diff --git a/WHATSNEW b/WHATSNEW index 96d52d7d2..0375b1666 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -17,6 +17,9 @@ Other changes: * Added a new condition that test for the existence of a property to the condition task. +* Ant's testcases require JUnit 3.7 or above as they now use the new + assertTrue method instead of assert. + Fixed bugs: ----------- diff --git a/src/testcases/org/apache/tools/ant/DirectoryScannerTest.java b/src/testcases/org/apache/tools/ant/DirectoryScannerTest.java index 7c5468582..790e4b670 100644 --- a/src/testcases/org/apache/tools/ant/DirectoryScannerTest.java +++ b/src/testcases/org/apache/tools/ant/DirectoryScannerTest.java @@ -87,8 +87,8 @@ public class DirectoryScannerTest extends TestCase { haveTaskdefsPackage = true; } } - assert("(1) zip package included", haveZipPackage); - assert("(1) taskdefs package not included", !haveTaskdefsPackage); + assertTrue("(1) zip package included", haveZipPackage); + assertTrue("(1) taskdefs package not included", !haveTaskdefsPackage); ds = new DirectoryScanner(); ds.setBasedir(dir); @@ -103,8 +103,8 @@ public class DirectoryScannerTest extends TestCase { haveTaskdefsPackage = true; } } - assert("(2) zip package included", haveZipPackage); - assert("(2) taskdefs package included", haveTaskdefsPackage); + assertTrue("(2) zip package included", haveZipPackage); + assertTrue("(2) taskdefs package included", haveTaskdefsPackage); } diff --git a/src/testcases/org/apache/tools/ant/IntrospectionHelperTest.java b/src/testcases/org/apache/tools/ant/IntrospectionHelperTest.java index f50e9fb63..7d221a013 100644 --- a/src/testcases/org/apache/tools/ant/IntrospectionHelperTest.java +++ b/src/testcases/org/apache/tools/ant/IntrospectionHelperTest.java @@ -94,15 +94,15 @@ public class IntrospectionHelperTest extends TestCase { ih.addText(p, this, "test2"); fail("test2 shouldn\'t be equal to test"); } catch (BuildException be) { - assert(be.getException() instanceof AssertionFailedError); + assertTrue(be.getException() instanceof AssertionFailedError); } } public void testSupportsCharacters() { IntrospectionHelper ih = IntrospectionHelper.getHelper(java.lang.String.class); - assert("String doesn\'t support addText", !ih.supportsCharacters()); + assertTrue("String doesn\'t support addText", !ih.supportsCharacters()); ih = IntrospectionHelper.getHelper(getClass()); - assert("IntrospectionHelperTest supports addText", + assertTrue("IntrospectionHelperTest supports addText", ih.supportsCharacters()); } @@ -177,14 +177,14 @@ public class IntrospectionHelperTest extends TestCase { ih.createElement(p, this, "fourteen"); fail("fourteen throws NullPointerException"); } catch (BuildException be) { - assert(be.getException() instanceof NullPointerException); + assertTrue(be.getException() instanceof NullPointerException); } try { ih.createElement(p, this, "fourteen"); fail("fifteen throws NullPointerException"); } catch (BuildException be) { - assert(be.getException() instanceof NullPointerException); + assertTrue(be.getException() instanceof NullPointerException); } } @@ -204,7 +204,7 @@ public class IntrospectionHelperTest extends TestCase { assertEquals("Return type of "+name, expect, ih.getElementType(name)); h.remove(name); } - assert("Found all", h.isEmpty()); + assertTrue("Found all", h.isEmpty()); } public Object createTwo(String s) { @@ -288,76 +288,76 @@ public class IntrospectionHelperTest extends TestCase { ih.setAttribute(p, this, "seven", "3"); fail("2 shouldn't be equals to three"); } catch (BuildException be) { - assert(be.getException() instanceof AssertionFailedError); + assertTrue(be.getException() instanceof AssertionFailedError); } ih.setAttribute(p, this, "eight", "2"); try { ih.setAttribute(p, this, "eight", "3"); fail("2 shouldn't be equals to three - as int"); } catch (BuildException be) { - assert(be.getException() instanceof AssertionFailedError); + assertTrue(be.getException() instanceof AssertionFailedError); } ih.setAttribute(p, this, "nine", "2"); try { ih.setAttribute(p, this, "nine", "3"); fail("2 shouldn't be equals to three - as Integer"); } catch (BuildException be) { - assert(be.getException() instanceof AssertionFailedError); + assertTrue(be.getException() instanceof AssertionFailedError); } ih.setAttribute(p, this, "ten", "2"); try { ih.setAttribute(p, this, "ten", "3"); fail("/tmp/2 shouldn't be equals to /tmp/3"); } catch (BuildException be) { - assert(be.getException() instanceof AssertionFailedError); + assertTrue(be.getException() instanceof AssertionFailedError); } ih.setAttribute(p, this, "eleven", "2"); try { ih.setAttribute(p, this, "eleven", "on"); fail("on shouldn't be false"); } catch (BuildException be) { - assert(be.getException() instanceof AssertionFailedError); + assertTrue(be.getException() instanceof AssertionFailedError); } ih.setAttribute(p, this, "twelve", "2"); try { ih.setAttribute(p, this, "twelve", "on"); fail("on shouldn't be false"); } catch (BuildException be) { - assert(be.getException() instanceof AssertionFailedError); + assertTrue(be.getException() instanceof AssertionFailedError); } ih.setAttribute(p, this, "thirteen", "org.apache.tools.ant.Project"); try { ih.setAttribute(p, this, "thirteen", "org.apache.tools.ant.ProjectHelper"); fail("org.apache.tools.ant.Project shouldn't be equal to org.apache.tools.ant.ProjectHelper"); } catch (BuildException be) { - assert(be.getException() instanceof AssertionFailedError); + assertTrue(be.getException() instanceof AssertionFailedError); } try { ih.setAttribute(p, this, "thirteen", "org.apache.tools.ant.Project2"); fail("org.apache.tools.ant.Project2 doesn't exist"); } catch (BuildException be) { - assert(be.getException() instanceof ClassNotFoundException); + assertTrue(be.getException() instanceof ClassNotFoundException); } ih.setAttribute(p, this, "fourteen", "2"); try { ih.setAttribute(p, this, "fourteen", "on"); fail("2 shouldn't be equals to three - as StringBuffer"); } catch (BuildException be) { - assert(be.getException() instanceof AssertionFailedError); + assertTrue(be.getException() instanceof AssertionFailedError); } ih.setAttribute(p, this, "fifteen", "abcd"); try { ih.setAttribute(p, this, "fifteen", "on"); fail("o shouldn't be equal to a"); } catch (BuildException be) { - assert(be.getException() instanceof AssertionFailedError); + assertTrue(be.getException() instanceof AssertionFailedError); } ih.setAttribute(p, this, "sixteen", "abcd"); try { ih.setAttribute(p, this, "sixteen", "on"); fail("o shouldn't be equal to a"); } catch (BuildException be) { - assert(be.getException() instanceof AssertionFailedError); + assertTrue(be.getException() instanceof AssertionFailedError); } } @@ -394,7 +394,7 @@ public class IntrospectionHelperTest extends TestCase { h.remove(name); } h.remove("name"); - assert("Found all", h.isEmpty()); + assertTrue("Found all", h.isEmpty()); } public int setTwo(String s) { @@ -432,11 +432,11 @@ public class IntrospectionHelperTest extends TestCase { } public void setEleven(boolean b) { - assert(!b); + assertTrue(!b); } public void setTwelve(Boolean b) { - assert(!b.booleanValue()); + assertTrue(!b.booleanValue()); } public void setThirteen(Class c) { diff --git a/src/testcases/org/apache/tools/ant/ProjectTest.java b/src/testcases/org/apache/tools/ant/ProjectTest.java index 83c64ce56..d570cfb80 100644 --- a/src/testcases/org/apache/tools/ant/ProjectTest.java +++ b/src/testcases/org/apache/tools/ant/ProjectTest.java @@ -87,10 +87,10 @@ public class ProjectTest extends TestCase { p.createDataType("dummy")); Object o = p.createDataType("fileset"); assertNotNull("fileset is a known type", o); - assert("fileset creates FileSet", o instanceof FileSet); - assert("PatternSet", + assertTrue("fileset creates FileSet", o instanceof FileSet); + assertTrue("PatternSet", p.createDataType("patternset") instanceof PatternSet); - assert("Path", p.createDataType("path") instanceof Path); + assertTrue("Path", p.createDataType("path") instanceof Path); } /** diff --git a/src/testcases/org/apache/tools/ant/taskdefs/AvailableTest.java b/src/testcases/org/apache/tools/ant/taskdefs/AvailableTest.java index 6750f6005..639964b42 100644 --- a/src/testcases/org/apache/tools/ant/taskdefs/AvailableTest.java +++ b/src/testcases/org/apache/tools/ant/taskdefs/AvailableTest.java @@ -85,7 +85,7 @@ public class AvailableTest extends TaskdefsTest { // file doesn't exist -> property 'test' == null public void test4() { executeTarget("test4"); - assert(project.getProperty("test") == null); + assertTrue(project.getProperty("test") == null); } // file does exist -> property 'test' == 'true' @@ -97,7 +97,7 @@ public class AvailableTest extends TaskdefsTest { // resource doesn't exist -> property 'test' == null public void test6() { executeTarget("test6"); - assert(project.getProperty("test") == null); + assertTrue(project.getProperty("test") == null); } // resource does exist -> property 'test' == 'true' @@ -109,7 +109,7 @@ public class AvailableTest extends TaskdefsTest { // class doesn't exist -> property 'test' == null public void test8() { executeTarget("test8"); - assert(project.getProperty("test") == null); + assertTrue(project.getProperty("test") == null); } // class does exist -> property 'test' == 'true' diff --git a/src/testcases/org/apache/tools/ant/taskdefs/CVSPassTest.java b/src/testcases/org/apache/tools/ant/taskdefs/CVSPassTest.java index cea6b7e5a..08c5ccd4c 100644 --- a/src/testcases/org/apache/tools/ant/taskdefs/CVSPassTest.java +++ b/src/testcases/org/apache/tools/ant/taskdefs/CVSPassTest.java @@ -106,7 +106,7 @@ public class CVSPassTest extends TaskdefsTest { executeTarget("test3"); File f = new File(getProjectDir(), "testpassfile.tmp"); - assert( "Passfile "+f+" not created", f.exists()); + assertTrue( "Passfile "+f+" not created", f.exists()); assertEquals(JAKARTA_URL+EOL, readFile(f)); @@ -116,7 +116,7 @@ public class CVSPassTest extends TaskdefsTest { executeTarget("test4"); File f = new File(getProjectDir(), "testpassfile.tmp"); - assert( "Passfile "+f+" not created", f.exists()); + assertTrue( "Passfile "+f+" not created", f.exists()); assertEquals( JAKARTA_URL+ EOL+ @@ -128,7 +128,7 @@ public class CVSPassTest extends TaskdefsTest { executeTarget("test5"); File f = new File(getProjectDir(), "testpassfile.tmp"); - assert( "Passfile "+f+" not created", f.exists()); + assertTrue( "Passfile "+f+" not created", f.exists()); assertEquals( JAKARTA_URL+ EOL+ diff --git a/src/testcases/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java b/src/testcases/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java index 4c39598af..89dd6a6aa 100644 --- a/src/testcases/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java +++ b/src/testcases/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java @@ -138,7 +138,7 @@ public class ExecuteWatchdogTest extends TestCase { Process process = getProcess(TIME_OUT/2); watchdog.start(process); int retCode = waitForEnd(process); - assert("process should not have been killed", !watchdog.killedProcess()); + assertTrue("process should not have been killed", !watchdog.killedProcess()); assertEquals(0, retCode); } @@ -149,10 +149,10 @@ public class ExecuteWatchdogTest extends TestCase { watchdog.start(process); int retCode = process.waitFor(); long elapsed = System.currentTimeMillis() - now; - assert("process should have been killed", watchdog.killedProcess()); - // assert("return code is invalid: " + retCode, retCode!=0); - assert("elapse time is less than timeout value", elapsed > TIME_OUT); - assert("elapse time is greater than run value", elapsed < TIME_OUT*2); + assertTrue("process should have been killed", watchdog.killedProcess()); + // assertTrue("return code is invalid: " + retCode, retCode!=0); + assertTrue("elapse time is less than timeout value", elapsed > TIME_OUT); + assertTrue("elapse time is greater than run value", elapsed < TIME_OUT*2); } // test a process that runs and failed @@ -160,8 +160,8 @@ public class ExecuteWatchdogTest extends TestCase { Process process = getProcess(-1); // process should abort watchdog.start(process); int retCode = process.waitFor(); - assert("process should not have been killed", !watchdog.killedProcess()); - assert("return code is invalid: " + retCode, retCode!=0); + assertTrue("process should not have been killed", !watchdog.killedProcess()); + assertTrue("return code is invalid: " + retCode, retCode!=0); } public void testManualStop() throws Exception { @@ -192,7 +192,7 @@ public class ExecuteWatchdogTest extends TestCase { // process should be dead and well finished assertEquals(0, process.exitValue()); - assert("process should not have been killed", !watchdog.killedProcess()); + assertTrue("process should not have been killed", !watchdog.killedProcess()); } public static class TimeProcess { diff --git a/src/testcases/org/apache/tools/ant/taskdefs/JarTest.java b/src/testcases/org/apache/tools/ant/taskdefs/JarTest.java index 239223522..253e3f681 100644 --- a/src/testcases/org/apache/tools/ant/taskdefs/JarTest.java +++ b/src/testcases/org/apache/tools/ant/taskdefs/JarTest.java @@ -88,7 +88,7 @@ public class JarTest extends TaskdefsTest { public void test4() { executeTarget("test4"); File jarFile = new File(getProjectDir(), tempJar); - assert(jarFile.exists()); + assertTrue(jarFile.exists()); jarModifiedDate = jarFile.lastModified(); } diff --git a/src/testcases/org/apache/tools/ant/taskdefs/SleepTest.java b/src/testcases/org/apache/tools/ant/taskdefs/SleepTest.java index 02116ad65..cd1679b02 100644 --- a/src/testcases/org/apache/tools/ant/taskdefs/SleepTest.java +++ b/src/testcases/org/apache/tools/ant/taskdefs/SleepTest.java @@ -78,7 +78,7 @@ public class SleepTest extends TaskdefsTest { executeTarget("test1"); timer.stop(); if(TRACE) System.out.println(" test1 elapsed time="+timer.time()); - assert(timer.time()>=0); + assertTrue(timer.time()>=0); } public void test2() { @@ -86,7 +86,7 @@ public class SleepTest extends TaskdefsTest { executeTarget("test2"); timer.stop(); if(TRACE) System.out.println(" test2 elapsed time="+timer.time()); - assert(timer.time()>=0); + assertTrue(timer.time()>=0); } public void test3() { @@ -94,7 +94,7 @@ public class SleepTest extends TaskdefsTest { executeTarget("test3"); timer.stop(); if(TRACE) System.out.println(" test3 elapsed time="+timer.time()); - assert(timer.time()>=(2000-ERROR_RANGE)); + assertTrue(timer.time()>=(2000-ERROR_RANGE)); } public void test4() { @@ -102,7 +102,7 @@ public class SleepTest extends TaskdefsTest { executeTarget("test3"); timer.stop(); if(TRACE) System.out.println(" test4 elapsed time="+timer.time()); - assert(timer.time()>=(2000-ERROR_RANGE) && timer.time()<60000); + assertTrue(timer.time()>=(2000-ERROR_RANGE) && timer.time()<60000); } public void test5() { @@ -115,7 +115,7 @@ public class SleepTest extends TaskdefsTest { executeTarget("test6"); timer.stop(); if(TRACE) System.out.println(" test6 elapsed time="+timer.time()); - assert(timer.time()<2000); + assertTrue(timer.time()<2000); } diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java index d98beb37d..47360a290 100644 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java +++ b/src/testcases/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java @@ -83,7 +83,7 @@ public class ANTLRTest extends TaskdefsTest { executeTarget("test3"); File outputDirectory = new File(TASKDEFS_DIR + "antlr.tmp"); String[] calcFiles = outputDirectory.list(new CalcFileFilter()); - assert(5 == calcFiles.length); + assertEquals(5, calcFiles.length); } public void test4() { diff --git a/src/testcases/org/apache/tools/ant/types/CommandlineJavaTest.java b/src/testcases/org/apache/tools/ant/types/CommandlineJavaTest.java index 76a600709..de84532cb 100644 --- a/src/testcases/org/apache/tools/ant/types/CommandlineJavaTest.java +++ b/src/testcases/org/apache/tools/ant/types/CommandlineJavaTest.java @@ -93,7 +93,7 @@ public class CommandlineJavaTest extends TestCase { * here without using the same logic as applied in the class * itself. * - * assert("no classpath", "java", s[0]); + * assertTrue("no classpath", "java", s[0]); */ assertEquals("no classpath", "-Djava.compiler=NONE", s[1]); assertEquals("no classpath", "junit.textui.TestRunner", s[2]); @@ -112,9 +112,9 @@ public class CommandlineJavaTest extends TestCase { // assertEquals("with classpath", "java", s[0]); assertEquals("with classpath", "-Djava.compiler=NONE", s[1]); assertEquals("with classpath", "-classpath", s[2]); - assert("junit.jar contained", + assertTrue("junit.jar contained", s[3].indexOf("junit.jar"+java.io.File.pathSeparator) >= 0); - assert("ant.jar contained", s[3].endsWith("ant.jar")); + assertTrue("ant.jar contained", s[3].endsWith("ant.jar")); assertEquals("with classpath", "junit.textui.TestRunner", s[4]); assertEquals("with classpath", "org.apache.tools.ant.CommandlineJavaTest", s[5]); diff --git a/src/testcases/org/apache/tools/ant/types/EnumeratedAttributeTest.java b/src/testcases/org/apache/tools/ant/types/EnumeratedAttributeTest.java index ed54f10ba..2e7532b0b 100644 --- a/src/testcases/org/apache/tools/ant/types/EnumeratedAttributeTest.java +++ b/src/testcases/org/apache/tools/ant/types/EnumeratedAttributeTest.java @@ -76,14 +76,14 @@ public class EnumeratedAttributeTest extends TestCase { public void testContains() { EnumeratedAttribute t1 = new TestNormal(); for (int i=0; i