Skip to content
Browse files

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...
1 parent c6faf29 commit e0af7b61e44127b731df1d66cbfe707723333334 @rolfl rolfl committed Sep 20, 2011
View
44 build.xml
@@ -65,6 +65,8 @@ For instructions on how to build JDOM, please view the README.txt file.
<property name="junit" value="./test" />
<property name="junit.src" value="${junit}/src/java" />
<property name="junit.build" value="${build}/junit" />
+ <property name="junit.xml" value="${build}/junit.xml" />
+ <property name="junit.report" value="${build}/junit.report" />
<property name="junit.instrumented" value="${build}/instrumented" />
@@ -326,6 +328,9 @@ For instructions on how to build JDOM, please view the README.txt file.
<delete dir="${dist.root}"/>
</target>
+ <!-- =================================================================== -->
+ <!-- JUnit and Test Coverage targets -->
+ <!-- =================================================================== -->
<target name="coverage.setup" description="Set up code-coverage metrics" depends="compile.core">
<taskdef classpathref="junit.class.path" resource="tasks.properties"/>
@@ -338,19 +343,49 @@ For instructions on how to build JDOM, please view the README.txt file.
<!-- exclude name="**/**/jaxen/**/*.class"/ -->
</fileset>
</cobertura-instrument>
-
+
+ <property name="forkjunit" value="true" />
+
</target>
<target name="junit" depends="compile.core, compile.junit"
description="Run all the JUnit tests">
- <junit fork="true" haltonerror="false" haltonfailure="false"
+
+ <delete dir="${junit.report}" />
+ <mkdir dir="${junit.report}" />
+
+ <delete dir="${junit.xml}" />
+ <mkdir dir="${junit.xml}" />
+
+ <!-- this may already be set true in the cobertura task. -->
+ <property name="forkjunit" value="false" />
+
+ <junit fork="${forkjunit}" forkmode="once" haltonerror="false" haltonfailure="false"
failureproperty="junit.failed" printsummary="true" timeout="100000"
showoutput="true" includeantruntime="true" >
+
<sysproperty key="net.sourceforge.cobertura.datafile"
file="${cobertura.datafile}" />
<classpath refid="junit.class.path" />
- <test name="org.jdom2.test.cases.Alltests" />
+
+ <formatter type="xml"/>
+
+ <batchtest haltonerror="false" haltonfailure="false"
+ failureproperty="junit.failed" todir="${junit.xml}" >
+ <fileset dir="${junit.build}">
+ <include name="**/Test*.java"/>
+ <exclude name="**/generate/**" />
+ </fileset>
+ </batchtest>
+
</junit>
+ <junitreport todir="${junit.report}">
+ <fileset dir="${junit.xml}">
+ <include name="TEST-*.xml"/>
+ </fileset>
+
+ <report format="frames" todir="${junit.report}"/>
+ </junitreport>
</target>
<target name="coverage" depends="coverage.setup, junit"
@@ -362,6 +397,9 @@ For instructions on how to build JDOM, please view the README.txt file.
</target>
+ <!-- =================================================================== -->
+ <!-- Eclipse targets -->
+ <!-- =================================================================== -->
<target name="eclipse" description="Set up your eclipse project (source folders, jars, etc.)">
<echo file="./.classpath" xml:space="preserve"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<classpath>
View
2 ...va/org/jdom2/TestIllegalAddException.java → ...java/org/jdom2/TestIllegalAddExceptn.java
@@ -6,7 +6,7 @@
import org.jdom2.IllegalAddException;
import org.junit.Test;
-public class TestIllegalAddException {
+public class TestIllegalAddExceptn {
@Test
public void testIllegalAddExceptionElementAttributeString() {
View
2 ...a/org/jdom2/TestIllegalNameException.java → ...ava/org/jdom2/TestIllegalNameExceptn.java
@@ -4,7 +4,7 @@
import org.junit.Test;
-public class TestIllegalNameException {
+public class TestIllegalNameExceptn {
@Test
public void testIllegalNameExceptionStringStringString() {
View
2 ...org/jdom2/TestIllegalTargetException.java → ...a/org/jdom2/TestIllegalTargetExceptn.java
@@ -4,7 +4,7 @@
import org.junit.Test;
-public class TestIllegalTargetException {
+public class TestIllegalTargetExceptn {
@Test
public void testIllegalTargetExceptionStringString() {
View
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
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.jdom2.TestIllegalAddException;
-import org.jdom2.TestIllegalNameException;
-import org.jdom2.TestIllegalTargetException;
+import org.jdom2.TestIllegalAddExceptn;
+import org.jdom2.TestIllegalNameExceptn;
+import org.jdom2.TestIllegalTargetExceptn;
import org.jdom2.test.cases.filter.TestContentFilter;
import org.jdom2.test.cases.filter.TestElementFilter;
import org.jdom2.test.cases.input.TestBuilderErrorHandler;
import org.jdom2.test.cases.input.TestDOMBuilder;
-import org.jdom2.test.cases.input.TestJDOMParseException;
+import org.jdom2.test.cases.input.TestJDOMParseExceptn;
import org.jdom2.test.cases.input.TestSAXBuilder;
import org.jdom2.test.cases.input.TestSAXComplexSchema;
import org.jdom2.test.cases.input.TestSAXHandler;
@@ -77,7 +77,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
import org.jdom2.test.cases.transform.TestJDOMResult;
import org.jdom2.test.cases.transform.TestJDOMSource;
import org.jdom2.test.cases.transform.TestJDOMTransform;
-import org.jdom2.test.cases.transform.TestXSLTransformException;
+import org.jdom2.test.cases.transform.TestXSLTransformExceptn;
import org.jdom2.test.cases.transform.TestXSLTransformer;
import org.jdom2.test.cases.xpath.AbstractTestXPath;
import org.jdom2.test.cases.xpath.TestJaxenXPath;
@@ -145,16 +145,16 @@ public static Test suite() {
suite.addTest(new JUnit4TestAdapter(TestDefaultJDOMFactory.class));
suite.addTest(new JUnit4TestAdapter(TestUncheckedJDOMFactory.class));
- suite.addTest(new JUnit4TestAdapter(TestJDOMException.class));
- suite.addTest(new JUnit4TestAdapter(TestIllegalAddException.class));
- suite.addTest(new JUnit4TestAdapter(TestIllegalNameException.class));
- suite.addTest(new JUnit4TestAdapter(TestIllegalTargetException.class));
+ suite.addTest(new JUnit4TestAdapter(TestJDOMExceptn.class));
+ suite.addTest(new JUnit4TestAdapter(TestIllegalAddExceptn.class));
+ suite.addTest(new JUnit4TestAdapter(TestIllegalNameExceptn.class));
+ suite.addTest(new JUnit4TestAdapter(TestIllegalTargetExceptn.class));
suite.addTest(new JUnit4TestAdapter(ListTest.class));
// Input Tests
suite.addTest(new JUnit4TestAdapter(TestBuilderErrorHandler.class));
- suite.addTest(new JUnit4TestAdapter(TestJDOMParseException.class));
+ suite.addTest(new JUnit4TestAdapter(TestJDOMParseExceptn.class));
suite.addTest(new JUnit4TestAdapter(TestSAXHandler.class));
suite.addTest(new JUnit4TestAdapter(TestSAXBuilder.class));
suite.addTest(new JUnit4TestAdapter(TestSAXComplexSchema.class));
@@ -171,7 +171,7 @@ public static Test suite() {
suite.addTest(new JUnit4TestAdapter(TestJDOMSource.class));
suite.addTest(new JUnit4TestAdapter(TestJDOMResult.class));
suite.addTest(new JUnit4TestAdapter(TestJDOMTransform.class));
- suite.addTest(new JUnit4TestAdapter(TestXSLTransformException.class));
+ suite.addTest(new JUnit4TestAdapter(TestXSLTransformExceptn.class));
suite.addTest(new JUnit4TestAdapter(TestXSLTransformer.class));
// XPath tests.
View
2 ...g/jdom2/test/cases/TestJDOMException.java → ...org/jdom2/test/cases/TestJDOMExceptn.java
@@ -10,7 +10,7 @@
import org.jdom2.JDOMException;
import org.junit.Test;
-public class TestJDOMException {
+public class TestJDOMExceptn {
@Test
public void testJDOMException() {
View
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
* @author unascribed
* @version 0.1
*/
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.fail;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -75,8 +74,6 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
import org.jdom2.Element;
import org.jdom2.Namespace;
import org.jdom2.Verifier;
-import org.jdom2.output.Format;
-import org.jdom2.output.XMLOutputter;
import org.junit.Test;
import org.junit.runner.JUnitCore;
@@ -432,7 +429,15 @@ public void testCheckNamespaceCollision() {
Element cpms = new Element ("cpms", mscp);
root.addContent(cpms);
- printlement(root);
+ //printlement(root);
+// XMLOutputter out = new XMLOutputter(Format.getPrettyFormat());
+// try {
+// CharArrayWriter w = new CharArrayWriter();
+// out.output(root, w);
+// } catch (IOException e) {
+// e.printStackTrace();
+// }
+
// Check Namespace against elements.
assertNull (Verifier.checkNamespaceCollision(att, root));
@@ -586,15 +591,4 @@ public void testIsXMLCharacter() {
}
- private static final void printlement(Element emt) {
- XMLOutputter out = new XMLOutputter(Format.getPrettyFormat());
- try {
- out.output(emt, System.out);
- System.out.println();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
}
View
2 test/src/java/org/jdom2/test/cases/filter/AbstractTestFilter.java
@@ -35,7 +35,7 @@ protected static final void assertFilterNotEquals(Filter a, Filter b) {
a.toString() + " and " + b.toString());
}
if (a.hashCode() == b.hashCode()) {
- System.err.println("Two different (not equals() ) Filters have " +
+ System.out.println("Two different (not equals() ) Filters have " +
"the same hashCode(): " + a.hashCode() + "\n " +
a.toString() + " \n " + b.toString());
}
View
3 ...t/cases/input/TestJDOMParseException.java → ...est/cases/input/TestJDOMParseExceptn.java
@@ -7,7 +7,8 @@
import org.junit.Test;
import org.xml.sax.SAXParseException;
-public class TestJDOMParseException {
+// Do not use name ending in Exception.
+public class TestJDOMParseExceptn {
private final SAXParseException spe = new SAXParseException("message", "publicID", "systemID", 5, 10);
View
2 test/src/java/org/jdom2/test/cases/input/TestSAXComplexSchema.java
@@ -61,7 +61,7 @@ public void testBuildFile() throws IOException {
StringWriter sw = new StringWriter();
out.output(doc, sw);
String xml = sw.toString();
- System.out.println("Document parsed. Content:\n" + xml + "\n");
+ //System.out.println("Document parsed. Content:\n" + xml + "\n");
Namespace defns = Namespace.getNamespace("http://www.jdom.org/tests/default");
Namespace impns = Namespace.getNamespace("http://www.jdom.org/tests/imp");
View
2 .../transform/TestXSLTransformException.java → ...es/transform/TestXSLTransformExceptn.java
@@ -5,7 +5,7 @@
import org.jdom2.transform.XSLTransformException;
import org.junit.Test;
-public class TestXSLTransformException {
+public class TestXSLTransformExceptn {
@Test
public void testXSLTransformException() {

0 comments on commit e0af7b6

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