| @@ -26,7 +26,8 @@ import org.junit.Rule; | |||||
| import org.junit.Test; | import org.junit.Test; | ||||
| import static org.junit.Assert.assertEquals; | import static org.junit.Assert.assertEquals; | ||||
| import static org.junit.Assert.assertFalse; | |||||
| import static org.junit.Assert.assertNotEquals; | |||||
| import static org.junit.Assert.assertNotSame; | |||||
| import static org.junit.Assert.assertTrue; | import static org.junit.Assert.assertTrue; | ||||
| public class LocationTest { | public class LocationTest { | ||||
| @@ -43,8 +44,8 @@ public class LocationTest { | |||||
| public void testPlainTask() { | public void testPlainTask() { | ||||
| buildRule.executeTarget("testPlainTask"); | buildRule.executeTarget("testPlainTask"); | ||||
| Echo e = buildRule.getProject().getReference("echo"); | Echo e = buildRule.getProject().getReference("echo"); | ||||
| assertFalse(e.getLocation() == Location.UNKNOWN_LOCATION); | |||||
| assertFalse(e.getLocation().getLineNumber() == 0); | |||||
| assertNotSame(e.getLocation(), Location.UNKNOWN_LOCATION); | |||||
| assertNotEquals(0, e.getLocation().getLineNumber()); | |||||
| } | } | ||||
| @Test | @Test | ||||
| @@ -52,7 +53,7 @@ public class LocationTest { | |||||
| buildRule.executeTarget("testStandaloneType"); | buildRule.executeTarget("testStandaloneType"); | ||||
| Echo e = buildRule.getProject().getReference("echo2"); | Echo e = buildRule.getProject().getReference("echo2"); | ||||
| FileSet f = buildRule.getProject().getReference("fs"); | FileSet f = buildRule.getProject().getReference("fs"); | ||||
| assertFalse(f.getLocation() == Location.UNKNOWN_LOCATION); | |||||
| assertNotSame(f.getLocation(), Location.UNKNOWN_LOCATION); | |||||
| assertEquals(e.getLocation().getLineNumber() + 1, | assertEquals(e.getLocation().getLineNumber() + 1, | ||||
| f.getLocation().getLineNumber()); | f.getLocation().getLineNumber()); | ||||
| } | } | ||||
| @@ -62,8 +63,8 @@ public class LocationTest { | |||||
| buildRule.executeTarget("testConditionTask"); | buildRule.executeTarget("testConditionTask"); | ||||
| TaskAdapter ta = buildRule.getProject().getReference("cond"); | TaskAdapter ta = buildRule.getProject().getReference("cond"); | ||||
| ConditionTask c = (ConditionTask) ta.getProxy(); | ConditionTask c = (ConditionTask) ta.getProxy(); | ||||
| assertFalse(c.getLocation() == Location.UNKNOWN_LOCATION); | |||||
| assertFalse(c.getLocation().getLineNumber() == 0); | |||||
| assertNotSame(c.getLocation(), Location.UNKNOWN_LOCATION); | |||||
| assertNotEquals(0, c.getLocation().getLineNumber()); | |||||
| } | } | ||||
| @Test | @Test | ||||
| @@ -18,12 +18,10 @@ | |||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import org.apache.tools.ant.AntAssert; | |||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| import org.apache.tools.ant.BuildFileRule; | import org.apache.tools.ant.BuildFileRule; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.junit.After; | import org.junit.After; | ||||
| import org.junit.Assert; | |||||
| import org.junit.Before; | import org.junit.Before; | ||||
| import org.junit.Rule; | import org.junit.Rule; | ||||
| import org.junit.Test; | import org.junit.Test; | ||||
| @@ -31,6 +29,9 @@ import org.junit.Test; | |||||
| import java.io.PrintWriter; | import java.io.PrintWriter; | ||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| import static org.apache.tools.ant.AntAssert.assertContains; | |||||
| import static org.junit.Assert.assertEquals; | |||||
| import static org.junit.Assert.assertTrue; | |||||
| import static org.junit.Assert.fail; | import static org.junit.Assert.fail; | ||||
| /** | /** | ||||
| @@ -68,7 +69,7 @@ public class AntStructureTest { | |||||
| // the test has likely been loaded via a different classloader | // the test has likely been loaded via a different classloader | ||||
| // than this class. Therefore we make the printer assert its | // than this class. Therefore we make the printer assert its | ||||
| // state and only check for the tail invocation. | // state and only check for the tail invocation. | ||||
| AntAssert.assertContains(MyPrinter.TAIL_CALLED, buildRule.getLog()); | |||||
| assertContains(MyPrinter.TAIL_CALLED, buildRule.getLog()); | |||||
| } | } | ||||
| public static class MyPrinter implements AntStructure.StructurePrinter { | public static class MyPrinter implements AntStructure.StructurePrinter { | ||||
| @@ -81,32 +82,32 @@ public class AntStructureTest { | |||||
| public void printHead(PrintWriter out, Project p, Hashtable tasks, | public void printHead(PrintWriter out, Project p, Hashtable tasks, | ||||
| Hashtable types) { | Hashtable types) { | ||||
| Assert.assertTrue(!headCalled); | |||||
| Assert.assertTrue(!targetCalled); | |||||
| Assert.assertTrue(!tailCalled); | |||||
| Assert.assertEquals(0, elementCalled); | |||||
| assertTrue(!headCalled); | |||||
| assertTrue(!targetCalled); | |||||
| assertTrue(!tailCalled); | |||||
| assertEquals(0, elementCalled); | |||||
| headCalled = true; | headCalled = true; | ||||
| } | } | ||||
| public void printTargetDecl(PrintWriter out) { | public void printTargetDecl(PrintWriter out) { | ||||
| Assert.assertTrue(headCalled); | |||||
| Assert.assertTrue(!targetCalled); | |||||
| Assert.assertTrue(!tailCalled); | |||||
| Assert.assertEquals(0, elementCalled); | |||||
| assertTrue(headCalled); | |||||
| assertTrue(!targetCalled); | |||||
| assertTrue(!tailCalled); | |||||
| assertEquals(0, elementCalled); | |||||
| targetCalled = true; | targetCalled = true; | ||||
| } | } | ||||
| public void printElementDecl(PrintWriter out, Project p, String name, | public void printElementDecl(PrintWriter out, Project p, String name, | ||||
| Class element) { | Class element) { | ||||
| Assert.assertTrue(headCalled); | |||||
| Assert.assertTrue(targetCalled); | |||||
| Assert.assertTrue(!tailCalled); | |||||
| assertTrue(headCalled); | |||||
| assertTrue(targetCalled); | |||||
| assertTrue(!tailCalled); | |||||
| elementCalled++; | elementCalled++; | ||||
| this.p = p; | this.p = p; | ||||
| } | } | ||||
| public void printTail(PrintWriter out) { | public void printTail(PrintWriter out) { | ||||
| Assert.assertTrue(headCalled); | |||||
| Assert.assertTrue(targetCalled); | |||||
| Assert.assertTrue(!tailCalled); | |||||
| Assert.assertTrue(elementCalled > 0); | |||||
| assertTrue(headCalled); | |||||
| assertTrue(targetCalled); | |||||
| assertTrue(!tailCalled); | |||||
| assertTrue(elementCalled > 0); | |||||
| tailCalled = true; | tailCalled = true; | ||||
| p.log(TAIL_CALLED); | p.log(TAIL_CALLED); | ||||
| } | } | ||||
| @@ -26,7 +26,6 @@ import org.junit.Test; | |||||
| import static org.junit.Assert.assertEquals; | import static org.junit.Assert.assertEquals; | ||||
| import static org.junit.Assert.assertNull; | import static org.junit.Assert.assertNull; | ||||
| import static org.junit.Assert.assertTrue; | |||||
| import static org.junit.Assert.fail; | import static org.junit.Assert.fail; | ||||
| /** | /** | ||||
| @@ -81,7 +80,7 @@ public class AvailableTest { | |||||
| @Test | @Test | ||||
| public void test4() { | public void test4() { | ||||
| buildRule.executeTarget("test4"); | buildRule.executeTarget("test4"); | ||||
| assertTrue(buildRule.getProject().getProperty("test") == null); | |||||
| assertNull(buildRule.getProject().getProperty("test")); | |||||
| } | } | ||||
| // file does exist -> property 'test' == 'true' | // file does exist -> property 'test' == 'true' | ||||
| @@ -94,7 +93,7 @@ public class AvailableTest { | |||||
| @Test | @Test | ||||
| public void test6() { | public void test6() { | ||||
| buildRule.executeTarget("test6"); | buildRule.executeTarget("test6"); | ||||
| assertTrue(buildRule.getProject().getProperty("test") == null); | |||||
| assertNull(buildRule.getProject().getProperty("test")); | |||||
| } | } | ||||
| // resource does exist -> property 'test' == 'true' | // resource does exist -> property 'test' == 'true' | ||||
| @@ -108,7 +107,7 @@ public class AvailableTest { | |||||
| @Test | @Test | ||||
| public void test8() { | public void test8() { | ||||
| buildRule.executeTarget("test8"); | buildRule.executeTarget("test8"); | ||||
| assertTrue(buildRule.getProject().getProperty("test") == null); | |||||
| assertNull(buildRule.getProject().getProperty("test")); | |||||
| } | } | ||||
| // class does exist -> property 'test' == 'true' | // class does exist -> property 'test' == 'true' | ||||
| @@ -23,8 +23,6 @@ import org.apache.tools.ant.BuildFileRule; | |||||
| import org.apache.tools.ant.FileUtilities; | import org.apache.tools.ant.FileUtilities; | ||||
| import org.apache.tools.ant.taskdefs.condition.Os; | import org.apache.tools.ant.taskdefs.condition.Os; | ||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| import org.junit.Assert; | |||||
| import org.junit.Assume; | |||||
| import org.junit.Before; | import org.junit.Before; | ||||
| import org.junit.Ignore; | import org.junit.Ignore; | ||||
| import org.junit.Rule; | import org.junit.Rule; | ||||
| @@ -37,8 +35,10 @@ import java.io.IOException; | |||||
| import static org.apache.tools.ant.AntAssert.assertContains; | import static org.apache.tools.ant.AntAssert.assertContains; | ||||
| import static org.junit.Assert.assertEquals; | import static org.junit.Assert.assertEquals; | ||||
| import static org.junit.Assert.assertNotEquals; | |||||
| import static org.junit.Assert.assertTrue; | import static org.junit.Assert.assertTrue; | ||||
| import static org.junit.Assert.fail; | import static org.junit.Assert.fail; | ||||
| import static org.junit.Assume.assumeTrue; | |||||
| /** | /** | ||||
| * Tests FileSet using the Copy task. | * Tests FileSet using the Copy task. | ||||
| @@ -78,7 +78,7 @@ public class CopyTest { | |||||
| public void test3() { | public void test3() { | ||||
| buildRule.executeTarget("test3"); | buildRule.executeTarget("test3"); | ||||
| File file3 = new File(buildRule.getProject().getProperty("output"), "copytest3.tmp"); | File file3 = new File(buildRule.getProject().getProperty("output"), "copytest3.tmp"); | ||||
| //rollback file timestamp instead of delaying test | |||||
| // rollback file timestamp instead of delaying test | |||||
| FileUtilities.rollbackTimestamps(file3, 3); | FileUtilities.rollbackTimestamps(file3, 3); | ||||
| buildRule.executeTarget("test3Part2"); | buildRule.executeTarget("test3Part2"); | ||||
| assertTrue(file3.exists()); | assertTrue(file3.exists()); | ||||
| @@ -90,19 +90,14 @@ public class CopyTest { | |||||
| File file3c = new File(buildRule.getProject().getProperty("output"), "copytest3c.tmp"); | File file3c = new File(buildRule.getProject().getProperty("output"), "copytest3c.tmp"); | ||||
| assertTrue(file3c.exists()); | assertTrue(file3c.exists()); | ||||
| //file length checks rely on touch generating a zero byte file | |||||
| if (file3.length()==0) { | |||||
| fail("could not overwrite an existing, older file"); | |||||
| } | |||||
| if (file3c.length()!=0) { | |||||
| fail("could not force overwrite an existing, newer file"); | |||||
| } | |||||
| if (file3b.length()==0) { | |||||
| fail("unexpectedly overwrote an existing, newer file"); | |||||
| } | |||||
| // file length checks rely on touch generating a zero byte file | |||||
| assertNotEquals("could not overwrite an existing, older file", 0, file3.length()); | |||||
| assertEquals("could not force overwrite an existing, newer file", 0, file3c.length()); | |||||
| assertNotEquals("unexpectedly overwrote an existing, newer file", 0, file3b.length()); | |||||
| //file time checks for java1.2+ | |||||
| assertTrue(file3a.lastModified() == file3.lastModified()); | |||||
| // file time checks for java1.2+ | |||||
| assertEquals(file3a.lastModified(), file3.lastModified()); | |||||
| assertTrue(file3c.lastModified() < file3a.lastModified()); | assertTrue(file3c.lastModified() < file3a.lastModified()); | ||||
| } | } | ||||
| @@ -293,14 +288,14 @@ public class CopyTest { | |||||
| @Test | @Test | ||||
| public void testCopyToSymlinkedSelf() throws Exception { | public void testCopyToSymlinkedSelf() throws Exception { | ||||
| // we are only going to test against systems that support symlinks | // we are only going to test against systems that support symlinks | ||||
| Assume.assumeTrue("Symlinks not supported on this operating system", Os.isFamily(Os.FAMILY_UNIX)); | |||||
| assumeTrue("Symlinks not supported on this operating system", Os.isFamily(Os.FAMILY_UNIX)); | |||||
| // setup the source files to run copying against | // setup the source files to run copying against | ||||
| buildRule.executeTarget("setupSelfCopyTesting"); | buildRule.executeTarget("setupSelfCopyTesting"); | ||||
| final File testDir = new File(buildRule.getProject().getProperty("self.copy.test.root.dir")); | final File testDir = new File(buildRule.getProject().getProperty("self.copy.test.root.dir")); | ||||
| Assert.assertTrue(testDir + " was expected to be a directory", testDir.isDirectory()); | |||||
| assertTrue(testDir + " was expected to be a directory", testDir.isDirectory()); | |||||
| final File srcFile = new File(testDir, "file.txt"); | final File srcFile = new File(testDir, "file.txt"); | ||||
| Assert.assertTrue("Source file " + srcFile + " was expected to be a file", srcFile.isFile()); | |||||
| assertTrue("Source file " + srcFile + " was expected to be a file", srcFile.isFile()); | |||||
| final long originalFileSize = srcFile.length(); | final long originalFileSize = srcFile.length(); | ||||
| final String originalContent; | final String originalContent; | ||||
| final BufferedReader reader = new BufferedReader(new FileReader(srcFile)); | final BufferedReader reader = new BufferedReader(new FileReader(srcFile)); | ||||
| @@ -309,26 +304,26 @@ public class CopyTest { | |||||
| } finally { | } finally { | ||||
| reader.close(); | reader.close(); | ||||
| } | } | ||||
| Assert.assertTrue("Content missing in file " + srcFile, originalContent != null && originalContent.length() > 0); | |||||
| assertTrue("Content missing in file " + srcFile, originalContent != null && originalContent.length() > 0); | |||||
| // run the copy tests | // run the copy tests | ||||
| buildRule.executeTarget("testSelfCopy"); | buildRule.executeTarget("testSelfCopy"); | ||||
| // make sure the source file hasn't been impacted by the copy | // make sure the source file hasn't been impacted by the copy | ||||
| assertSizeAndContent(srcFile, originalFileSize, originalContent); | assertSizeAndContent(srcFile, originalFileSize, originalContent); | ||||
| final File symlinkedFile = new File(testDir, "sylmink-file.txt"); | final File symlinkedFile = new File(testDir, "sylmink-file.txt"); | ||||
| Assert.assertTrue(symlinkedFile + " was expected to be a file", symlinkedFile.isFile()); | |||||
| assertTrue(symlinkedFile + " was expected to be a file", symlinkedFile.isFile()); | |||||
| assertSizeAndContent(symlinkedFile, originalFileSize, originalContent); | assertSizeAndContent(symlinkedFile, originalFileSize, originalContent); | ||||
| final File symlinkedTestDir = new File(buildRule.getProject().getProperty("self.copy.test.symlinked.dir")); | final File symlinkedTestDir = new File(buildRule.getProject().getProperty("self.copy.test.symlinked.dir")); | ||||
| Assert.assertTrue(symlinkedTestDir + " was expected to be a directory", symlinkedTestDir.isDirectory()); | |||||
| assertTrue(symlinkedTestDir + " was expected to be a directory", symlinkedTestDir.isDirectory()); | |||||
| assertSizeAndContent(new File(symlinkedTestDir, "file.txt"), originalFileSize, originalContent); | assertSizeAndContent(new File(symlinkedTestDir, "file.txt"), originalFileSize, originalContent); | ||||
| assertSizeAndContent(new File(symlinkedTestDir, "sylmink-file.txt"), originalFileSize, originalContent); | assertSizeAndContent(new File(symlinkedTestDir, "sylmink-file.txt"), originalFileSize, originalContent); | ||||
| } | } | ||||
| private void assertSizeAndContent(final File file, final long expectedSize, final String expectedContent) throws IOException { | private void assertSizeAndContent(final File file, final long expectedSize, final String expectedContent) throws IOException { | ||||
| Assert.assertTrue(file + " was expected to be a file", file.isFile()); | |||||
| Assert.assertEquals("Unexpected size of file " + file, expectedSize, file.length()); | |||||
| assertTrue(file + " was expected to be a file", file.isFile()); | |||||
| assertEquals("Unexpected size of file " + file, expectedSize, file.length()); | |||||
| final BufferedReader reader = new BufferedReader(new FileReader(file)); | final BufferedReader reader = new BufferedReader(new FileReader(file)); | ||||
| final String content; | final String content; | ||||
| try { | try { | ||||
| @@ -336,6 +331,6 @@ public class CopyTest { | |||||
| } finally { | } finally { | ||||
| reader.close(); | reader.close(); | ||||
| } | } | ||||
| Assert.assertEquals("Unexpected content in file " + file, expectedContent, content); | |||||
| assertEquals("Unexpected content in file " + file, expectedContent, content); | |||||
| } | } | ||||
| } | } | ||||
| @@ -11,7 +11,7 @@ import java.io.FileInputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.util.Arrays; | import java.util.Arrays; | ||||
| import static org.junit.Assert.assertFalse; | |||||
| import static org.junit.Assert.assertNotEquals; | |||||
| import static org.junit.Assert.assertNotNull; | import static org.junit.Assert.assertNotNull; | ||||
| import static org.junit.Assert.assertTrue; | import static org.junit.Assert.assertTrue; | ||||
| @@ -57,7 +57,7 @@ public class ExecStreamRedirectorTest { | |||||
| assertTrue(redirectedOutputFile + " is missing or not a regular file", redirectedOutputFile.isFile()); | assertTrue(redirectedOutputFile + " is missing or not a regular file", redirectedOutputFile.isFile()); | ||||
| final byte[] redirectedOutput = readAllBytes(redirectedOutputFile); | final byte[] redirectedOutput = readAllBytes(redirectedOutputFile); | ||||
| assertNotNull("No content was redirected to " + redirectedOutputFile, redirectedOutput); | assertNotNull("No content was redirected to " + redirectedOutputFile, redirectedOutput); | ||||
| assertFalse("Content in redirected file " + redirectedOutputFile + " was empty", redirectedOutput.length == 0); | |||||
| assertNotEquals("Content in redirected file " + redirectedOutputFile + " was empty", 0, redirectedOutput.length); | |||||
| if (dirListingOutput != null) { | if (dirListingOutput != null) { | ||||
| // compare the directory listing that was redirected to these files. all files should have the same content | // compare the directory listing that was redirected to these files. all files should have the same content | ||||
| assertTrue("Redirected output in file " + redirectedOutputFile + | assertTrue("Redirected output in file " + redirectedOutputFile + | ||||
| @@ -22,7 +22,6 @@ import static org.apache.tools.ant.AntAssert.assertContains; | |||||
| import static org.junit.Assert.assertEquals; | import static org.junit.Assert.assertEquals; | ||||
| import static org.junit.Assert.assertNotNull; | import static org.junit.Assert.assertNotNull; | ||||
| import static org.junit.Assert.assertNull; | import static org.junit.Assert.assertNull; | ||||
| import static org.junit.Assert.assertTrue; | |||||
| import static org.junit.Assert.fail; | import static org.junit.Assert.fail; | ||||
| import java.io.File; | import java.io.File; | ||||
| @@ -53,8 +52,7 @@ public class ImportTest { | |||||
| buildRule.configureProject("src/etc/testcases/taskdefs/import/unnamedImport.xml", | buildRule.configureProject("src/etc/testcases/taskdefs/import/unnamedImport.xml", | ||||
| Project.MSG_WARN); | Project.MSG_WARN); | ||||
| String log = buildRule.getLog(); | String log = buildRule.getLog(); | ||||
| assertTrue("Warnings logged when not expected: " + log, | |||||
| log.length() == 0); | |||||
| assertEquals("Warnings logged when not expected: " + log, 0, log.length()); | |||||
| } | } | ||||
| @Test | @Test | ||||
| @@ -41,8 +41,8 @@ import org.junit.Test; | |||||
| import org.junit.internal.AssumptionViolatedException; | import org.junit.internal.AssumptionViolatedException; | ||||
| import static org.apache.tools.ant.AntAssert.assertContains; | import static org.apache.tools.ant.AntAssert.assertContains; | ||||
| import org.junit.Assert; | |||||
| import static org.junit.Assert.assertEquals; | import static org.junit.Assert.assertEquals; | ||||
| import static org.junit.Assert.assertNotNull; | |||||
| import static org.junit.Assert.assertTrue; | import static org.junit.Assert.assertTrue; | ||||
| import static org.junit.Assert.fail; | import static org.junit.Assert.fail; | ||||
| @@ -169,7 +169,7 @@ public class JavaTest { | |||||
| java.setJvmargs("-Xmx128M"); | java.setJvmargs("-Xmx128M"); | ||||
| java.setArgs(arg); | java.setArgs(arg); | ||||
| final String[] cmdLine = java.getCommandLine().getCommandline(); | final String[] cmdLine = java.getCommandLine().getCommandline(); | ||||
| Assert.assertNotNull("Has command line.", cmdLine); | |||||
| assertNotNull("Has command line.", cmdLine); | |||||
| assertEquals("Command line should have 5 elements", 5, cmdLine.length); | assertEquals("Command line should have 5 elements", 5, cmdLine.length); | ||||
| assertEquals("Last command line element should be java argument: " + arg, | assertEquals("Last command line element should be java argument: " + arg, | ||||
| arg, | arg, | ||||
| @@ -195,7 +195,7 @@ public class JavaTest { | |||||
| java.setJvmargs("-Xmx128M"); //NOI18N | java.setJvmargs("-Xmx128M"); //NOI18N | ||||
| java.setArgs(arg); | java.setArgs(arg); | ||||
| final String[] cmdLine = java.getCommandLine().getCommandline(); | final String[] cmdLine = java.getCommandLine().getCommandline(); | ||||
| Assert.assertNotNull("Has command line.", cmdLine); | |||||
| assertNotNull("Has command line.", cmdLine); | |||||
| assertEquals("Command line should have 5 elements", 5, cmdLine.length); | assertEquals("Command line should have 5 elements", 5, cmdLine.length); | ||||
| assertEquals("Last command line element should be java argument: " + arg, | assertEquals("Last command line element should be java argument: " + arg, | ||||
| arg, | arg, | ||||
| @@ -148,7 +148,7 @@ public class ReplaceTest { | |||||
| testFile.setLastModified(testFile.lastModified() - FileUtils.getFileUtils().getFileTimestampGranularity() * 5)); | testFile.setLastModified(testFile.lastModified() - FileUtils.getFileUtils().getFileTimestampGranularity() * 5)); | ||||
| long ts1 = testFile.lastModified(); | long ts1 = testFile.lastModified(); | ||||
| buildRule.executeTarget("testPreserve"); | buildRule.executeTarget("testPreserve"); | ||||
| assertTrue(ts1 == new File(buildRule.getOutputDir(), "test.txt").lastModified()); | |||||
| assertEquals(ts1, new File(buildRule.getOutputDir(), "test.txt").lastModified()); | |||||
| } | } | ||||
| public void assertEqualContent(File expect, File result) | public void assertEqualContent(File expect, File result) | ||||
| @@ -29,6 +29,7 @@ import org.junit.Test; | |||||
| import static org.junit.Assert.assertEquals; | import static org.junit.Assert.assertEquals; | ||||
| import static org.junit.Assert.assertFalse; | import static org.junit.Assert.assertFalse; | ||||
| import static org.junit.Assert.assertNotEquals; | |||||
| import static org.junit.Assert.assertTrue; | import static org.junit.Assert.assertTrue; | ||||
| import static org.junit.Assert.fail; | import static org.junit.Assert.fail; | ||||
| @@ -124,7 +125,7 @@ public class SignJarTest { | |||||
| File f = new File(testJarParent, | File f = new File(testJarParent, | ||||
| "../" + testJarParent.getName() + "/" | "../" + testJarParent.getName() + "/" | ||||
| + testJar.getName()); | + testJar.getName()); | ||||
| assertFalse(testJar.equals(f)); | |||||
| assertNotEquals(testJar, f); | |||||
| assertEquals(testJar.getCanonicalPath(), f.getCanonicalPath()); | assertEquals(testJar.getCanonicalPath(), f.getCanonicalPath()); | ||||
| SignJar s = new SignJar(); | SignJar s = new SignJar(); | ||||
| s.setProject(buildRule.getProject()); | s.setProject(buildRule.getProject()); | ||||
| @@ -36,11 +36,10 @@ import org.junit.Test; | |||||
| import static org.apache.tools.ant.AntAssert.assertContains; | import static org.apache.tools.ant.AntAssert.assertContains; | ||||
| import static org.junit.Assert.assertEquals; | import static org.junit.Assert.assertEquals; | ||||
| import static org.junit.Assert.assertNotNull; | import static org.junit.Assert.assertNotNull; | ||||
| import static org.junit.Assert.assertTrue; | |||||
| import static org.junit.Assert.assertNull; | |||||
| import static org.junit.Assert.fail; | import static org.junit.Assert.fail; | ||||
| import static org.junit.Assume.assumeTrue; | import static org.junit.Assume.assumeTrue; | ||||
| public class ZipTest { | public class ZipTest { | ||||
| @Rule | @Rule | ||||
| @@ -138,12 +137,12 @@ public class ZipTest { | |||||
| ZipFile zipFile = new ZipFile(new File(buildRule.getProject().getProperty("output"), | ZipFile zipFile = new ZipFile(new File(buildRule.getProject().getProperty("output"), | ||||
| "zipgroupfileset.zip")); | "zipgroupfileset.zip")); | ||||
| assertTrue(zipFile.getEntry("ant.xml") != null); | |||||
| assertTrue(zipFile.getEntry("optional/jspc.xml") != null); | |||||
| assertTrue(zipFile.getEntry("zip/zipgroupfileset3.zip") != null); | |||||
| assertNotNull(zipFile.getEntry("ant.xml")); | |||||
| assertNotNull(zipFile.getEntry("optional/jspc.xml")); | |||||
| assertNotNull(zipFile.getEntry("zip/zipgroupfileset3.zip")); | |||||
| assertTrue(zipFile.getEntry("test6.mf") == null); | |||||
| assertTrue(zipFile.getEntry("test7.mf") == null); | |||||
| assertNull(zipFile.getEntry("test6.mf")); | |||||
| assertNull(zipFile.getEntry("test7.mf")); | |||||
| zipFile.close(); | zipFile.close(); | ||||
| } | } | ||||
| @@ -30,12 +30,14 @@ import org.apache.tools.ant.taskdefs.Javac; | |||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| import org.junit.Test; | import org.junit.Test; | ||||
| import static org.apache.tools.ant.AntAssert.assertContains; | |||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| import org.junit.Assert; | |||||
| import static org.apache.tools.ant.AntAssert.assertContains; | |||||
| import static org.junit.Assert.assertEquals; | import static org.junit.Assert.assertEquals; | ||||
| import static org.junit.Assert.assertNotNull; | |||||
| import static org.junit.Assert.assertTrue; | |||||
| public class DefaultCompilerAdapterTest { | public class DefaultCompilerAdapterTest { | ||||
| @@ -263,17 +265,17 @@ public class DefaultCompilerAdapterTest { | |||||
| javac.setIncludeantruntime(false); | javac.setIncludeantruntime(false); | ||||
| javac.add(impl); | javac.add(impl); | ||||
| javac.execute(); | javac.execute(); | ||||
| Assert.assertNotNull(cmd[0]); | |||||
| assertNotNull(cmd[0]); | |||||
| final List<String> cmdLine = Arrays.asList(cmd[0].getCommandline()); | final List<String> cmdLine = Arrays.asList(cmd[0].getCommandline()); | ||||
| //No modulesourcepath | //No modulesourcepath | ||||
| assertEquals(-1, cmdLine.indexOf("--module-source-path")); | assertEquals(-1, cmdLine.indexOf("--module-source-path")); | ||||
| //The -sourcepath has to be followed by src | //The -sourcepath has to be followed by src | ||||
| int index = cmdLine.indexOf("-sourcepath"); | int index = cmdLine.indexOf("-sourcepath"); | ||||
| Assert.assertTrue(index != -1 && index < cmdLine.size() - 1); | |||||
| assertTrue(index != -1 && index < cmdLine.size() - 1); | |||||
| assertEquals(src.getAbsolutePath(), cmdLine.get(index + 1)); | assertEquals(src.getAbsolutePath(), cmdLine.get(index + 1)); | ||||
| //The --module-path has to be followed by modules | //The --module-path has to be followed by modules | ||||
| index = cmdLine.indexOf("--module-path"); | index = cmdLine.indexOf("--module-path"); | ||||
| Assert.assertTrue(index != -1 && index < cmdLine.size() - 1); | |||||
| assertTrue(index != -1 && index < cmdLine.size() - 1); | |||||
| assertEquals(modules.getAbsolutePath(), cmdLine.get(index + 1)); | assertEquals(modules.getAbsolutePath(), cmdLine.get(index + 1)); | ||||
| //J1.java & J2.java has to be in files list | //J1.java & J2.java has to be in files list | ||||
| final Set<String> expected = new TreeSet<String>(); | final Set<String> expected = new TreeSet<String>(); | ||||
| @@ -321,13 +323,13 @@ public class DefaultCompilerAdapterTest { | |||||
| javac.setIncludeantruntime(false); | javac.setIncludeantruntime(false); | ||||
| javac.add(impl); | javac.add(impl); | ||||
| javac.execute(); | javac.execute(); | ||||
| Assert.assertNotNull(cmd[0]); | |||||
| assertNotNull(cmd[0]); | |||||
| final List<String> cmdLine = Arrays.asList(cmd[0].getCommandline()); | final List<String> cmdLine = Arrays.asList(cmd[0].getCommandline()); | ||||
| //No sourcepath | //No sourcepath | ||||
| assertEquals(-1, cmdLine.indexOf("-sourcepath")); | assertEquals(-1, cmdLine.indexOf("-sourcepath")); | ||||
| //The --module-source-path has to be followed by the pattern | //The --module-source-path has to be followed by the pattern | ||||
| int index = cmdLine.indexOf("--module-source-path"); | int index = cmdLine.indexOf("--module-source-path"); | ||||
| Assert.assertTrue(index != -1 && index < cmdLine.size() - 1); | |||||
| assertTrue(index != -1 && index < cmdLine.size() - 1); | |||||
| String expectedModSrcPath = String.format("%s/%s", | String expectedModSrcPath = String.format("%s/%s", | ||||
| workDir.getAbsolutePath(), | workDir.getAbsolutePath(), | ||||
| moduleSrcPathStr) | moduleSrcPathStr) | ||||
| @@ -336,7 +338,7 @@ public class DefaultCompilerAdapterTest { | |||||
| assertEquals(expectedModSrcPath, cmdLine.get(index + 1)); | assertEquals(expectedModSrcPath, cmdLine.get(index + 1)); | ||||
| //The --module-path has to be followed by modules | //The --module-path has to be followed by modules | ||||
| index = cmdLine.indexOf("--module-path"); | index = cmdLine.indexOf("--module-path"); | ||||
| Assert.assertTrue(index != -1 && index < cmdLine.size() - 1); | |||||
| assertTrue(index != -1 && index < cmdLine.size() - 1); | |||||
| assertEquals(modules.getAbsolutePath(), cmdLine.get(index + 1)); | assertEquals(modules.getAbsolutePath(), cmdLine.get(index + 1)); | ||||
| //J1.java, J2.java & J3.java has to be in files list | //J1.java, J2.java & J3.java has to be in files list | ||||
| final Set<String> expectedFiles = new TreeSet<String>(); | final Set<String> expectedFiles = new TreeSet<String>(); | ||||
| @@ -386,7 +388,7 @@ public class DefaultCompilerAdapterTest { | |||||
| javac.add(impl); | javac.add(impl); | ||||
| javac.execute(); | javac.execute(); | ||||
| final File[] compileList = impl.compileList; | final File[] compileList = impl.compileList; | ||||
| Assert.assertNotNull(compileList); | |||||
| assertNotNull(compileList); | |||||
| //J1.java, J2.java has to be in files list but not J3.java | //J1.java, J2.java has to be in files list but not J3.java | ||||
| final Set<String> expectedFiles = new TreeSet<String>(); | final Set<String> expectedFiles = new TreeSet<String>(); | ||||
| Collections.addAll(expectedFiles, | Collections.addAll(expectedFiles, | ||||
| @@ -181,9 +181,8 @@ public class JspcTest { | |||||
| */ | */ | ||||
| protected void assertMapped(JspMangler mangler, String filename, String classname) { | protected void assertMapped(JspMangler mangler, String filename, String classname) { | ||||
| String mappedname = mangler.mapJspToJavaName(new File(filename)); | String mappedname = mangler.mapJspToJavaName(new File(filename)); | ||||
| assertTrue(filename + " should have mapped to " + classname | |||||
| + " but instead mapped to " + mappedname, | |||||
| classname.equals(mappedname)); | |||||
| assertEquals(filename + " should have mapped to " + classname | |||||
| + " but instead mapped to " + mappedname, classname, mappedname); | |||||
| } | } | ||||
| } | } | ||||
| @@ -81,9 +81,9 @@ public class PropertyFileTest { | |||||
| assertEquals(FNAME, beforeUpdate.getProperty(FNAME_KEY)); | assertEquals(FNAME, beforeUpdate.getProperty(FNAME_KEY)); | ||||
| assertEquals(LNAME, beforeUpdate.getProperty(LNAME_KEY)); | assertEquals(LNAME, beforeUpdate.getProperty(LNAME_KEY)); | ||||
| assertEquals(EMAIL, beforeUpdate.getProperty(EMAIL_KEY)); | assertEquals(EMAIL, beforeUpdate.getProperty(EMAIL_KEY)); | ||||
| assertEquals(null, beforeUpdate.getProperty(PHONE_KEY)); | |||||
| assertEquals(null, beforeUpdate.getProperty(AGE_KEY)); | |||||
| assertEquals(null, beforeUpdate.getProperty(DATE_KEY)); | |||||
| assertNull(beforeUpdate.getProperty(PHONE_KEY)); | |||||
| assertNull(beforeUpdate.getProperty(AGE_KEY)); | |||||
| assertNull(beforeUpdate.getProperty(DATE_KEY)); | |||||
| // ask ant to update the properties... | // ask ant to update the properties... | ||||
| buildRule.executeTarget("update-existing-properties"); | buildRule.executeTarget("update-existing-properties"); | ||||
| @@ -29,6 +29,7 @@ import org.junit.Test; | |||||
| import java.io.File; | import java.io.File; | ||||
| import static org.junit.Assert.assertEquals; | |||||
| import static org.junit.Assert.assertTrue; | import static org.junit.Assert.assertTrue; | ||||
| import static org.junit.Assume.assumeFalse; | import static org.junit.Assume.assumeFalse; | ||||
| import static org.junit.Assume.assumeTrue; | import static org.junit.Assume.assumeTrue; | ||||
| @@ -96,7 +97,7 @@ public class ImageTest { | |||||
| AntAssert.assertContains("Processing File", buildRule.getLog()); | AntAssert.assertContains("Processing File", buildRule.getLog()); | ||||
| f = new File(buildRule.getOutputDir(), LARGEIMAGE); | f = new File(buildRule.getOutputDir(), LARGEIMAGE); | ||||
| long overwrittenLastModified = f.lastModified(); | long overwrittenLastModified = f.lastModified(); | ||||
| assertTrue("File was overwritten.", lastModified == overwrittenLastModified); | |||||
| assertEquals("File was overwritten.", lastModified, overwrittenLastModified); | |||||
| } | } | ||||
| @Test | @Test | ||||
| @@ -5,12 +5,13 @@ import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.BuildListener; | import org.apache.tools.ant.BuildListener; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.ProjectHelper; | import org.apache.tools.ant.ProjectHelper; | ||||
| import org.junit.Assert; | |||||
| import org.junit.Before; | import org.junit.Before; | ||||
| import org.junit.Test; | import org.junit.Test; | ||||
| import java.io.File; | import java.io.File; | ||||
| import static org.junit.Assert.fail; | |||||
| /** | /** | ||||
| * Tests the {@link JUnitLauncherTask} | * Tests the {@link JUnitLauncherTask} | ||||
| */ | */ | ||||
| @@ -75,7 +76,7 @@ public class JUnitLauncherTaskTest { | |||||
| public void testFailureStopsBuild() { | public void testFailureStopsBuild() { | ||||
| try { | try { | ||||
| project.executeTarget("test-failure-stops-build"); | project.executeTarget("test-failure-stops-build"); | ||||
| Assert.fail("Test execution failure was expected to stop the build but didn't"); | |||||
| fail("Test execution failure was expected to stop the build but didn't"); | |||||
| } catch (BuildException be) { | } catch (BuildException be) { | ||||
| // expected | // expected | ||||
| } | } | ||||
| @@ -35,16 +35,16 @@ import org.apache.tools.ant.taskdefs.condition.Os; | |||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.util.SymbolicLinkUtils; | import org.apache.tools.ant.util.SymbolicLinkUtils; | ||||
| import org.junit.After; | import org.junit.After; | ||||
| import org.junit.Assert; | |||||
| import org.junit.Assume; | |||||
| import org.junit.Before; | import org.junit.Before; | ||||
| import org.junit.Rule; | import org.junit.Rule; | ||||
| import org.junit.Test; | import org.junit.Test; | ||||
| import static org.junit.Assert.assertEquals; | |||||
| import static org.junit.Assert.assertFalse; | import static org.junit.Assert.assertFalse; | ||||
| import static org.junit.Assert.assertNotNull; | import static org.junit.Assert.assertNotNull; | ||||
| import static org.junit.Assert.assertTrue; | import static org.junit.Assert.assertTrue; | ||||
| import static org.junit.Assert.fail; | import static org.junit.Assert.fail; | ||||
| import static org.junit.Assume.assumeTrue; | |||||
| import java.io.File; | import java.io.File; | ||||
| import java.nio.file.Files; | import java.nio.file.Files; | ||||
| @@ -69,7 +69,7 @@ public class SymlinkTest { | |||||
| @Before | @Before | ||||
| public void setUp() { | public void setUp() { | ||||
| Assume.assumeTrue("Symlinks not supported on current operating system", supportsSymlinks); | |||||
| assumeTrue("Symlinks not supported on current operating system", supportsSymlinks); | |||||
| buildRule.configureProject("src/etc/testcases/taskdefs/optional/unix/symlink.xml"); | buildRule.configureProject("src/etc/testcases/taskdefs/optional/unix/symlink.xml"); | ||||
| buildRule.executeTarget("setUp"); | buildRule.executeTarget("setUp"); | ||||
| } | } | ||||
| @@ -274,8 +274,8 @@ public class SymlinkTest { | |||||
| assertFalse(f.exists()); | assertFalse(f.exists()); | ||||
| assertFalse(f.isDirectory()); | assertFalse(f.isDirectory()); | ||||
| assertFalse(f.isFile()); | assertFalse(f.isFile()); | ||||
| assertTrue(su.isSymbolicLink(f.getAbsolutePath()) == false); | |||||
| assertTrue(su.isSymbolicLink(f.getParentFile(), f.getName()) == false); | |||||
| assertFalse(su.isSymbolicLink(f.getAbsolutePath())); | |||||
| assertFalse(su.isSymbolicLink(f.getParentFile(), f.getName())); | |||||
| assertTrue(su.isDanglingSymbolicLink(f.getAbsolutePath())); | assertTrue(su.isDanglingSymbolicLink(f.getAbsolutePath())); | ||||
| assertTrue(su.isDanglingSymbolicLink(f.getParentFile(), | assertTrue(su.isDanglingSymbolicLink(f.getParentFile(), | ||||
| f.getName())); | f.getName())); | ||||
| @@ -284,8 +284,8 @@ public class SymlinkTest { | |||||
| assertFalse(f.exists()); | assertFalse(f.exists()); | ||||
| assertFalse(f.isDirectory()); | assertFalse(f.isDirectory()); | ||||
| assertFalse(f.isFile()); | assertFalse(f.isFile()); | ||||
| assertTrue(su.isSymbolicLink(f.getAbsolutePath()) == false); | |||||
| assertTrue(su.isSymbolicLink(f.getParentFile(), f.getName()) == false); | |||||
| assertFalse(su.isSymbolicLink(f.getAbsolutePath())); | |||||
| assertFalse(su.isSymbolicLink(f.getParentFile(), f.getName())); | |||||
| assertTrue(su.isDanglingSymbolicLink(f.getAbsolutePath())); | assertTrue(su.isDanglingSymbolicLink(f.getAbsolutePath())); | ||||
| assertTrue(su.isDanglingSymbolicLink(f.getParentFile(), | assertTrue(su.isDanglingSymbolicLink(f.getParentFile(), | ||||
| f.getName())); | f.getName())); | ||||
| @@ -305,10 +305,10 @@ public class SymlinkTest { | |||||
| buildRule.executeTarget("test-overwrite-link"); | buildRule.executeTarget("test-overwrite-link"); | ||||
| final Project p = buildRule.getProject(); | final Project p = buildRule.getProject(); | ||||
| final String linkTargetResource = p.getProperty("test.overwrite.link.target.dir"); | final String linkTargetResource = p.getProperty("test.overwrite.link.target.dir"); | ||||
| Assert.assertNotNull("Property test.overwrite.link.target.dir is not set", linkTargetResource); | |||||
| assertNotNull("Property test.overwrite.link.target.dir is not set", linkTargetResource); | |||||
| final Path targetResourcePath = Paths.get(linkTargetResource); | final Path targetResourcePath = Paths.get(linkTargetResource); | ||||
| Assert.assertTrue(targetResourcePath + " is not a directory", Files.isDirectory(targetResourcePath)); | |||||
| Assert.assertEquals(targetResourcePath + " directory was expected to be empty", 0, Files.list(targetResourcePath).count()); | |||||
| assertTrue(targetResourcePath + " is not a directory", Files.isDirectory(targetResourcePath)); | |||||
| assertEquals(targetResourcePath + " directory was expected to be empty", 0, Files.list(targetResourcePath).count()); | |||||
| } | } | ||||
| @After | @After | ||||
| @@ -24,7 +24,6 @@ import org.apache.tools.ant.BuildException; | |||||
| import org.junit.Test; | import org.junit.Test; | ||||
| import static org.junit.Assert.assertEquals; | import static org.junit.Assert.assertEquals; | ||||
| import static org.junit.Assert.assertTrue; | |||||
| import static org.junit.Assert.fail; | import static org.junit.Assert.fail; | ||||
| /** | /** | ||||
| @@ -107,14 +106,10 @@ public class TarFileSetTest extends AbstractFileSetTest { | |||||
| getProject().addReference("test", f); | getProject().addReference("test", f); | ||||
| TarFileSet zid = (TarFileSet) getInstance(); | TarFileSet zid = (TarFileSet) getInstance(); | ||||
| zid.setRefid(new Reference(getProject(), "test")); | zid.setRefid(new Reference(getProject(), "test")); | ||||
| assertTrue("src attribute copied by copy constructor", | |||||
| zid.getSrc(getProject()).equals(f.getSrc(getProject()))); | |||||
| assertTrue("prefix attribute copied by copy constructor", | |||||
| f.getPrefix(getProject()).equals(zid.getPrefix(getProject()))); | |||||
| assertTrue("file mode attribute copied by copy constructor", | |||||
| f.getFileMode(getProject()) == zid.getFileMode(getProject())); | |||||
| assertTrue("dir mode attribute copied by copy constructor", | |||||
| f.getDirMode(getProject()) == zid.getDirMode(getProject())); | |||||
| assertEquals("src attribute copied by copy constructor", zid.getSrc(getProject()), f.getSrc(getProject())); | |||||
| assertEquals("prefix attribute copied by copy constructor", f.getPrefix(getProject()), zid.getPrefix(getProject())); | |||||
| assertEquals("file mode attribute copied by copy constructor", f.getFileMode(getProject()), zid.getFileMode(getProject())); | |||||
| assertEquals("dir mode attribute copied by copy constructor", f.getDirMode(getProject()), zid.getDirMode(getProject())); | |||||
| } | } | ||||
| } | } | ||||
| @@ -24,7 +24,6 @@ import org.apache.tools.ant.BuildException; | |||||
| import org.junit.Test; | import org.junit.Test; | ||||
| import static org.junit.Assert.assertEquals; | import static org.junit.Assert.assertEquals; | ||||
| import static org.junit.Assert.assertTrue; | |||||
| import static org.junit.Assert.fail; | import static org.junit.Assert.fail; | ||||
| /** | /** | ||||
| @@ -106,10 +105,8 @@ public class ZipFileSetTest extends AbstractFileSetTest { | |||||
| getProject().addReference("test", f); | getProject().addReference("test", f); | ||||
| ZipFileSet zid = (ZipFileSet) getInstance(); | ZipFileSet zid = (ZipFileSet) getInstance(); | ||||
| zid.setRefid(new Reference(getProject(), "test")); | zid.setRefid(new Reference(getProject(), "test")); | ||||
| assertTrue("src attribute copied by copy constructor", | |||||
| zid.getSrc(getProject()).equals(f.getSrc(getProject()))); | |||||
| assertTrue("prefix attribute copied by copy constructor", | |||||
| f.getPrefix(getProject()).equals(zid.getPrefix(getProject()))); | |||||
| assertEquals("src attribute copied by copy constructor", zid.getSrc(getProject()), f.getSrc(getProject())); | |||||
| assertEquals("prefix attribute copied by copy constructor", f.getPrefix(getProject()), zid.getPrefix(getProject())); | |||||
| assertEquals("file mode attribute copied by copy constructor", | assertEquals("file mode attribute copied by copy constructor", | ||||
| f.getFileMode(getProject()), zid.getFileMode(getProject())); | f.getFileMode(getProject()), zid.getFileMode(getProject())); | ||||
| assertEquals("dir mode attribute copied by copy constructor", | assertEquals("dir mode attribute copied by copy constructor", | ||||
| @@ -18,7 +18,6 @@ | |||||
| package org.apache.tools.ant.types.selectors; | package org.apache.tools.ant.types.selectors; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileWriter; | import java.io.FileWriter; | ||||
| import java.text.RuleBasedCollator; | import java.text.RuleBasedCollator; | ||||
| @@ -51,6 +50,7 @@ import org.junit.Test; | |||||
| import static org.junit.Assert.assertEquals; | import static org.junit.Assert.assertEquals; | ||||
| import static org.junit.Assert.assertFalse; | import static org.junit.Assert.assertFalse; | ||||
| import static org.junit.Assert.assertNotEquals; | |||||
| import static org.junit.Assert.assertNotNull; | import static org.junit.Assert.assertNotNull; | ||||
| import static org.junit.Assert.assertTrue; | import static org.junit.Assert.assertTrue; | ||||
| import static org.junit.Assert.fail; | import static org.junit.Assert.fail; | ||||
| @@ -189,7 +189,7 @@ public class ModifiedSelectorTest { | |||||
| assertNotNull("'fs.mod.value' must be set.", fsModValue); | assertNotNull("'fs.mod.value' must be set.", fsModValue); | ||||
| // must be empty according to the Mock* implementations | // must be empty according to the Mock* implementations | ||||
| assertTrue("'fs.mod.value' must be empty.", "".equals(fsModValue)); | |||||
| assertEquals("'fs.mod.value' must be empty.", "", fsModValue); | |||||
| } finally { | } finally { | ||||
| bft.doTarget("modifiedselectortest-scenario-clean"); | bft.doTarget("modifiedselectortest-scenario-clean"); | ||||
| bft.deletePropertiesfile(); | bft.deletePropertiesfile(); | ||||
| @@ -602,9 +602,9 @@ public class ModifiedSelectorTest { | |||||
| Object o2 = "string2"; | Object o2 = "string2"; | ||||
| Object o3 = "string2"; // really "2" | Object o3 = "string2"; // really "2" | ||||
| assertTrue("Comparator gave wrong value.", comp.compare(o1, o2) != 0); | |||||
| assertTrue("Comparator gave wrong value.", comp.compare(o1, o3) != 0); | |||||
| assertTrue("Comparator gave wrong value.", comp.compare(o2, o3) == 0); | |||||
| assertNotEquals("Comparator gave wrong value.", 0, comp.compare(o1, o2)); | |||||
| assertNotEquals("Comparator gave wrong value.", 0, comp.compare(o1, o3)); | |||||
| assertEquals("Comparator gave wrong value.", 0, comp.compare(o2, o3)); | |||||
| } | } | ||||
| // ===================== scenario tests ===================== | // ===================== scenario tests ===================== | ||||
| @@ -837,8 +837,8 @@ public class ModifiedSelectorTest { | |||||
| // do the checks | // do the checks | ||||
| assertTrue("Cache file not created.", cachefile.exists()); | assertTrue("Cache file not created.", cachefile.exists()); | ||||
| assertTrue("Not enough files copied on first time.", to1.list().length > 5); | assertTrue("Not enough files copied on first time.", to1.list().length > 5); | ||||
| assertTrue("Too much files copied on second time.", to2.list().length == 0); | |||||
| assertTrue("Too much files copied on third time.", to3.list().length == 2); | |||||
| assertEquals("Too much files copied on second time.", 0, to2.list().length); | |||||
| assertEquals("Too much files copied on third time.", 2, to3.list().length); | |||||
| // don't catch the JUnit exceptions | // don't catch the JUnit exceptions | ||||
| } finally { | } finally { | ||||
| bft.doTarget("modifiedselectortest-scenario-clean"); | bft.doTarget("modifiedselectortest-scenario-clean"); | ||||
| @@ -26,7 +26,7 @@ import org.apache.tools.ant.Project; | |||||
| import org.junit.Before; | import org.junit.Before; | ||||
| import org.junit.Test; | import org.junit.Test; | ||||
| import static org.junit.Assert.assertTrue; | |||||
| import static org.junit.Assert.assertEquals; | |||||
| /** | /** | ||||
| @@ -61,6 +61,6 @@ public class ClasspathUtilsTest { | |||||
| list.append(" ").append(enumeration.nextElement()); | list.append(" ").append(enumeration.nextElement()); | ||||
| count++; | count++; | ||||
| } | } | ||||
| assertTrue("Should be only one and not " + count + " " + list, count == 1); | |||||
| assertEquals("Should be only one and not " + count + " " + list, 1, count); | |||||
| } | } | ||||
| } | } | ||||
| @@ -18,12 +18,12 @@ | |||||
| package org.apache.tools.ant.util; | package org.apache.tools.ant.util; | ||||
| import org.junit.Test; | |||||
| import static org.junit.Assert.assertEquals; | import static org.junit.Assert.assertEquals; | ||||
| import static org.junit.Assert.assertFalse; | |||||
| import static org.junit.Assert.assertNotEquals; | |||||
| import static org.junit.Assert.assertTrue; | import static org.junit.Assert.assertTrue; | ||||
| import org.junit.Test; | |||||
| public class DeweyDecimalTest { | public class DeweyDecimalTest { | ||||
| @Test | @Test | ||||
| @@ -55,21 +55,21 @@ public class DeweyDecimalTest { | |||||
| @Test | @Test | ||||
| public void testEquals() { | public void testEquals() { | ||||
| assertTrue(new DeweyDecimal("1.2.3").equals(new DeweyDecimal("1.2.3"))); | |||||
| assertFalse(new DeweyDecimal("1.2.3").equals(new DeweyDecimal("1.2.4"))); | |||||
| assertTrue(new DeweyDecimal("1.2.0").equals(new DeweyDecimal("1.2"))); | |||||
| assertTrue(new DeweyDecimal("1.2").equals(new DeweyDecimal("1.2.0"))); | |||||
| assertEquals(new DeweyDecimal("1.2.3"), new DeweyDecimal("1.2.3")); | |||||
| assertNotEquals(new DeweyDecimal("1.2.3"), new DeweyDecimal("1.2.4")); | |||||
| assertEquals(new DeweyDecimal("1.2.0"), new DeweyDecimal("1.2")); | |||||
| assertEquals(new DeweyDecimal("1.2"), new DeweyDecimal("1.2.0")); | |||||
| } | } | ||||
| @Test | @Test | ||||
| public void compareTo() { | public void compareTo() { | ||||
| assertTrue(new DeweyDecimal("1.2.3").compareTo(new DeweyDecimal("1.2")) > 0); | assertTrue(new DeweyDecimal("1.2.3").compareTo(new DeweyDecimal("1.2")) > 0); | ||||
| assertTrue(new DeweyDecimal("1.2").compareTo(new DeweyDecimal("1.2.3")) < 0); | assertTrue(new DeweyDecimal("1.2").compareTo(new DeweyDecimal("1.2.3")) < 0); | ||||
| assertTrue(new DeweyDecimal("1.2.3").compareTo(new DeweyDecimal("1.2.3")) == 0); | |||||
| assertEquals(0, new DeweyDecimal("1.2.3").compareTo(new DeweyDecimal("1.2.3"))); | |||||
| assertTrue(new DeweyDecimal("1.2.3").compareTo(new DeweyDecimal("1.1.4")) > 0); | assertTrue(new DeweyDecimal("1.2.3").compareTo(new DeweyDecimal("1.1.4")) > 0); | ||||
| assertTrue(new DeweyDecimal("1.2.3").compareTo(new DeweyDecimal("1.2.2.9")) > 0); | assertTrue(new DeweyDecimal("1.2.3").compareTo(new DeweyDecimal("1.2.2.9")) > 0); | ||||
| assertTrue(new DeweyDecimal("1.2.0").compareTo(new DeweyDecimal("1.2")) == 0); | |||||
| assertTrue(new DeweyDecimal("1.2").compareTo(new DeweyDecimal("1.2.0")) == 0); | |||||
| assertEquals(0, new DeweyDecimal("1.2.0").compareTo(new DeweyDecimal("1.2"))); | |||||
| assertEquals(0, new DeweyDecimal("1.2").compareTo(new DeweyDecimal("1.2.0"))); | |||||
| } | } | ||||
| // TODO isGreaterThan, ... | // TODO isGreaterThan, ... | ||||
| @@ -25,6 +25,8 @@ import java.nio.ByteBuffer; | |||||
| import org.junit.Test; | import org.junit.Test; | ||||
| import static org.junit.Assert.assertEquals; | import static org.junit.Assert.assertEquals; | ||||
| import static org.junit.Assert.assertFalse; | |||||
| import static org.junit.Assert.assertTrue; | |||||
| /** | /** | ||||
| * Test zip encodings. | * Test zip encodings. | ||||
| @@ -133,15 +135,15 @@ public class ZipEncodingTest { | |||||
| String decoded = enc.decode(testBytes); | String decoded = enc.decode(testBytes); | ||||
| assertEquals(true, enc.canEncode(decoded)); | |||||
| assertTrue(enc.canEncode(decoded)); | |||||
| ByteBuffer encoded = enc.encode(decoded); | ByteBuffer encoded = enc.encode(decoded); | ||||
| assertByteEquals(testBytes, encoded); | assertByteEquals(testBytes, encoded); | ||||
| assertEquals(false, enc.canEncode(UNENC_STRING)); | |||||
| assertFalse(enc.canEncode(UNENC_STRING)); | |||||
| assertByteEquals("%U2016".getBytes("US-ASCII"), enc.encode(UNENC_STRING)); | assertByteEquals("%U2016".getBytes("US-ASCII"), enc.encode(UNENC_STRING)); | ||||
| assertEquals(false, enc.canEncode(BAD_STRING)); | |||||
| assertFalse(enc.canEncode(BAD_STRING)); | |||||
| assertByteEquals(BAD_STRING_ENC.getBytes("US-ASCII"), | assertByteEquals(BAD_STRING_ENC.getBytes("US-ASCII"), | ||||
| enc.encode(BAD_STRING)); | enc.encode(BAD_STRING)); | ||||
| } | } | ||||
| @@ -23,7 +23,7 @@ import org.junit.Test; | |||||
| import java.util.NoSuchElementException; | import java.util.NoSuchElementException; | ||||
| import static org.junit.Assert.assertEquals; | import static org.junit.Assert.assertEquals; | ||||
| import static org.junit.Assert.assertFalse; | |||||
| import static org.junit.Assert.assertNotEquals; | |||||
| import static org.junit.Assert.assertSame; | import static org.junit.Assert.assertSame; | ||||
| import static org.junit.Assert.fail; | import static org.junit.Assert.fail; | ||||
| @@ -210,7 +210,7 @@ public class ZipEntryTest { | |||||
| public void testNotEquals() { | public void testNotEquals() { | ||||
| ZipEntry entry1 = new ZipEntry("foo"); | ZipEntry entry1 = new ZipEntry("foo"); | ||||
| ZipEntry entry2 = new ZipEntry("bar"); | ZipEntry entry2 = new ZipEntry("bar"); | ||||
| assertFalse(entry1.equals(entry2)); | |||||
| assertNotEquals(entry1, entry2); | |||||
| } | } | ||||
| @Test | @Test | ||||
| @@ -63,12 +63,12 @@ public class ZipLongTest { | |||||
| ZipLong zl2 = new ZipLong(0x12345678); | ZipLong zl2 = new ZipLong(0x12345678); | ||||
| ZipLong zl3 = new ZipLong(0x87654321); | ZipLong zl3 = new ZipLong(0x87654321); | ||||
| assertTrue("reflexive", zl.equals(zl)); | |||||
| assertEquals("reflexive", zl, zl); | |||||
| assertTrue("works", zl.equals(zl2)); | |||||
| assertEquals("works", zl, zl2); | |||||
| assertTrue("works, part two", !zl.equals(zl3)); | assertTrue("works, part two", !zl.equals(zl3)); | ||||
| assertTrue("symmetric", zl2.equals(zl)); | |||||
| assertEquals("symmetric", zl2, zl); | |||||
| assertTrue("null handling", !zl.equals(null)); | assertTrue("null handling", !zl.equals(null)); | ||||
| assertTrue("non ZipLong handling", !zl.equals(0x1234)); | assertTrue("non ZipLong handling", !zl.equals(0x1234)); | ||||
| @@ -60,12 +60,12 @@ public class ZipShortTest { | |||||
| ZipShort zs2 = new ZipShort(0x1234); | ZipShort zs2 = new ZipShort(0x1234); | ||||
| ZipShort zs3 = new ZipShort(0x5678); | ZipShort zs3 = new ZipShort(0x5678); | ||||
| assertTrue("reflexive", zs.equals(zs)); | |||||
| assertEquals("reflexive", zs, zs); | |||||
| assertTrue("works", zs.equals(zs2)); | |||||
| assertEquals("works", zs, zs2); | |||||
| assertTrue("works, part two", !zs.equals(zs3)); | assertTrue("works, part two", !zs.equals(zs3)); | ||||
| assertTrue("symmetric", zs2.equals(zs)); | |||||
| assertEquals("symmetric", zs2, zs); | |||||
| assertTrue("null handling", !zs.equals(null)); | assertTrue("null handling", !zs.equals(null)); | ||||
| assertTrue("non ZipShort handling", !zs.equals(0x1234)); | assertTrue("non ZipShort handling", !zs.equals(0x1234)); | ||||
| @@ -1,8 +1,11 @@ | |||||
| package org.example.junitlauncher.vintage; | package org.example.junitlauncher.vintage; | ||||
| import org.junit.Assert; | |||||
| import org.junit.Test; | import org.junit.Test; | ||||
| import static org.junit.Assert.assertEquals; | |||||
| import static org.junit.Assert.assertFalse; | |||||
| import static org.junit.Assert.assertTrue; | |||||
| /** | /** | ||||
| * | * | ||||
| */ | */ | ||||
| @@ -10,16 +13,16 @@ public class JUnit4SampleTest { | |||||
| @Test | @Test | ||||
| public void testFoo() { | public void testFoo() { | ||||
| Assert.assertEquals(1, 1); | |||||
| assertEquals(1, 1); | |||||
| } | } | ||||
| @Test | @Test | ||||
| public void testBar() { | public void testBar() { | ||||
| Assert.assertTrue(true); | |||||
| assertTrue(true); | |||||
| } | } | ||||
| @Test | @Test | ||||
| public void testFooBar() { | public void testFooBar() { | ||||
| Assert.assertFalse(false); | |||||
| assertFalse(false); | |||||
| } | } | ||||
| } | } | ||||