aboutsummaryrefslogtreecommitdiff
path: root/org.jacoco.report.test/src
diff options
context:
space:
mode:
authorMarc R. Hoffmann <hoffmann@mountainminds.com>2011-01-16 16:39:53 +0000
committerMarc R. Hoffmann <hoffmann@mountainminds.com>2011-01-16 16:39:53 +0000
commitd37ff3d49e64d6c2d1088840e794c482593d484d (patch)
tree4b29ddade3a0f374207468d224eda7a62f9af144 /org.jacoco.report.test/src
parent1b18f2a611c6e3b0a9bc088cac4a3ce9b17ffc82 (diff)
downloadjacoco-d37ff3d49e64d6c2d1088840e794c482593d484d.tar.gz
Consistently use AssertionError for internal inconsistencies, corresponding unit tests.
Diffstat (limited to 'org.jacoco.report.test/src')
-rw-r--r--org.jacoco.report.test/src/org/jacoco/report/csv/CSVGroupHandlerTest.java52
-rw-r--r--org.jacoco.report.test/src/org/jacoco/report/csv/CSVPackageHandlerTest.java57
-rw-r--r--org.jacoco.report.test/src/org/jacoco/report/internal/html/PackagePageTest.java111
-rw-r--r--org.jacoco.report.test/src/org/jacoco/report/internal/html/SourceFilePageTest.java4
4 files changed, 222 insertions, 2 deletions
diff --git a/org.jacoco.report.test/src/org/jacoco/report/csv/CSVGroupHandlerTest.java b/org.jacoco.report.test/src/org/jacoco/report/csv/CSVGroupHandlerTest.java
new file mode 100644
index 00000000..6ab77036
--- /dev/null
+++ b/org.jacoco.report.test/src/org/jacoco/report/csv/CSVGroupHandlerTest.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2011 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.csv;
+
+import java.io.StringWriter;
+
+import org.jacoco.core.analysis.CoverageNodeImpl;
+import org.jacoco.core.analysis.ICoverageNode.ElementType;
+import org.jacoco.report.IReportVisitor;
+import org.jacoco.report.JavaNames;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Unit tests for {@link CSVGroupHandler}.
+ */
+public class CSVGroupHandlerTest {
+
+ private IReportVisitor handler;
+
+ @Before
+ public void setup() throws Exception {
+ final DelimitedWriter dw = new DelimitedWriter(new StringWriter());
+ final ClassRowWriter rw = new ClassRowWriter(dw, new JavaNames());
+ handler = new CSVGroupHandler(rw, "group");
+ }
+
+ @Test(expected = AssertionError.class)
+ public void testVisitChildNegative1() throws Exception {
+ handler.visitChild(new CoverageNodeImpl(ElementType.CLASS, "Foo"));
+ }
+
+ @Test(expected = AssertionError.class)
+ public void testVisitChildNegative2() throws Exception {
+ handler.visitChild(new CoverageNodeImpl(ElementType.METHOD, "Foo"));
+ }
+
+ @Test(expected = AssertionError.class)
+ public void testVisitChildNegative3() throws Exception {
+ handler.visitChild(new CoverageNodeImpl(ElementType.SOURCEFILE, "Foo"));
+ }
+
+}
diff --git a/org.jacoco.report.test/src/org/jacoco/report/csv/CSVPackageHandlerTest.java b/org.jacoco.report.test/src/org/jacoco/report/csv/CSVPackageHandlerTest.java
new file mode 100644
index 00000000..bbb03569
--- /dev/null
+++ b/org.jacoco.report.test/src/org/jacoco/report/csv/CSVPackageHandlerTest.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2011 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.csv;
+
+import java.io.StringWriter;
+
+import org.jacoco.core.analysis.CoverageNodeImpl;
+import org.jacoco.core.analysis.ICoverageNode.ElementType;
+import org.jacoco.report.IReportVisitor;
+import org.jacoco.report.JavaNames;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Unit tests for {@link CSVPackageHandler}.
+ */
+public class CSVPackageHandlerTest {
+
+ private IReportVisitor handler;
+
+ @Before
+ public void setup() throws Exception {
+ final DelimitedWriter dw = new DelimitedWriter(new StringWriter());
+ final ClassRowWriter rw = new ClassRowWriter(dw, new JavaNames());
+ handler = new CSVPackageHandler(rw, "group", "package");
+ }
+
+ @Test(expected = AssertionError.class)
+ public void testVisitChildNegative1() throws Exception {
+ handler.visitChild(new CoverageNodeImpl(ElementType.GROUP, "Foo"));
+ }
+
+ @Test(expected = AssertionError.class)
+ public void testVisitChildNegative2() throws Exception {
+ handler.visitChild(new CoverageNodeImpl(ElementType.BUNDLE, "Foo"));
+ }
+
+ @Test(expected = AssertionError.class)
+ public void testVisitChildNegative3() throws Exception {
+ handler.visitChild(new CoverageNodeImpl(ElementType.PACKAGE, "Foo"));
+ }
+
+ @Test(expected = AssertionError.class)
+ public void testVisitChildNegative4() throws Exception {
+ handler.visitChild(new CoverageNodeImpl(ElementType.METHOD, "Foo"));
+ }
+
+}
diff --git a/org.jacoco.report.test/src/org/jacoco/report/internal/html/PackagePageTest.java b/org.jacoco.report.test/src/org/jacoco/report/internal/html/PackagePageTest.java
new file mode 100644
index 00000000..86e63f1e
--- /dev/null
+++ b/org.jacoco.report.test/src/org/jacoco/report/internal/html/PackagePageTest.java
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2011 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal.html;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Locale;
+
+import org.jacoco.core.analysis.CoverageNodeImpl;
+import org.jacoco.core.analysis.IClassCoverage;
+import org.jacoco.core.analysis.ICoverageNode.ElementType;
+import org.jacoco.core.analysis.IPackageCoverage;
+import org.jacoco.core.analysis.ISourceFileCoverage;
+import org.jacoco.core.internal.analysis.PackageCoverageImpl;
+import org.jacoco.report.ILanguageNames;
+import org.jacoco.report.MemoryMultiReportOutput;
+import org.jacoco.report.ReportOutputFolder;
+import org.jacoco.report.internal.html.index.IIndexUpdate;
+import org.jacoco.report.internal.html.resources.Resources;
+import org.jacoco.report.internal.html.table.Table;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Unit tests for {@link PackagePage}.
+ */
+public class PackagePageTest {
+
+ private MemoryMultiReportOutput output;
+
+ private ReportOutputFolder root;
+
+ private IHTMLReportContext context;
+
+ private PackagePage page;
+
+ @Before
+ public void setup() {
+ output = new MemoryMultiReportOutput();
+ root = new ReportOutputFolder(output);
+ context = new IHTMLReportContext() {
+
+ public ILanguageNames getLanguageNames() {
+ throw new AssertionError("Unexpected method call.");
+ }
+
+ public Resources getResources() {
+ throw new AssertionError("Unexpected method call.");
+ }
+
+ public Table getTable() {
+ throw new AssertionError("Unexpected method call.");
+ }
+
+ public String getFooterText() {
+ throw new AssertionError("Unexpected method call.");
+ }
+
+ public ILinkable getSessionsPage() {
+ throw new AssertionError("Unexpected method call.");
+ }
+
+ public String getOutputEncoding() {
+ throw new AssertionError("Unexpected method call.");
+ }
+
+ public IIndexUpdate getIndexUpdate() {
+ throw new AssertionError("Unexpected method call.");
+ }
+
+ public Locale getLocale() {
+ throw new AssertionError("Unexpected method call.");
+ }
+ };
+ Collection<IClassCoverage> classes = Collections.emptyList();
+ Collection<ISourceFileCoverage> sources = Collections.emptyList();
+ final IPackageCoverage node = new PackageCoverageImpl("foo", classes,
+ sources);
+ page = new PackagePage(node, null, root, context);
+ }
+
+ @Test(expected = AssertionError.class)
+ public void testVisitChildNegative1() {
+ page.visitChild(new CoverageNodeImpl(ElementType.GROUP, "Foo"));
+ }
+
+ @Test(expected = AssertionError.class)
+ public void testVisitChildNegative2() {
+ page.visitChild(new CoverageNodeImpl(ElementType.BUNDLE, "Foo"));
+ }
+
+ @Test(expected = AssertionError.class)
+ public void testVisitChildNegative3() {
+ page.visitChild(new CoverageNodeImpl(ElementType.PACKAGE, "Foo"));
+ }
+
+ @Test(expected = AssertionError.class)
+ public void testVisitChildNegative4() {
+ page.visitChild(new CoverageNodeImpl(ElementType.METHOD, "Foo"));
+ }
+
+}
diff --git a/org.jacoco.report.test/src/org/jacoco/report/internal/html/SourceFilePageTest.java b/org.jacoco.report.test/src/org/jacoco/report/internal/html/SourceFilePageTest.java
index 849fb49c..45752118 100644
--- a/org.jacoco.report.test/src/org/jacoco/report/internal/html/SourceFilePageTest.java
+++ b/org.jacoco.report.test/src/org/jacoco/report/internal/html/SourceFilePageTest.java
@@ -97,8 +97,8 @@ public class SourceFilePageTest {
output.assertAllClosed();
}
- @Test(expected = IllegalStateException.class)
- public void testVisitChild() {
+ @Test(expected = AssertionError.class)
+ public void testVisitChildNegative() {
final SourceFileCoverageImpl node = new SourceFileCoverageImpl(
"SourceFilePageTest.java", "org/jacoco/report/html");
final SourceFilePage page = new SourceFilePage(node, null, root,