Skip to content
This repository
Browse code

Tidy up the ant junit process.

Remove dependency on AllTests.java which is a JUnit3 throwback.
Rename all tests named 'Test*Exception' to 'Test*Exceptn' because
eclipse/ant hooks in to the *Exception name and makes thinks 'clickable'
and they are not in fact Exception classes.
Update the junit ant task to produce HTML reports.
Make the coverage process work with the new report style.
  • Loading branch information...
commit e0af7b61e44127b731df1d66cbfe707723333334 1 parent c6faf29
Rolf rolfl authored
44 build.xml
@@ -65,6 +65,8 @@ For instructions on how to build JDOM, please view the README.txt file.
65 65 <property name="junit" value="./test" />
66 66 <property name="junit.src" value="${junit}/src/java" />
67 67 <property name="junit.build" value="${build}/junit" />
  68 + <property name="junit.xml" value="${build}/junit.xml" />
  69 + <property name="junit.report" value="${build}/junit.report" />
68 70 <property name="junit.instrumented" value="${build}/instrumented" />
69 71
70 72
@@ -326,6 +328,9 @@ For instructions on how to build JDOM, please view the README.txt file.
326 328 <delete dir="${dist.root}"/>
327 329 </target>
328 330
  331 + <!-- =================================================================== -->
  332 + <!-- JUnit and Test Coverage targets -->
  333 + <!-- =================================================================== -->
329 334 <target name="coverage.setup" description="Set up code-coverage metrics" depends="compile.core">
330 335 <taskdef classpathref="junit.class.path" resource="tasks.properties"/>
331 336
@@ -338,19 +343,49 @@ For instructions on how to build JDOM, please view the README.txt file.
338 343 <!-- exclude name="**/**/jaxen/**/*.class"/ -->
339 344 </fileset>
340 345 </cobertura-instrument>
341   -
  346 +
  347 + <property name="forkjunit" value="true" />
  348 +
342 349 </target>
343 350
344 351 <target name="junit" depends="compile.core, compile.junit"
345 352 description="Run all the JUnit tests">
346   - <junit fork="true" haltonerror="false" haltonfailure="false"
  353 +
  354 + <delete dir="${junit.report}" />
  355 + <mkdir dir="${junit.report}" />
  356 +
  357 + <delete dir="${junit.xml}" />
  358 + <mkdir dir="${junit.xml}" />
  359 +
  360 + <!-- this may already be set true in the cobertura task. -->
  361 + <property name="forkjunit" value="false" />
  362 +
  363 + <junit fork="${forkjunit}" forkmode="once" haltonerror="false" haltonfailure="false"
347 364 failureproperty="junit.failed" printsummary="true" timeout="100000"
348 365 showoutput="true" includeantruntime="true" >
  366 +
349 367 <sysproperty key="net.sourceforge.cobertura.datafile"
350 368 file="${cobertura.datafile}" />
351 369 <classpath refid="junit.class.path" />
352   - <test name="org.jdom2.test.cases.Alltests" />
  370 +
  371 + <formatter type="xml"/>
  372 +
  373 + <batchtest haltonerror="false" haltonfailure="false"
  374 + failureproperty="junit.failed" todir="${junit.xml}" >
  375 + <fileset dir="${junit.build}">
  376 + <include name="**/Test*.java"/>
  377 + <exclude name="**/generate/**" />
  378 + </fileset>
  379 + </batchtest>
  380 +
353 381 </junit>
  382 + <junitreport todir="${junit.report}">
  383 + <fileset dir="${junit.xml}">
  384 + <include name="TEST-*.xml"/>
  385 + </fileset>
  386 +
  387 + <report format="frames" todir="${junit.report}"/>
  388 + </junitreport>
354 389 </target>
355 390
356 391 <target name="coverage" depends="coverage.setup, junit"
@@ -362,6 +397,9 @@ For instructions on how to build JDOM, please view the README.txt file.
362 397 </target>
363 398
364 399
  400 + <!-- =================================================================== -->
  401 + <!-- Eclipse targets -->
  402 + <!-- =================================================================== -->
365 403 <target name="eclipse" description="Set up your eclipse project (source folders, jars, etc.)">
366 404 <echo file="./.classpath" xml:space="preserve"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
367 405 <classpath>
2  test/src/java/org/jdom2/TestIllegalAddException.java → test/src/java/org/jdom2/TestIllegalAddExceptn.java
@@ -6,7 +6,7 @@
6 6 import org.jdom2.IllegalAddException;
7 7 import org.junit.Test;
8 8
9   -public class TestIllegalAddException {
  9 +public class TestIllegalAddExceptn {
10 10
11 11 @Test
12 12 public void testIllegalAddExceptionElementAttributeString() {
2  .../src/java/org/jdom2/TestIllegalNameException.java → test/src/java/org/jdom2/TestIllegalNameExceptn.java
@@ -4,7 +4,7 @@
4 4
5 5 import org.junit.Test;
6 6
7   -public class TestIllegalNameException {
  7 +public class TestIllegalNameExceptn {
8 8
9 9 @Test
10 10 public void testIllegalNameExceptionStringStringString() {
2  ...rc/java/org/jdom2/TestIllegalTargetException.java → .../src/java/org/jdom2/TestIllegalTargetExceptn.java
@@ -4,7 +4,7 @@
4 4
5 5 import org.junit.Test;
6 6
7   -public class TestIllegalTargetException {
  7 +public class TestIllegalTargetExceptn {
8 8
9 9 @Test
10 10 public void testIllegalTargetExceptionStringString() {
22 test/src/java/org/jdom2/test/cases/Alltests.java
@@ -59,14 +59,14 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
59 59 import junit.framework.Test;
60 60 import junit.framework.TestSuite;
61 61
62   -import org.jdom2.TestIllegalAddException;
63   -import org.jdom2.TestIllegalNameException;
64   -import org.jdom2.TestIllegalTargetException;
  62 +import org.jdom2.TestIllegalAddExceptn;
  63 +import org.jdom2.TestIllegalNameExceptn;
  64 +import org.jdom2.TestIllegalTargetExceptn;
65 65 import org.jdom2.test.cases.filter.TestContentFilter;
66 66 import org.jdom2.test.cases.filter.TestElementFilter;
67 67 import org.jdom2.test.cases.input.TestBuilderErrorHandler;
68 68 import org.jdom2.test.cases.input.TestDOMBuilder;
69   -import org.jdom2.test.cases.input.TestJDOMParseException;
  69 +import org.jdom2.test.cases.input.TestJDOMParseExceptn;
70 70 import org.jdom2.test.cases.input.TestSAXBuilder;
71 71 import org.jdom2.test.cases.input.TestSAXComplexSchema;
72 72 import org.jdom2.test.cases.input.TestSAXHandler;
@@ -77,7 +77,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
77 77 import org.jdom2.test.cases.transform.TestJDOMResult;
78 78 import org.jdom2.test.cases.transform.TestJDOMSource;
79 79 import org.jdom2.test.cases.transform.TestJDOMTransform;
80   -import org.jdom2.test.cases.transform.TestXSLTransformException;
  80 +import org.jdom2.test.cases.transform.TestXSLTransformExceptn;
81 81 import org.jdom2.test.cases.transform.TestXSLTransformer;
82 82 import org.jdom2.test.cases.xpath.AbstractTestXPath;
83 83 import org.jdom2.test.cases.xpath.TestJaxenXPath;
@@ -145,16 +145,16 @@ public static Test suite() {
145 145 suite.addTest(new JUnit4TestAdapter(TestDefaultJDOMFactory.class));
146 146 suite.addTest(new JUnit4TestAdapter(TestUncheckedJDOMFactory.class));
147 147
148   - suite.addTest(new JUnit4TestAdapter(TestJDOMException.class));
149   - suite.addTest(new JUnit4TestAdapter(TestIllegalAddException.class));
150   - suite.addTest(new JUnit4TestAdapter(TestIllegalNameException.class));
151   - suite.addTest(new JUnit4TestAdapter(TestIllegalTargetException.class));
  148 + suite.addTest(new JUnit4TestAdapter(TestJDOMExceptn.class));
  149 + suite.addTest(new JUnit4TestAdapter(TestIllegalAddExceptn.class));
  150 + suite.addTest(new JUnit4TestAdapter(TestIllegalNameExceptn.class));
  151 + suite.addTest(new JUnit4TestAdapter(TestIllegalTargetExceptn.class));
152 152
153 153 suite.addTest(new JUnit4TestAdapter(ListTest.class));
154 154
155 155 // Input Tests
156 156 suite.addTest(new JUnit4TestAdapter(TestBuilderErrorHandler.class));
157   - suite.addTest(new JUnit4TestAdapter(TestJDOMParseException.class));
  157 + suite.addTest(new JUnit4TestAdapter(TestJDOMParseExceptn.class));
158 158 suite.addTest(new JUnit4TestAdapter(TestSAXHandler.class));
159 159 suite.addTest(new JUnit4TestAdapter(TestSAXBuilder.class));
160 160 suite.addTest(new JUnit4TestAdapter(TestSAXComplexSchema.class));
@@ -171,7 +171,7 @@ public static Test suite() {
171 171 suite.addTest(new JUnit4TestAdapter(TestJDOMSource.class));
172 172 suite.addTest(new JUnit4TestAdapter(TestJDOMResult.class));
173 173 suite.addTest(new JUnit4TestAdapter(TestJDOMTransform.class));
174   - suite.addTest(new JUnit4TestAdapter(TestXSLTransformException.class));
  174 + suite.addTest(new JUnit4TestAdapter(TestXSLTransformExceptn.class));
175 175 suite.addTest(new JUnit4TestAdapter(TestXSLTransformer.class));
176 176
177 177 // XPath tests.
2  .../java/org/jdom2/test/cases/TestJDOMException.java → ...rc/java/org/jdom2/test/cases/TestJDOMExceptn.java
@@ -10,7 +10,7 @@
10 10 import org.jdom2.JDOMException;
11 11 import org.junit.Test;
12 12
13   -public class TestJDOMException {
  13 +public class TestJDOMExceptn {
14 14
15 15 @Test
16 16 public void testJDOMException() {
26 test/src/java/org/jdom2/test/cases/TestVerifier.java
@@ -60,13 +60,12 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
60 60 * @author unascribed
61 61 * @version 0.1
62 62 */
  63 +import static org.junit.Assert.assertFalse;
63 64 import static org.junit.Assert.assertNotNull;
64 65 import static org.junit.Assert.assertNull;
65 66 import static org.junit.Assert.assertTrue;
66   -import static org.junit.Assert.assertFalse;
67 67 import static org.junit.Assert.fail;
68 68
69   -import java.io.IOException;
70 69 import java.util.ArrayList;
71 70 import java.util.Arrays;
72 71 import java.util.List;
@@ -75,8 +74,6 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
75 74 import org.jdom2.Element;
76 75 import org.jdom2.Namespace;
77 76 import org.jdom2.Verifier;
78   -import org.jdom2.output.Format;
79   -import org.jdom2.output.XMLOutputter;
80 77 import org.junit.Test;
81 78 import org.junit.runner.JUnitCore;
82 79
@@ -432,7 +429,15 @@ public void testCheckNamespaceCollision() {
432 429 Element cpms = new Element ("cpms", mscp);
433 430 root.addContent(cpms);
434 431
435   - printlement(root);
  432 + //printlement(root);
  433 +// XMLOutputter out = new XMLOutputter(Format.getPrettyFormat());
  434 +// try {
  435 +// CharArrayWriter w = new CharArrayWriter();
  436 +// out.output(root, w);
  437 +// } catch (IOException e) {
  438 +// e.printStackTrace();
  439 +// }
  440 +
436 441
437 442 // Check Namespace against elements.
438 443 assertNull (Verifier.checkNamespaceCollision(att, root));
@@ -586,15 +591,4 @@ public void testIsXMLCharacter() {
586 591
587 592 }
588 593
589   - private static final void printlement(Element emt) {
590   - XMLOutputter out = new XMLOutputter(Format.getPrettyFormat());
591   - try {
592   - out.output(emt, System.out);
593   - System.out.println();
594   - } catch (IOException e) {
595   - // TODO Auto-generated catch block
596   - e.printStackTrace();
597   - }
598   - }
599   -
600 594 }
2  test/src/java/org/jdom2/test/cases/filter/AbstractTestFilter.java
@@ -35,7 +35,7 @@ protected static final void assertFilterNotEquals(Filter a, Filter b) {
35 35 a.toString() + " and " + b.toString());
36 36 }
37 37 if (a.hashCode() == b.hashCode()) {
38   - System.err.println("Two different (not equals() ) Filters have " +
  38 + System.out.println("Two different (not equals() ) Filters have " +
39 39 "the same hashCode(): " + a.hashCode() + "\n " +
40 40 a.toString() + " \n " + b.toString());
41 41 }
3  ...dom2/test/cases/input/TestJDOMParseException.java → .../jdom2/test/cases/input/TestJDOMParseExceptn.java
@@ -7,7 +7,8 @@
7 7 import org.junit.Test;
8 8 import org.xml.sax.SAXParseException;
9 9
10   -public class TestJDOMParseException {
  10 +// Do not use name ending in Exception.
  11 +public class TestJDOMParseExceptn {
11 12
12 13 private final SAXParseException spe = new SAXParseException("message", "publicID", "systemID", 5, 10);
13 14
2  test/src/java/org/jdom2/test/cases/input/TestSAXComplexSchema.java
@@ -61,7 +61,7 @@ public void testBuildFile() throws IOException {
61 61 StringWriter sw = new StringWriter();
62 62 out.output(doc, sw);
63 63 String xml = sw.toString();
64   - System.out.println("Document parsed. Content:\n" + xml + "\n");
  64 + //System.out.println("Document parsed. Content:\n" + xml + "\n");
65 65
66 66 Namespace defns = Namespace.getNamespace("http://www.jdom.org/tests/default");
67 67 Namespace impns = Namespace.getNamespace("http://www.jdom.org/tests/imp");
2  ...st/cases/transform/TestXSLTransformException.java → ...test/cases/transform/TestXSLTransformExceptn.java
@@ -5,7 +5,7 @@
5 5 import org.jdom2.transform.XSLTransformException;
6 6 import org.junit.Test;
7 7
8   -public class TestXSLTransformException {
  8 +public class TestXSLTransformExceptn {
9 9
10 10 @Test
11 11 public void testXSLTransformException() {

0 comments on commit e0af7b6

Please sign in to comment.
Something went wrong with that request. Please try again.