diff --git a/src/etc/testcases/taskdefs/exec/exec.xml b/src/etc/testcases/taskdefs/exec/exec.xml index 8c977f508..20e56565f 100644 --- a/src/etc/testcases/taskdefs/exec/exec.xml +++ b/src/etc/testcases/taskdefs/exec/exec.xml @@ -16,56 +16,54 @@ limitations under the License. --> - - - - - - - - - - - - - - - - - - - - - + - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + - + + + + + + + + + + + + + + + + + - - - - diff --git a/src/etc/testcases/taskdefs/fixcrlf/build.xml b/src/etc/testcases/taskdefs/fixcrlf/build.xml index 4547ec4b4..3a4280e6b 100644 --- a/src/etc/testcases/taskdefs/fixcrlf/build.xml +++ b/src/etc/testcases/taskdefs/fixcrlf/build.xml @@ -16,18 +16,17 @@ limitations under the License. --> - - - + - - + + + - + @@ -40,84 +39,84 @@ - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + Q - + @@ -125,112 +124,112 @@ - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + + - - + + - + - - + + - - + - - + - - + - - + + @@ -239,8 +238,8 @@ - - + + @@ -248,8 +247,8 @@ - - + + @@ -257,8 +256,8 @@ - - + + @@ -266,8 +265,8 @@ - - + + @@ -275,8 +274,8 @@ - - + + @@ -284,8 +283,8 @@ - - + + @@ -293,8 +292,8 @@ - - + + @@ -302,8 +301,8 @@ - - + + @@ -312,13 +311,13 @@ - - diff --git a/src/etc/testcases/taskdefs/optional/jspc.xml b/src/etc/testcases/taskdefs/optional/jspc.xml index b0c1ef2ac..f1207908e 100644 --- a/src/etc/testcases/taskdefs/optional/jspc.xml +++ b/src/etc/testcases/taskdefs/optional/jspc.xml @@ -18,116 +18,116 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/etc/testcases/taskdefs/optional/junit.xml b/src/etc/testcases/taskdefs/optional/junit.xml index 465e7f3e5..8a4943e8e 100644 --- a/src/etc/testcases/taskdefs/optional/junit.xml +++ b/src/etc/testcases/taskdefs/optional/junit.xml @@ -17,17 +17,18 @@ --> + + + + + + - - - - - @@ -91,11 +92,12 @@ - + @@ -112,12 +114,11 @@ - - + - + @@ -132,11 +133,11 @@ - + - + @@ -150,12 +151,12 @@ - + - + @@ -169,7 +170,7 @@ - + import junit.framework.*; @@ -210,7 +211,7 @@ - + @@ -248,7 +249,7 @@ - + import junit.framework.*; public class A extends TestCase { @@ -278,12 +279,12 @@ - + - + @@ -295,12 +296,12 @@ - + - + @@ -311,12 +312,12 @@ - + - + @@ -326,7 +327,7 @@ - + public class T1 extends junit.framework.TestCase { public void testOK() {} diff --git a/src/etc/testcases/taskdefs/optional/junitreport.xml b/src/etc/testcases/taskdefs/optional/junitreport.xml index dd6b2e17c..608066256 100644 --- a/src/etc/testcases/taskdefs/optional/junitreport.xml +++ b/src/etc/testcases/taskdefs/optional/junitreport.xml @@ -16,138 +16,139 @@ limitations under the License. --> - + - - + + + + + + + + - - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - - - - - + + - + - - - + + + - - + + - + - - - + + + - - + + - + - - + + - + - - + + - + - - + + - @@ -155,24 +156,24 @@ - - + + - - - + + - @@ -180,7 +181,7 @@ - + diff --git a/src/etc/testcases/taskdefs/optional/propertyfile.xml b/src/etc/testcases/taskdefs/optional/propertyfile.xml index e656f5d24..20a17271b 100644 --- a/src/etc/testcases/taskdefs/optional/propertyfile.xml +++ b/src/etc/testcases/taskdefs/optional/propertyfile.xml @@ -18,7 +18,13 @@ - + + + + + + + @@ -29,7 +35,7 @@ @@ -43,14 +49,14 @@ - + @@ -91,11 +97,11 @@ value="8" pattern="MMdd"/> - + - + foo=3 @@ -103,11 +109,11 @@ - + - + diff --git a/src/etc/testcases/taskdefs/property.xml b/src/etc/testcases/taskdefs/property.xml index 6949fee83..87cda8b01 100644 --- a/src/etc/testcases/taskdefs/property.xml +++ b/src/etc/testcases/taskdefs/property.xml @@ -18,13 +18,14 @@ - - + - - + + + + @@ -70,8 +71,7 @@ - - <?xml version="1.0" encoding="UTF-8"?> + <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties version="1.0"> <comment> @@ -85,7 +85,7 @@ - + diff --git a/src/etc/testcases/taskdefs/recorder.xml b/src/etc/testcases/taskdefs/recorder.xml index ab108b921..1c073118c 100644 --- a/src/etc/testcases/taskdefs/recorder.xml +++ b/src/etc/testcases/taskdefs/recorder.xml @@ -17,60 +17,57 @@ --> - - + - + + + - - - + - - - - - - + - - - - - - + + + + + + - - - - - - - - - + + + + + + - - - - - - - - - - + + + + + + + + + - - - - - - + + + + + + + + + + + + + + + + - - - diff --git a/src/etc/testcases/taskdefs/recorder2.xml b/src/etc/testcases/taskdefs/recorder2.xml index da69f9de2..e093cf519 100644 --- a/src/etc/testcases/taskdefs/recorder2.xml +++ b/src/etc/testcases/taskdefs/recorder2.xml @@ -17,16 +17,13 @@ --> - - - - + - + - + - + diff --git a/src/etc/testcases/taskdefs/replace.xml b/src/etc/testcases/taskdefs/replace.xml index 25abfc3d0..a4039e536 100644 --- a/src/etc/testcases/taskdefs/replace.xml +++ b/src/etc/testcases/taskdefs/replace.xml @@ -18,7 +18,12 @@ - + + + + + + @@ -64,29 +69,26 @@ - - - - + + + + - - + + - - Hello, world! + + Hello, world! - + - - - - diff --git a/src/etc/testcases/taskdefs/signjar.xml b/src/etc/testcases/taskdefs/signjar.xml index 485cde807..38a13592c 100644 --- a/src/etc/testcases/taskdefs/signjar.xml +++ b/src/etc/testcases/taskdefs/signjar.xml @@ -17,11 +17,16 @@ --> - - - - - + + + + + + + + + + @@ -45,27 +50,14 @@ storepass="apacheant"/> - - - - - - - - + - - - - - - This build is for use with Ant's test cases diff --git a/src/etc/testcases/taskdefs/sync.xml b/src/etc/testcases/taskdefs/sync.xml index c1d10d1a1..d2eb126e7 100644 --- a/src/etc/testcases/taskdefs/sync.xml +++ b/src/etc/testcases/taskdefs/sync.xml @@ -16,24 +16,21 @@ limitations under the License. --> - + - - This file must be used from a test case - - - - - - - - - + + + + - + + This file must be used from a test case + + + @@ -41,7 +38,7 @@ - + @@ -51,7 +48,7 @@ - + @@ -64,7 +61,7 @@ - + @@ -77,7 +74,7 @@ - + @@ -88,7 +85,7 @@ - + @@ -96,7 +93,7 @@ - + - + @@ -115,7 +112,7 @@ - + @@ -128,7 +125,7 @@ - + diff --git a/src/etc/testcases/taskdefs/war.xml b/src/etc/testcases/taskdefs/war.xml index d8bca4965..b000ecf5b 100644 --- a/src/etc/testcases/taskdefs/war.xml +++ b/src/etc/testcases/taskdefs/war.xml @@ -17,25 +17,23 @@ --> - + + + + + + - - - - - + - + - + - - - diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ExecTaskTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ExecTaskTest.java index a80100a6e..27a4a71ce 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/ExecTaskTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ExecTaskTest.java @@ -52,20 +52,13 @@ public class ExecTaskTest extends BuildFileTest { configureProject(BUILD_FILE); } - public void tearDown() { - if (logFile != null && logFile.exists()) { - getProject().setProperty("logFile", logFile.getAbsolutePath()); - } - executeTarget("cleanup"); - } - public void testspawn() { - project.executeTarget("init"); + project.executeTarget("setUp"); if (project.getProperty("test.can.run") == null) { return; } myBuild = new MonitoredBuild(new File(System.getProperty("root"), BUILD_FILE), "spawn"); - logFile = FILE_UTILS.createTempFile("spawn", "log", project.getBaseDir(), false, false); + logFile = FILE_UTILS.createTempFile("spawn", "log", getOutputDir(), false, false); // this is guaranteed by FileUtils#createTempFile assertTrue("log file not existing", !logFile.exists()); // make the spawned process run 4 seconds diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/FixCrLfTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/FixCrLfTest.java index 98b2cb294..b739b835b 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/FixCrLfTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/FixCrLfTest.java @@ -40,10 +40,6 @@ public class FixCrLfTest extends BuildFileTest { configureProject("src/etc/testcases/taskdefs/fixcrlf/build.xml"); } - public void tearDown() { - executeTarget("cleanup"); - } - public void test1() throws IOException { executeTarget("test1"); } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java index b830f5323..aa1e4a79f 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java @@ -35,6 +35,7 @@ public class PropertyTest extends BuildFileTest { public void setUp() { configureProject("src/etc/testcases/taskdefs/property.xml"); + project.executeTarget("setUp"); } public void test1() { diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/RecorderTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/RecorderTest.java index 4c8d4389e..a057e50e6 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/RecorderTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/RecorderTest.java @@ -21,6 +21,7 @@ package org.apache.tools.ant.taskdefs; import org.apache.tools.ant.BuildFileTest; import org.apache.tools.ant.util.FileUtils; +import java.io.File; import java.io.IOException; /** @@ -39,11 +40,7 @@ public class RecorderTest extends BuildFileTest { public void setUp() { configureProject("src/etc/testcases/taskdefs/recorder.xml"); - executeTarget("prepare"); - } - - public void tearDown() { - executeTarget("cleanup"); + executeTarget("setUp"); } public void testNoAppend() throws IOException { @@ -51,8 +48,8 @@ public class RecorderTest extends BuildFileTest { assertTrue(FILE_UTILS .contentEquals(project.resolveFile(REC_IN + "rectest1.result"), - project.resolveFile(REC_DIR - + "rectest1.log"), true)); + new File(getOutputDir(), + "rectest1.log"), true)); } public void testAppend() throws IOException { @@ -60,8 +57,8 @@ public class RecorderTest extends BuildFileTest { assertTrue(FILE_UTILS .contentEquals(project.resolveFile(REC_IN + "rectest2.result"), - project.resolveFile(REC_DIR - + "rectest2.log"), true)); + new File(getOutputDir(), + "rectest2.log"), true)); } public void testRestart() throws IOException { @@ -69,8 +66,7 @@ public class RecorderTest extends BuildFileTest { assertTrue(FILE_UTILS .contentEquals(project.resolveFile(REC_IN + "rectest3.result"), - project.resolveFile(REC_DIR - + "rectest3.log"), true)); + new File(getOutputDir(), "rectest3.log"), true)); } public void testDeleteRestart() throws IOException { @@ -78,8 +74,8 @@ public class RecorderTest extends BuildFileTest { assertTrue(FILE_UTILS .contentEquals(project.resolveFile(REC_IN + "rectest4.result"), - project.resolveFile(REC_DIR - + "rectest4.log"), true)); + new File(getOutputDir(), + "rectest4.log"), true)); } public void testSubBuild() throws IOException { @@ -87,13 +83,11 @@ public class RecorderTest extends BuildFileTest { assertTrue(FILE_UTILS .contentEquals(project.resolveFile(REC_IN + "rectest5.result"), - project.resolveFile(REC_DIR - + "rectest5.log"), true)); + new File(getOutputDir(), "rectest5.log"), true)); assertTrue(FILE_UTILS .contentEquals(project.resolveFile(REC_IN + "rectest6.result"), - project.resolveFile(REC_DIR - + "rectest6.log"), true)); + new File(getOutputDir(), "rectest6.log"), true)); } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ReplaceTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ReplaceTest.java index 9eedf44d5..ccefcd19b 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/ReplaceTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ReplaceTest.java @@ -34,6 +34,7 @@ public class ReplaceTest extends BuildFileTest { public void setUp() { configureProject("src/etc/testcases/taskdefs/replace.xml"); + project.executeTarget("setUp"); } public void test1() { @@ -70,32 +71,26 @@ public class ReplaceTest extends BuildFileTest { public void test9() throws IOException { executeTarget("test9"); - String tmpdir = project.getProperty("tmp.dir"); - assertEqualContent(new File(tmpdir, "result.txt"), - new File(tmpdir, "output.txt")); + assertEqualContent(new File(getOutputDir(), "result.txt"), + new File(getOutputDir(), "output.txt")); } public void testNoPreserveLastModified() throws Exception { executeTarget("lastModifiedSetup"); - String tmpdir = project.getProperty("tmp.dir"); - long ts1 = new File(tmpdir, "test.txt").lastModified(); + long ts1 = new File(getOutputDir(), "test.txt").lastModified(); Thread.sleep(3000); executeTarget("testNoPreserve"); - assertTrue(ts1 < new File(tmpdir, "test.txt").lastModified()); + assertTrue(ts1 < new File(getOutputDir(), "test.txt").lastModified()); } public void testPreserveLastModified() throws Exception { executeTarget("lastModifiedSetup"); - String tmpdir = project.getProperty("tmp.dir"); - long ts1 = new File(tmpdir, "test.txt").lastModified(); + long ts1 = new File(getOutputDir(), "test.txt").lastModified(); Thread.sleep(3000); executeTarget("testPreserve"); - assertTrue(ts1 == new File(tmpdir, "test.txt").lastModified()); + assertTrue(ts1 == new File(getOutputDir(), "test.txt").lastModified()); } - public void tearDown() { - executeTarget("cleanup"); - } public void assertEqualContent(File expect, File result) throws AssertionFailedError, IOException { if (!result.exists()) { diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java index 3d5c5f546..daf6a9440 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java @@ -40,10 +40,6 @@ public class SignJarTest extends BuildFileTest { configureProject("src/etc/testcases/taskdefs/signjar.xml"); } - public void tearDown() { - executeTarget("clean"); - } - /** * check for being offline * @return true if the system property "offline" is "true" @@ -108,7 +104,7 @@ public class SignJarTest extends BuildFileTest { } /** - * @see https://issues.apache.org/bugzilla/show_bug.cgi?id=50081 + * @see bug 50081 */ public void testSignUnnormalizedJar() throws Exception { executeTarget("jar"); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/SyncTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/SyncTest.java index 62302d33b..331528086 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/SyncTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/SyncTest.java @@ -30,10 +30,6 @@ public class SyncTest extends BuildFileTest { configureProject("src/etc/testcases/taskdefs/sync.xml"); } - public void tearDown() { - executeTarget("cleanup"); - } - public void testSimpleCopy() { executeTarget("simplecopy"); String d = getProject().getProperty("dest") + "/a/b/c/d"; diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/WarTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/WarTest.java index fea98659a..d3554ca90 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/WarTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/WarTest.java @@ -38,16 +38,12 @@ public class WarTest extends BuildFileTest { configureProject(TEST_BUILD_FILE); } - public void tearDown() { - executeTarget("clean"); - } - /** * Test direct dependency removal */ public void testLibRefs() { executeTarget("testlibrefs"); - File f = getProject().resolveFile("working/WEB-INF/lib/war.xml"); + File f = new File(getOutputDir(), "WEB-INF/lib/war.xml"); assertTrue("File has been put into lib", f.exists()); } } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JspcTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JspcTest.java index 7e810b1dc..4954af7ef 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JspcTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JspcTest.java @@ -33,14 +33,6 @@ import org.apache.tools.ant.taskdefs.optional.jsp.compilers.JspCompilerAdapterFa * @since Ant 1.5 */ public class JspcTest extends BuildFileTest { - /** - * Description of the Field - */ - private File baseDir; - /** - * Description of the Field - */ - private File outDir; /** * Description of the Field @@ -63,16 +55,6 @@ public class JspcTest extends BuildFileTest { */ public void setUp() { configureProject(TASKDEFS_DIR + "jspc.xml"); - baseDir = new File(System.getProperty("root"), TASKDEFS_DIR); - outDir = new File(baseDir, "jsp/java"); - } - - - /** - * The teardown method for JUnit - */ - public void tearDown() { - executeTarget("cleanup"); } @@ -180,7 +162,7 @@ public class JspcTest extends BuildFileTest { * @return The OutputFile value */ protected File getOutputFile(String subpath) { - return new File(outDir, subpath); + return new File(getOutputDir(), subpath); } /** diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PropertyFileTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PropertyFileTest.java index 9996389f8..3e6c4b9b0 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PropertyFileTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PropertyFileTest.java @@ -43,7 +43,8 @@ public class PropertyFileTest extends BuildFileTest { * The JUnit setup method */ public void setUp() throws Exception { - destroyTempFiles(); + configureProject(projectFilePath); + executeTarget("setUp"); initTestPropFile(); initBuildPropFile(); configureProject(projectFilePath); @@ -51,13 +52,6 @@ public class PropertyFileTest extends BuildFileTest { } - /** - * The JUnit tearDown method - */ - public void tearDown() { - destroyTempFiles(); - } - public void testNonExistingFile() { PropertyFile props = new PropertyFile(); props.setProject( getProject() ); @@ -129,33 +123,10 @@ public class PropertyFileTest extends BuildFileTest { executeTarget("bugDemo2"); assertEquals("5", project.getProperty("foo")); } -/* - public void testDirect() throws Exception { - PropertyFile pf = new PropertyFile(); - pf.setProject(project); - pf.setFile(new File(System.getProperty("root"), testPropsFilePath)); - PropertyFile.Entry entry = pf.createEntry(); - - entry.setKey("date"); - entry.setValue("123"); - PropertyFile.Entry.Type type = new PropertyFile.Entry.Type(); - type.setValue("date"); - entry.setType(type); - - entry.setPattern("yyyy/MM/dd"); - - PropertyFile.Entry.Operation operation = new PropertyFile.Entry.Operation(); - operation.setValue("+"); - pf.execute(); - - Properties props = getTestProperties(); - assertEquals("yeehaw", props.getProperty("date")); - } -*/ private Properties getTestProperties() throws Exception { Properties testProps = new Properties(); - FileInputStream propsFile = new FileInputStream(new File(System.getProperty("root"), testPropsFilePath)); + FileInputStream propsFile = new FileInputStream(new File(getOutputDir(), testPropsFilePath)); testProps.load(propsFile); propsFile.close(); return testProps; @@ -169,7 +140,7 @@ public class PropertyFileTest extends BuildFileTest { testProps.put(EMAIL_KEY, EMAIL); testProps.put("existing.prop", "37"); - FileOutputStream fos = new FileOutputStream(new File(System.getProperty("root"), testPropsFilePath)); + FileOutputStream fos = new FileOutputStream(new File(getOutputDir(), testPropsFilePath)); testProps.store(fos, "defaults"); fos.close(); } @@ -185,26 +156,12 @@ public class PropertyFileTest extends BuildFileTest { buildProps.put(AGE_KEY, NEW_AGE); buildProps.put(DATE_KEY, NEW_DATE); - FileOutputStream fos = new FileOutputStream(new File(System.getProperty("root"), buildPropsFilePath)); + FileOutputStream fos = new FileOutputStream(new File(getOutputDir(), buildPropsFilePath)); buildProps.store(fos, null); fos.close(); } - private void destroyTempFiles() { - File tempFile = new File(System.getProperty("root"), testPropsFilePath); - tempFile.delete(); - tempFile = null; - - tempFile = new File(System.getProperty("root"), buildPropsFilePath); - tempFile.delete(); - tempFile = null; - - tempFile = new File(System.getProperty("root"), valueDoesNotGetOverwrittenPropsFilePath); - tempFile.delete(); - tempFile = null; - } - private static final String @@ -212,13 +169,13 @@ public class PropertyFileTest extends BuildFileTest { testPropertyFile = "propertyfile.test.properties", testPropertyFileKey = "test.propertyfile", - testPropsFilePath = "src/etc/testcases/taskdefs/optional/" + testPropertyFile, + testPropsFilePath = testPropertyFile, valueDoesNotGetOverwrittenPropertyFile = "overwrite.test.properties", valueDoesNotGetOverwrittenPropertyFileKey = "overwrite.test.propertyfile", - valueDoesNotGetOverwrittenPropsFilePath = "src/etc/testcases/taskdefs/optional/" + valueDoesNotGetOverwrittenPropertyFile, + valueDoesNotGetOverwrittenPropsFilePath = valueDoesNotGetOverwrittenPropertyFile, - buildPropsFilePath = "src/etc/testcases/taskdefs/optional/propertyfile.build.properties", + buildPropsFilePath = "propertyfile.build.properties", FNAME = "Bruce", NEW_FNAME = "Clark", diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java index fe9a25b15..e99f246ea 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java @@ -40,10 +40,6 @@ public class JUnitReportTest extends BuildFileTest { configureProject("src/etc/testcases/taskdefs/optional/junitreport.xml"); } - protected void tearDown() { - executeTarget("clean"); - } - /** * Verifies that no empty junit-noframes.html is generated when frames * output is selected via the default. @@ -51,15 +47,14 @@ public class JUnitReportTest extends BuildFileTest { */ public void testNoFileJUnitNoFrames() { executeTarget("reports1"); - if (new File(System.getProperty("root"), "src/etc/testcases/taskdefs/optional/junitreport/test/html/junit-noframes.html").exists()) + if (new File(getOutputDir(), "html/junit-noframes.html").exists()) { fail("No file junit-noframes.html expected"); } } public void assertIndexCreated() { - if (!new File(System.getProperty("root"), - "src/etc/testcases/taskdefs/optional/junitreport/test/html/index.html").exists()) { + if (!new File(getOutputDir(), "html/index.html").exists()) { fail("No file index file found"); } @@ -98,8 +93,7 @@ public class JUnitReportTest extends BuildFileTest { expectReportWithText("testStackTraceLineBreaks", null); FileReader r = null; try { - r = new FileReader(new File(System.getProperty("root"), - "src/etc/testcases/taskdefs/optional/junitreport/test/html/sampleproject/coins/0_CoinTest.html")); + r = new FileReader(new File(getOutputDir(), "html/sampleproject/coins/0_CoinTest.html")); String report = FileUtils.readFully(r); assertTrue("output must contain
:\n" + report, report.indexOf("junit.framework.AssertionFailedError: DOEG
") @@ -116,7 +110,7 @@ public class JUnitReportTest extends BuildFileTest { // Bugzilla Report 38477 public void testSpecialSignsInSrcPath() throws Exception { executeTarget("testSpecialSignsInSrcPath"); - File reportFile = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/optional/junitreport/test/html/index.html"); + File reportFile = new File(getOutputDir(), "html/index.html"); // tests one the file object assertTrue("No index.html present. Not generated?", reportFile.exists() ); assertTrue("Cant read the report file.", reportFile.canRead() ); @@ -129,7 +123,7 @@ public class JUnitReportTest extends BuildFileTest { public void testSpecialSignsInHtmlPath() throws Exception { executeTarget("testSpecialSignsInHtmlPath"); - File reportFile = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/optional/junitreport/test/html# $%\u00A7&-!report/index.html"); + File reportFile = new File(getOutputDir(), "html# $%\u00A7&-!report/index.html"); // tests one the file object assertTrue("No index.html present. Not generated?", reportFile.exists() ); assertTrue("Cant read the report file.", reportFile.canRead() ); @@ -143,7 +137,7 @@ public class JUnitReportTest extends BuildFileTest { //Bugzilla Report 39708 public void testWithStyleFromDir() throws Exception { executeTarget("testWithStyleFromDir"); - File reportFile = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/optional/junitreport/test/html/index.html"); + File reportFile = new File(getOutputDir(), "html/index.html"); // tests one the file object assertTrue("No index.html present. Not generated?", reportFile.exists() ); assertTrue("Cant read the report file.", reportFile.canRead() ); @@ -157,7 +151,7 @@ public class JUnitReportTest extends BuildFileTest { //Bugzilla Report 40021 public void testNoFrames() throws Exception { executeTarget("testNoFrames"); - File reportFile = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/optional/junitreport/test/html/junit-noframes.html"); + File reportFile = new File(getOutputDir(), "html/junit-noframes.html"); // tests one the file object assertTrue("No junit-noframes.html present. Not generated?", reportFile.exists() ); assertTrue("Cant read the report file.", reportFile.canRead() ); @@ -170,7 +164,7 @@ public class JUnitReportTest extends BuildFileTest { //Bugzilla Report 39708 public void testWithStyleFromDirAndXslImport() throws Exception { executeTarget("testWithStyleFromDirAndXslImport"); - File reportFile = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/optional/junitreport/test/html/index.html"); + File reportFile = new File(getOutputDir(), "html/index.html"); // tests one the file object assertTrue("No index.html present. Not generated?", reportFile.exists() ); assertTrue("Cant read the report file.", reportFile.canRead() ); @@ -183,7 +177,7 @@ public class JUnitReportTest extends BuildFileTest { public void testWithStyleFromClasspath() throws Exception { executeTarget("testWithStyleFromClasspath"); - File reportFile = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/optional/junitreport/test/html/index.html"); + File reportFile = new File(getOutputDir(), "html/index.html"); // tests one the file object assertTrue("No index.html present. Not generated?", reportFile.exists() ); assertTrue("Cant read the report file.", reportFile.canRead() ); @@ -196,7 +190,7 @@ public class JUnitReportTest extends BuildFileTest { public void testWithParams() throws Exception { expectLogContaining("testWithParams", "key1=value1,key2=value2"); - File reportFile = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/optional/junitreport/test/html/index.html"); + File reportFile = new File(getOutputDir(), "html/index.html"); // tests one the file object assertTrue("No index.html present. Not generated?", reportFile.exists() ); assertTrue("Cant read the report file.", reportFile.canRead() ); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java index 730ecf0c9..30f624a19 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java @@ -50,13 +50,6 @@ public class JUnitTaskTest extends BuildFileTest { configureProject("src/etc/testcases/taskdefs/optional/junit.xml"); } - /** - * The teardown method for JUnit. - */ - public void tearDown() { - executeTarget("cleanup"); - } - public void testCrash() { expectPropertySet("crash", "crashed"); } @@ -121,8 +114,8 @@ public class JUnitTaskTest extends BuildFileTest { } try { - File testDir = new File(getProjectDir(), "out"); - File collectorFile = new File(getProjectDir(), + File testDir = new File(getOutputDir(), "out"); + File collectorFile = new File(getOutputDir(), "out/FailedTests.java"); // ensure that there is a clean test environment @@ -249,7 +242,7 @@ public class JUnitTaskTest extends BuildFileTest { private void assertResultFileExists(String classNameFragment, String ext) { assertTrue("result for " + classNameFragment + "Test" + ext + " exists", - getProject().resolveFile("out/TEST-org.apache.tools.ant." + new File(getOutputDir(), "TEST-org.apache.tools.ant." + "taskdefs.optional.junit." + classNameFragment + "Test" + ext) .exists()); @@ -261,8 +254,8 @@ public class JUnitTaskTest extends BuildFileTest { } private void assertOutput() throws IOException { - FileReader inner = new FileReader(getProject() - .resolveFile("testlog.txt")); + FileReader inner = new FileReader(new File(getOutputDir(), + "testlog.txt")); BufferedReader reader = new BufferedReader(inner); try { String line = reader.readLine(); @@ -309,7 +302,7 @@ public class JUnitTaskTest extends BuildFileTest { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); - Document doc = dBuilder.parse(getProject().getResource("out/TEST-org.example.junit.JUnit4Skippable.xml").getInputStream()); + Document doc = dBuilder.parse(new File(getOutputDir(), "TEST-org.example.junit.JUnit4Skippable.xml")); assertEquals("Incorrect number of nodes created", 8, doc.getElementsByTagName("testcase").getLength()); @@ -335,26 +328,26 @@ public class JUnitTaskTest extends BuildFileTest { public void testNonTestsSkipped() throws Exception { executeTarget("testNonTests"); - assertFalse("Test result should not exist as test was skipped - TEST-org.example.junit.NonTestMissed.xml", getProject().getResource("out/TEST-org.example.junit.NonTestMissed.xml").isExists()); - assertFalse("Test result should not exist as test was skipped - TEST-org.example.junit.JUnit3NonTestMissed.xml", getProject().getResource("out/TEST-org.example.junit.JUnit3TestMissed.xml").isExists()); - assertFalse("Test result should not exist as test was skipped - TEST-org.example.junit.AbstractTestMissed.xml", getProject().getResource("out/TEST-org.example.junit.AbstractTestMissed.xml").isExists()); - assertFalse("Test result should not exist as test was skipped - TEST-org.example.junit.AbstractJUnit3TestMissed.xml", getProject().getResource("out/TEST-org.example.junit.AbstractJUnit3TestMissed.xml").isExists()); - assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.AbstractTestNotMissed.xml", getProject().getResource("out/TEST-org.example.junit.AbstractTestNotMissed.xml").isExists()); - assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.AbstractJUnit3TestNotMissed.xml", getProject().getResource("out/TEST-org.example.junit.AbstractJUnit3TestNotMissed.xml").isExists()); - assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.TestNotMissed.xml", getProject().getResource("out/TEST-org.example.junit.TestNotMissed.xml").isExists()); - assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.JUnit3TestNotMissed.xml", getProject().getResource("out/TEST-org.example.junit.JUnit3TestNotMissed.xml").isExists()); - assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.TestWithSuiteNotMissed.xml", getProject().getResource("out/TEST-org.example.junit.TestWithSuiteNotMissed.xml").isExists()); + assertFalse("Test result should not exist as test was skipped - TEST-org.example.junit.NonTestMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.NonTestMissed.xml").exists()); + assertFalse("Test result should not exist as test was skipped - TEST-org.example.junit.JUnit3NonTestMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.JUnit3TestMissed.xml").exists()); + assertFalse("Test result should not exist as test was skipped - TEST-org.example.junit.AbstractTestMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.AbstractTestMissed.xml").exists()); + assertFalse("Test result should not exist as test was skipped - TEST-org.example.junit.AbstractJUnit3TestMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.AbstractJUnit3TestMissed.xml").exists()); + assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.AbstractTestNotMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.AbstractTestNotMissed.xml").exists()); + assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.AbstractJUnit3TestNotMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.AbstractJUnit3TestNotMissed.xml").exists()); + assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.TestNotMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.TestNotMissed.xml").exists()); + assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.JUnit3TestNotMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.JUnit3TestNotMissed.xml").exists()); + assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.TestWithSuiteNotMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.TestWithSuiteNotMissed.xml").exists()); executeTarget("testNonTestsRun"); - assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.NonTestMissed.xml", getProject().getResource("out/TEST-org.example.junit.NonTestMissed.xml").isExists()); - assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.JUnit3NonTestMissed.xml", getProject().getResource("out/TEST-org.example.junit.JUnit3NonTestMissed.xml").isExists()); - assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.TestNotMissed.xml", getProject().getResource("out/TEST-org.example.junit.TestNotMissed.xml").isExists()); - assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.JUnit3TestNotMissed.xml", getProject().getResource("out/TEST-org.example.junit.JUnit3TestNotMissed.xml").isExists()); - assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.AbstractTestMissed.xml", getProject().getResource("out/TEST-org.example.junit.AbstractTestMissed.xml").isExists()); - assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.AbstractTestNotMissed.xml", getProject().getResource("out/TEST-org.example.junit.AbstractTestNotMissed.xml").isExists()); - assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.AbstractJUnit3TestMissed.xml", getProject().getResource("out/TEST-org.example.junit.AbstractJUnit3TestMissed.xml").isExists()); - assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.JUnit3NonTestMissed.xml", getProject().getResource("out/TEST-org.example.junit.JUnit3NonTestMissed.xml").isExists()); - assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.TestWithSuiteNotMissed.xml", getProject().getResource("out/TEST-org.example.junit.TestWithSuiteNotMissed.xml").isExists()); + assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.NonTestMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.NonTestMissed.xml").exists()); + assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.JUnit3NonTestMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.JUnit3NonTestMissed.xml").exists()); + assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.TestNotMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.TestNotMissed.xml").exists()); + assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.JUnit3TestNotMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.JUnit3TestNotMissed.xml").exists()); + assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.AbstractTestMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.AbstractTestMissed.xml").exists()); + assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.AbstractTestNotMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.AbstractTestNotMissed.xml").exists()); + assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.AbstractJUnit3TestMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.AbstractJUnit3TestMissed.xml").exists()); + assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.JUnit3NonTestMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.JUnit3NonTestMissed.xml").exists()); + assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.TestWithSuiteNotMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.TestWithSuiteNotMissed.xml").exists()); } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestListenerTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestListenerTest.java index 31328763e..faeb7368a 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestListenerTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestListenerTest.java @@ -37,13 +37,6 @@ public class JUnitTestListenerTest extends BuildFileTest { configureProject("src/etc/testcases/taskdefs/optional/junit.xml"); } - /** - * The teardown method for JUnit. - */ - public void tearDown() { - executeTarget("cleanup"); - } - public void testFullLogOutput() { getProject().setProperty("enableEvents", "true"); executeTarget(PASS_TEST_TARGET);