diff --git a/src/main/org/apache/tools/ant/taskdefs/EchoXML.java b/src/main/org/apache/tools/ant/taskdefs/EchoXML.java index 34baf6b92..91b6d8bd2 100644 --- a/src/main/org/apache/tools/ant/taskdefs/EchoXML.java +++ b/src/main/org/apache/tools/ant/taskdefs/EchoXML.java @@ -57,7 +57,7 @@ public class EchoXML extends XMLFragment { /** * Set the namespace policy for the xml file - * @param n namespace policy: "ignore," "elementsOnly," or "all" + * @param n namespace policy: "ignore", "elementsOnly", or "all" * @see org.apache.tools.ant.util.DOMElementWriter.XmlNamespacePolicy */ public void setNamespacePolicy(NamespacePolicy n) { diff --git a/src/main/org/apache/tools/ant/taskdefs/launcher/VmsCommandLauncher.java b/src/main/org/apache/tools/ant/taskdefs/launcher/VmsCommandLauncher.java index fe05b68a9..695223baf 100644 --- a/src/main/org/apache/tools/ant/taskdefs/launcher/VmsCommandLauncher.java +++ b/src/main/org/apache/tools/ant/taskdefs/launcher/VmsCommandLauncher.java @@ -125,7 +125,7 @@ public class VmsCommandLauncher extends Java13CommandLauncher { new Thread(() -> { try { p.waitFor(); - } catch(InterruptedException e) { + } catch (InterruptedException e) { // ignore } FileUtils.delete(f); diff --git a/src/tests/junit/org/apache/tools/ant/DispatchTaskTest.java b/src/tests/junit/org/apache/tools/ant/DispatchTaskTest.java index c682093da..dab734f74 100644 --- a/src/tests/junit/org/apache/tools/ant/DispatchTaskTest.java +++ b/src/tests/junit/org/apache/tools/ant/DispatchTaskTest.java @@ -39,7 +39,7 @@ public class DispatchTaskTest { try { buildRule.executeTarget("disp"); fail("BuildException should have been thrown"); - } catch(BuildException ex) { + } catch (BuildException ex) { //FIXME the previous method used here ignored the build exception - what are we trying to test } } diff --git a/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java b/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java index 90c8bd753..5a20f38b4 100644 --- a/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java +++ b/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java @@ -259,12 +259,12 @@ public class IntrospectionHelperTest { } private void assertElemMethod(String elemName, String methodName, - Class returnType, Class methodArg) { + Class returnType, Class methodArg) { Method m = ih.getElementMethod(elemName); assertEquals("Method name", methodName, m.getName()); - Class expectedReturnType = (returnType == null)? Void.TYPE: returnType; + Class expectedReturnType = (returnType == null)? Void.TYPE: returnType; assertEquals("Return type", expectedReturnType, m.getReturnType()); - Class[] args = m.getParameterTypes(); + Class[] args = m.getParameterTypes(); if (methodArg != null) { assertEquals("Arg Count", 1, args.length); assertEquals("Arg Type", methodArg, args[0]); @@ -491,14 +491,14 @@ public class IntrospectionHelperTest { @Test public void testGetAttributes() { - Map attrMap = getExpectedAttributes(); - Enumeration e = ih.getAttributes(); + Map> attrMap = getExpectedAttributes(); + Enumeration e = ih.getAttributes(); while (e.hasMoreElements()) { - String name = (String) e.nextElement(); - Class expect = (Class) attrMap.get(name); - assertNotNull("Support for "+name+" in IntrospectionHelperTest?", + String name = e.nextElement(); + Class expect = attrMap.get(name); + assertNotNull("Support for " + name + " in IntrospectionHelperTest?", expect); - assertEquals("Type of "+name, expect, ih.getAttributeType(name)); + assertEquals("Type of " + name, expect, ih.getAttributeType(name)); attrMap.remove(name); } attrMap.remove("name"); @@ -511,7 +511,7 @@ public class IntrospectionHelperTest { Map> actualMap = ih.getAttributeMap(); for (Map.Entry> entry : actualMap.entrySet()) { String attrName = entry.getKey(); - Class attrClass = attrMap.get(attrName); + Class attrClass = attrMap.get(attrName); assertNotNull("Support for " + attrName + " in IntrospectionHelperTest?", attrClass); assertEquals("Type of " + attrName, attrClass, entry.getValue()); @@ -568,7 +568,7 @@ public class IntrospectionHelperTest { } private void assertAttrMethod(String attrName, String methodName, - Class methodArg, Object arg, Object badArg) { + Class methodArg, Object arg, Object badArg) { Method m = ih.getAttributeMethod(attrName); assertMethod(m, methodName, methodArg, arg, badArg); } @@ -614,14 +614,14 @@ public class IntrospectionHelperTest { } public void setEleven(boolean b) { - assertTrue(!b); + assertFalse(b); } public void setTwelve(Boolean b) { - assertTrue(!b); + assertFalse(b); } - public void setThirteen(Class c) { + public void setThirteen(Class c) { assertEquals(Project.class, c); } @@ -664,7 +664,7 @@ public class IntrospectionHelperTest { @Test public void testGetExtensionPoints() { - List extensions = ih.getExtensionPoints(); + List extensions = ih.getExtensionPoints(); final int adders = 2; assertEquals("extension count", adders, extensions.size()); @@ -675,28 +675,23 @@ public class IntrospectionHelperTest { // combinatorics are too hard to check. We really only want // to ensure that the more derived Hashtable can be found // before Map. -// assertExtMethod(extensions.get(0), "add", Number.class, +// assertMethod(extensions.get(0), "add", Number.class, // new Integer(2), new Integer(3)); // addConfigured(Hashtable) should come before addConfigured(Map) - assertExtMethod(extensions.get(adders - 2), + assertMethod(extensions.get(adders - 2), "addConfigured", Hashtable.class, makeTable("key", "value"), makeTable("1", "2")); - assertExtMethod(extensions.get(adders - 1), "addConfigured", Map.class, - new HashMap(), makeTable("1", "2")); - } - - private void assertExtMethod(Object mo, String methodName, Class methodArg, - Object arg, Object badArg) { - assertMethod((Method) mo, methodName, methodArg, arg, badArg); + assertMethod(extensions.get(adders - 1), "addConfigured", Map.class, + new HashMap(), makeTable("1", "2")); } - private void assertMethod(Method m, String methodName, Class methodArg, + private void assertMethod(Method m, String methodName, Class methodArg, Object arg, Object badArg) { assertEquals("Method name", methodName, m.getName()); assertEquals("Return type", Void.TYPE, m.getReturnType()); - Class[] args = m.getParameterTypes(); + Class[] args = m.getParameterTypes(); assertEquals("Arg Count", 1, args.length); assertEquals("Arg Type", methodArg, args[0]); @@ -717,7 +712,7 @@ public class IntrospectionHelperTest { } } - public List add(List l) { + public List add(List l) { // INVALID extension point return null; } @@ -728,11 +723,11 @@ public class IntrospectionHelperTest { // assertEquals(2, n.intValue()); // } - public void add(List l, int i) { + public void add(List l, int i) { // INVALID extension point } - public void addConfigured(Map m) { + public void addConfigured(Map m) { // Valid extension point assertTrue(m.isEmpty()); } diff --git a/src/tests/junit/org/apache/tools/ant/ProjectTest.java b/src/tests/junit/org/apache/tools/ant/ProjectTest.java index 120c00940..15340b6ca 100644 --- a/src/tests/junit/org/apache/tools/ant/ProjectTest.java +++ b/src/tests/junit/org/apache/tools/ant/ProjectTest.java @@ -34,6 +34,7 @@ import org.junit.Test; import static org.apache.tools.ant.AntAssert.assertContains; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; @@ -189,7 +190,7 @@ public class ProjectTest { } catch (BuildException e) { assertEquals(message, e.getMessage()); mbl.assertEmpty(); - assertTrue(!p.getTaskDefinitions().containsKey(dummyName)); + assertFalse(p.getTaskDefinitions().containsKey(dummyName)); } } diff --git a/src/tests/junit/org/apache/tools/ant/PropertyExpansionTest.java b/src/tests/junit/org/apache/tools/ant/PropertyExpansionTest.java index c943d3e84..5b338bb5b 100644 --- a/src/tests/junit/org/apache/tools/ant/PropertyExpansionTest.java +++ b/src/tests/junit/org/apache/tools/ant/PropertyExpansionTest.java @@ -90,9 +90,8 @@ public class PropertyExpansionTest { /** * little helper method to validate stuff */ - private void assertExpandsTo(String source,String expected) { - String actual = buildRule.getProject().replaceProperties(source); - assertEquals(source,expected,actual); + private void assertExpandsTo(String source, String expected) { + assertEquals(source, expected, buildRule.getProject().replaceProperties(source)); } } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/AntStructureTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/AntStructureTest.java index 5c19bc44e..1eb24bc8a 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/AntStructureTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/AntStructureTest.java @@ -31,6 +31,7 @@ import java.util.Hashtable; import static org.apache.tools.ant.AntAssert.assertContains; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -83,31 +84,34 @@ public class AntStructureTest { public void printHead(PrintWriter out, Project p, Hashtable> tasks, Hashtable> types) { - assertTrue(!headCalled); - assertTrue(!targetCalled); - assertTrue(!tailCalled); + assertFalse(headCalled); + assertFalse(targetCalled); + assertFalse(tailCalled); assertEquals(0, elementCalled); headCalled = true; } + public void printTargetDecl(PrintWriter out) { assertTrue(headCalled); - assertTrue(!targetCalled); - assertTrue(!tailCalled); + assertFalse(targetCalled); + assertFalse(tailCalled); assertEquals(0, elementCalled); targetCalled = true; } + public void printElementDecl(PrintWriter out, Project p, String name, Class element) { assertTrue(headCalled); assertTrue(targetCalled); - assertTrue(!tailCalled); + assertFalse(tailCalled); elementCalled++; this.p = p; } + public void printTail(PrintWriter out) { assertTrue(headCalled); assertTrue(targetCalled); - assertTrue(!tailCalled); + assertFalse(tailCalled); assertTrue(elementCalled > 0); tailCalled = true; p.log(TAIL_CALLED); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java index 5fddd8062..86049f857 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java @@ -65,7 +65,7 @@ public class AntTest { try { buildRule.executeTarget("test1"); fail("recursive call"); - } catch(BuildException ex) { + } catch (BuildException ex) { //TODO assert exception message } } @@ -76,7 +76,7 @@ public class AntTest { try { buildRule.executeTarget("test2"); fail("required argument not specified"); - } catch(BuildException ex) { + } catch (BuildException ex) { //TODO assert exception message } } @@ -87,7 +87,7 @@ public class AntTest { try { buildRule.executeTarget("test1"); fail("recursive call"); - } catch(BuildException ex) { + } catch (BuildException ex) { //TODO assert exception message } } @@ -107,7 +107,7 @@ public class AntTest { try { buildRule.executeTarget("test4b"); fail("target doesn't exist"); - } catch(BuildException ex) { + } catch (BuildException ex) { //TODO assert exception message } } @@ -327,7 +327,7 @@ public class AntTest { try { buildRule.executeTarget("infinite-loop-via-depends"); fail("recursive call"); - } catch(BuildException ex) { + } catch (BuildException ex) { //TODO assert exception message } } @@ -371,7 +371,7 @@ public class AntTest { try { buildRule.executeTarget("blank-target"); fail("target name must not be empty"); - } catch(BuildException ex) { + } catch (BuildException ex) { //TODO assert exception message } } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ConcatTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ConcatTest.java index daec44bf7..58b883d60 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/ConcatTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ConcatTest.java @@ -31,6 +31,7 @@ import java.io.IOException; import static org.apache.tools.ant.AntAssert.assertContains; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -240,7 +241,7 @@ public class ConcatTest { try { buildRule.executeTarget("samefile"); fail("Build exception should have been thrown - output file same as input"); - } catch(BuildException ex) { + } catch (BuildException ex) { //TODO assert value } } @@ -261,7 +262,7 @@ public class ConcatTest { public void testmultireader() { buildRule.executeTarget("testmultireader"); assertTrue(buildRule.getLog().contains("Bye")); - assertTrue(!buildRule.getLog().contains("Hello")); + assertFalse(buildRule.getLog().contains("Hello")); } /** * Check if fixlastline works diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/CopyTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/CopyTest.java index 5b36d0553..f261289e8 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/CopyTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/CopyTest.java @@ -35,6 +35,7 @@ import java.io.IOException; import static org.apache.tools.ant.AntAssert.assertContains; 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.fail; @@ -105,7 +106,7 @@ public class CopyTest { @Test public void testFilterTest() { buildRule.executeTarget("filtertest"); - assertTrue(!buildRule.getLog().contains("loop in tokens")); + assertFalse(buildRule.getLog().contains("loop in tokens")); } @Test diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/DefaultExcludesTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/DefaultExcludesTest.java index 06ca3a261..c1392d2c2 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/DefaultExcludesTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/DefaultExcludesTest.java @@ -159,8 +159,11 @@ public class DefaultExcludesTest { assertEquals(message + " : string array length match", expected.length, actual.length); for (String element : expected) { boolean found = false; - for (int i = 0; !found && i < actual.length; i++) { - found |= element.equals(actual[i]); + for (String member : actual) { + found |= element.equals(member); + if (found) { + break; + } } assertTrue(message + " : didn't find element " + element + " in array match", found); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/EchoTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/EchoTest.java index 6f0c7a98e..67715dc87 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/EchoTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/EchoTest.java @@ -68,7 +68,7 @@ public class EchoTest { echo.setEncoding("UTF-8"); echo.execute(); String x = FileUtils.readFully(new InputStreamReader(new FileInputStream(removeThis), "UTF-8")); - assertEquals(x,"\u00e4\u00a9"); + assertEquals(x, "\u00e4\u00a9"); } @After diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java index 4b8efa33f..80a4ac3bb 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java @@ -28,6 +28,7 @@ import org.junit.internal.AssumptionViolatedException; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; /** @@ -127,7 +128,7 @@ public class ExecuteWatchdogTest { watchdog.start(process); int retCode = process.waitFor(); assertFalse("process should not have been killed", watchdog.killedProcess()); - assertTrue("return code is invalid: " + retCode, retCode!=0); + assertNotEquals("return code is invalid: " + retCode, 0, retCode); } @Test @@ -139,7 +140,7 @@ public class ExecuteWatchdogTest { Thread thread = new Thread(() -> { try { process.waitFor(); - } catch(InterruptedException e) { + } catch (InterruptedException e) { // not very nice but will do the job throw new AssumptionViolatedException("process interrupted in thread", e); } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/JarTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/JarTest.java index 86b18fdb8..3ef9b3fad 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/JarTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/JarTest.java @@ -300,7 +300,7 @@ public class JarTest { } assertTrue(foundSub); - assertTrue(!foundSubFoo); + assertFalse(foundSubFoo); assertTrue(foundFoo); } } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java index 247d91946..3dbcdf1b4 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java @@ -37,6 +37,7 @@ import org.junit.Test; import static org.apache.tools.ant.AntAssert.assertContains; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -389,7 +390,7 @@ public class ManifestTest { buildRule.executeTarget("testUpdate"); Manifest mf = getManifest(new File(outDir, "mftest.mf")); assertNotNull(mf); - assertTrue(!Manifest.getDefaultManifest().equals(mf)); + assertNotEquals(Manifest.getDefaultManifest(), mf); String mfAsString = mf.toString(); assertNotNull(mfAsString); assertTrue(mfAsString.startsWith("Manifest-Version: 2.0")); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/MoveTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/MoveTest.java index c09b6ba59..529d2204f 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/MoveTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/MoveTest.java @@ -28,6 +28,7 @@ import java.io.File; import java.io.IOException; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; /** @@ -69,14 +70,14 @@ public class MoveTest { buildRule.executeTarget("testDirectoryRemoval"); String output = buildRule.getProject().getProperty("output"); - assertTrue(!new File(output,"E/B/1").exists()); + assertFalse(new File(output, "E/B/1").exists()); assertTrue(new File(output, "E/C/2").exists()); - assertTrue(new File(output,"E/D/3").exists()); - assertTrue(new File(output,"A/B/1").exists()); - assertTrue(!new File(output,"A/C/2").exists()); - assertTrue(!new File(output,"A/D/3").exists()); - assertTrue(!new File(output,"A/C").exists()); - assertTrue(!new File(output,"A/D").exists()); + assertTrue(new File(output, "E/D/3").exists()); + assertTrue(new File(output, "A/B/1").exists()); + assertFalse(new File(output, "A/C/2").exists()); + assertFalse(new File(output, "A/D/3").exists()); + assertFalse(new File(output, "A/C").exists()); + assertFalse(new File(output, "A/D").exists()); } /** Bugzilla Report 18886 */ @@ -84,10 +85,10 @@ public class MoveTest { public void testDirectoryRetaining() { buildRule.executeTarget("testDirectoryRetaining"); String output = buildRule.getProject().getProperty("output"); - assertTrue(new File(output,"E").exists()); - assertTrue(new File(output,"E/1").exists()); - assertTrue(!new File(output,"A/1").exists()); - assertTrue(new File(output,"A").exists()); + assertTrue(new File(output, "E").exists()); + assertTrue(new File(output, "E/1").exists()); + assertFalse(new File(output, "A/1").exists()); + assertTrue(new File(output, "A").exists()); } @Test @@ -103,21 +104,21 @@ public class MoveTest { private void testCompleteDirectoryMove(String target) { buildRule.executeTarget(target); String output = buildRule.getProject().getProperty("output"); - assertTrue(new File(output,"E").exists()); - assertTrue(new File(output,"E/1").exists()); - assertTrue(!new File(output,"A/1").exists()); + assertTrue(new File(output, "E").exists()); + assertTrue(new File(output, "E/1").exists()); + assertFalse(new File(output, "A/1").exists()); // swallows the basedir, it seems - //assertTrue(!new File(getOutputDir(),"A").exists()); + //assertFalse(new File(getOutputDir(), "A").exists()); } @Test public void testPathElementMove() { buildRule.executeTarget("testPathElementMove"); String output = buildRule.getProject().getProperty("output"); - assertTrue(new File(output,"E").exists()); - assertTrue(new File(output,"E/1").exists()); - assertTrue(!new File(output,"A/1").exists()); - assertTrue(new File(output,"A").exists()); + assertTrue(new File(output, "E").exists()); + assertTrue(new File(output, "E/1").exists()); + assertFalse(new File(output, "A/1").exists()); + assertTrue(new File(output, "A").exists()); } @Test diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/SQLExecTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/SQLExecTest.java index f5b72c82c..3bd5b0b44 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/SQLExecTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/SQLExecTest.java @@ -34,6 +34,7 @@ import org.junit.Test; import static org.apache.tools.ant.AntAssert.assertContains; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -72,7 +73,7 @@ public class SQLExecTest { @Test public void testDriverCaching() { SQLExec sql = createTask(getProperties(NULL)); - assertTrue(!SQLExec.getLoaderMap().containsKey(NULL_DRIVER)); + assertFalse(SQLExec.getLoaderMap().containsKey(NULL_DRIVER)); try { sql.execute(); fail("BuildException should have been thrown"); 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 a73854ae3..6a0a8ad8e 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java @@ -109,7 +109,7 @@ public class SignJarTest { try { buildRule.executeTarget("testTsaLocalhost"); fail("Should have thrown exception - no TSA at localhost:0"); - } catch(BuildException ex) { + } catch (BuildException ex) { assertEquals("jarsigner returned: 1", ex.getMessage()); } } 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 b296b7ba5..cb696f113 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/SyncTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/SyncTest.java @@ -24,6 +24,7 @@ import org.junit.Rule; import org.junit.Test; import static org.apache.tools.ant.AntAssert.assertContains; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; public class SyncTest { @@ -41,7 +42,7 @@ public class SyncTest { buildRule.executeTarget("simplecopy"); String d = buildRule.getProject().getProperty("dest") + "/a/b/c/d"; assertFileIsPresent(d); - assertTrue(!buildRule.getFullLog().contains("dangling")); + assertFalse(buildRule.getFullLog().contains("dangling")); } @Test @@ -51,7 +52,7 @@ public class SyncTest { assertFileIsNotPresent(d); String c = buildRule.getProject().getProperty("dest") + "/a/b/c"; assertFileIsNotPresent(c); - assertTrue(!buildRule.getFullLog().contains("dangling")); + assertFalse(buildRule.getFullLog().contains("dangling")); } @Test @@ -61,7 +62,7 @@ public class SyncTest { assertFileIsNotPresent(d); String c = buildRule.getProject().getProperty("dest") + "/a/b/c"; assertFileIsPresent(c); - assertTrue(!buildRule.getFullLog().contains("dangling")); + assertFalse(buildRule.getFullLog().contains("dangling")); } @Test @@ -123,7 +124,7 @@ public class SyncTest { assertFileIsPresent(d); String f = buildRule.getProject().getProperty("dest") + "/e/f"; assertFileIsPresent(f); - assertTrue(!buildRule.getFullLog().contains("Removing orphan file:")); + assertFalse(buildRule.getFullLog().contains("Removing orphan file:")); } @Test @@ -133,7 +134,7 @@ public class SyncTest { assertFileIsPresent(d); String f = buildRule.getProject().getProperty("dest") + "/e/f"; assertFileIsPresent(f); - assertTrue(!buildRule.getFullLog().contains("Removing orphan file:")); + assertFalse(buildRule.getFullLog().contains("Removing orphan file:")); } public void assertFileIsPresent(String f) { diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/condition/ContainsTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/condition/ContainsTest.java index a45b511a5..337b3b701 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/condition/ContainsTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/condition/ContainsTest.java @@ -20,6 +20,7 @@ package org.apache.tools.ant.taskdefs.condition; import org.junit.Test; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; /** @@ -33,7 +34,7 @@ public class ContainsTest { Contains con = new Contains(); con.setString("abc"); con.setSubstring("A"); - assertTrue(!con.eval()); + assertFalse(con.eval()); con.setCasesensitive(false); assertTrue(con.eval()); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/condition/EqualsTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/condition/EqualsTest.java index 5f9b996ac..b8c40b3c6 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/condition/EqualsTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/condition/EqualsTest.java @@ -20,6 +20,7 @@ package org.apache.tools.ant.taskdefs.condition; import org.junit.Test; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; /** @@ -33,7 +34,7 @@ public class EqualsTest { Equals eq = new Equals(); eq.setArg1("a"); eq.setArg2(" a"); - assertTrue(!eq.eval()); + assertFalse(eq.eval()); eq.setTrim(true); assertTrue(eq.eval()); @@ -47,7 +48,7 @@ public class EqualsTest { Equals eq = new Equals(); eq.setArg1("a"); eq.setArg2("A"); - assertTrue(!eq.eval()); + assertFalse(eq.eval()); eq.setCasesensitive(false); assertTrue(eq.eval()); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsReferenceTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsReferenceTest.java index 01b6b47c8..e8e178be7 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsReferenceTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsReferenceTest.java @@ -54,7 +54,7 @@ public class IsReferenceTest { try { buildRule.executeTarget("isreference-incomplete"); fail("Build exception expected: refid attirbute has been omitted"); - } catch(BuildException ex) { + } catch (BuildException ex) { assertEquals("No reference specified for isreference condition", ex.getMessage()); } } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/condition/ParserSupportsTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/condition/ParserSupportsTest.java index 271c19b97..c5c2f0428 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/condition/ParserSupportsTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/condition/ParserSupportsTest.java @@ -46,7 +46,7 @@ public class ParserSupportsTest { try { buildRule.executeTarget("testEmpty"); fail("Build exception expected: " + ParserSupports.ERROR_NO_ATTRIBUTES); - } catch(BuildException ex) { + } catch (BuildException ex) { assertEquals(ParserSupports.ERROR_NO_ATTRIBUTES, ex.getMessage()); } } @@ -56,7 +56,7 @@ public class ParserSupportsTest { try { buildRule.executeTarget("testBoth"); fail("Build exception expected: " + ParserSupports.ERROR_BOTH_ATTRIBUTES); - } catch(BuildException ex) { + } catch (BuildException ex) { assertEquals(ParserSupports.ERROR_BOTH_ATTRIBUTES, ex.getMessage()); } } @@ -71,7 +71,7 @@ public class ParserSupportsTest { try { buildRule.executeTarget("testPropertyNoValue"); fail("Build exception expected: " + ParserSupports.ERROR_NO_VALUE); - } catch(BuildException ex) { + } catch (BuildException ex) { assertEquals(ParserSupports.ERROR_NO_VALUE, ex.getMessage()); } } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/email/EmailTaskTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/email/EmailTaskTest.java index 6363f90d0..f3dc62228 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/email/EmailTaskTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/email/EmailTaskTest.java @@ -45,7 +45,7 @@ public class EmailTaskTest { try { buildRule.executeTarget("test1"); fail("Build exception expected: SMTP auth only possibly with MIME mail"); - } catch(BuildException ex) { + } catch (BuildException ex) { //TODO assert exception message } } @@ -55,7 +55,7 @@ public class EmailTaskTest { try { buildRule.executeTarget("test2"); fail("Build exception expected: SSL only possibly with MIME mail"); - } catch(BuildException ex) { + } catch (BuildException ex) { //TODO assert exception message } } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PvcsTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PvcsTest.java index 29b2685a9..c89ccd09b 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PvcsTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PvcsTest.java @@ -72,7 +72,7 @@ public class PvcsTest { buildRule.executeTarget("test6"); fail("Failed executing: /never/heard/of/a/directory/structure/like/this/pcli lvf -z " + "-aw -pr//ct4serv2/pvcs/monitor /. Exception: /never/heard/of/a/directory/structure/like/this/pcli: not found"); - } catch(BuildException ex) { + } catch (BuildException ex) { //TODO assert exception message } } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java index f0b32b098..3e9c25866 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java @@ -165,7 +165,7 @@ public class XmlValidateTest { try { buildRule.executeTarget("testUtf8"); fail("Invalid characters in file"); - } catch(BuildException ex) { + } catch (BuildException ex) { //TODO assert exception message } } @@ -181,7 +181,7 @@ public class XmlValidateTest { try { buildRule.executeTarget("testProperty.invalidXML"); fail("XML file does not satisfy schema"); - } catch(BuildException ex) { + } catch (BuildException ex) { //TODO assert exception message } } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java index c4aec20c1..66b488283 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java @@ -50,7 +50,7 @@ public class XsltTest { try { buildRule.executeTarget("testCatchNoDtd"); fail("Expected failure"); - } catch(BuildException ex) { + } catch (BuildException ex) { //TODO assert exception message } } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/script/ScriptDefTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/script/ScriptDefTest.java index 7dd9e60c6..7b2d327c8 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/script/ScriptDefTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/script/ScriptDefTest.java @@ -17,7 +17,6 @@ */ package org.apache.tools.ant.taskdefs.optional.script; -import org.apache.tools.ant.AntAssert; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildFileRule; import org.apache.tools.ant.Project; @@ -28,6 +27,7 @@ import org.junit.Test; import java.io.File; +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; @@ -67,8 +67,8 @@ public class ScriptDefTest { try { buildRule.executeTarget("nolang"); fail("Absence of language attribute not detected"); - } catch(BuildException ex) { - AntAssert.assertContains("requires a language attribute", ex.getMessage()); + } catch (BuildException ex) { + assertContains("requires a language attribute", ex.getMessage()); } } @@ -77,8 +77,8 @@ public class ScriptDefTest { try { buildRule.executeTarget("noname"); fail("Absence of name attribute not detected"); - } catch(BuildException ex) { - AntAssert.assertContains("scriptdef requires a name attribute", ex.getMessage()); + } catch (BuildException ex) { + assertContains("scriptdef requires a name attribute", ex.getMessage()); } } @@ -108,8 +108,8 @@ public class ScriptDefTest { try { buildRule.executeTarget("exception"); fail("Should have thrown an exception in the script"); - } catch(BuildException ex) { - AntAssert.assertContains("TypeError", ex.getMessage()); + } catch (BuildException ex) { + assertContains("TypeError", ex.getMessage()); } } @@ -126,8 +126,8 @@ public class ScriptDefTest { try { buildRule.executeTarget("doubleAttributeDef"); fail("Should have detected duplicate attirbute definition"); - } catch(BuildException ex) { - AntAssert.assertContains("attr1 attribute more than once", ex.getMessage()); + } catch (BuildException ex) { + assertContains("attr1 attribute more than once", ex.getMessage()); } } @@ -156,7 +156,7 @@ public class ScriptDefTest { fail("should have failed with reader's encoding [" + readerEncoding + "] different from the writer's encoding [" + buildRule.getProject().getProperty("useSrcAndEncoding.encoding") + "]"); - } catch(BuildException e) { + } catch (BuildException e) { assertTrue(e.getMessage().matches( "expected but was ")); } diff --git a/src/tests/junit/org/apache/tools/ant/types/optional/ScriptSelectorTest.java b/src/tests/junit/org/apache/tools/ant/types/optional/ScriptSelectorTest.java index 304d6d090..a75a66353 100644 --- a/src/tests/junit/org/apache/tools/ant/types/optional/ScriptSelectorTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/optional/ScriptSelectorTest.java @@ -44,7 +44,7 @@ public class ScriptSelectorTest { try { buildRule.executeTarget("testNolanguage"); fail("Absence of language attribute not detected"); - } catch(BuildException ex) { + } catch (BuildException ex) { assertContains("script language must be specified", ex.getMessage()); } diff --git a/src/tests/junit/org/apache/tools/ant/util/CollectionUtilsTest.java b/src/tests/junit/org/apache/tools/ant/util/CollectionUtilsTest.java index 9a4d50b56..a1aa45f5e 100644 --- a/src/tests/junit/org/apache/tools/ant/util/CollectionUtilsTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/CollectionUtilsTest.java @@ -25,6 +25,7 @@ import java.util.Vector; import org.junit.Test; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; /** @@ -36,8 +37,8 @@ public class CollectionUtilsTest { @Test public void testVectorEquals() { - assertTrue(!CollectionUtils.equals(null, new Vector())); - assertTrue(!CollectionUtils.equals(new Vector(), null)); + assertFalse(CollectionUtils.equals(null, new Vector())); + assertFalse(CollectionUtils.equals(new Vector(), null)); assertTrue(CollectionUtils.equals(new Vector(), new Vector())); Vector v1 = new Vector<>(); Stack s2 = new Stack<>(); @@ -46,27 +47,27 @@ public class CollectionUtilsTest { assertTrue(CollectionUtils.equals(v1, s2)); assertTrue(CollectionUtils.equals(s2, v1)); v1.addElement("bar"); - assertTrue(!CollectionUtils.equals(v1, s2)); - assertTrue(!CollectionUtils.equals(s2, v1)); + assertFalse(CollectionUtils.equals(v1, s2)); + assertFalse(CollectionUtils.equals(s2, v1)); s2.push("bar"); assertTrue(CollectionUtils.equals(v1, s2)); assertTrue(CollectionUtils.equals(s2, v1)); s2.push("baz"); - assertTrue(!CollectionUtils.equals(v1, s2)); - assertTrue(!CollectionUtils.equals(s2, v1)); + assertFalse(CollectionUtils.equals(v1, s2)); + assertFalse(CollectionUtils.equals(s2, v1)); v1.addElement("baz"); assertTrue(CollectionUtils.equals(v1, s2)); assertTrue(CollectionUtils.equals(s2, v1)); v1.addElement("zyzzy"); s2.push("zyzzy2"); - assertTrue(!CollectionUtils.equals(v1, s2)); - assertTrue(!CollectionUtils.equals(s2, v1)); + assertFalse(CollectionUtils.equals(v1, s2)); + assertFalse(CollectionUtils.equals(s2, v1)); } @Test public void testDictionaryEquals() { - assertTrue(!CollectionUtils.equals(null, new Hashtable())); - assertTrue(!CollectionUtils.equals(new Hashtable(), null)); + assertFalse(CollectionUtils.equals(null, new Hashtable())); + assertFalse(CollectionUtils.equals(new Hashtable(), null)); assertTrue(CollectionUtils.equals(new Hashtable(), new Properties())); Hashtable h1 = new Hashtable<>(); Properties p2 = new Properties(); @@ -75,28 +76,28 @@ public class CollectionUtilsTest { assertTrue(CollectionUtils.equals(h1, p2)); assertTrue(CollectionUtils.equals(p2, h1)); h1.put("bar", ""); - assertTrue(!CollectionUtils.equals(h1, p2)); - assertTrue(!CollectionUtils.equals(p2, h1)); + assertFalse(CollectionUtils.equals(h1, p2)); + assertFalse(CollectionUtils.equals(p2, h1)); p2.put("bar", ""); assertTrue(CollectionUtils.equals(h1, p2)); assertTrue(CollectionUtils.equals(p2, h1)); p2.put("baz", ""); - assertTrue(!CollectionUtils.equals(h1, p2)); - assertTrue(!CollectionUtils.equals(p2, h1)); + assertFalse(CollectionUtils.equals(h1, p2)); + assertFalse(CollectionUtils.equals(p2, h1)); h1.put("baz", ""); assertTrue(CollectionUtils.equals(h1, p2)); assertTrue(CollectionUtils.equals(p2, h1)); h1.put("zyzzy", ""); p2.put("zyzzy2", ""); - assertTrue(!CollectionUtils.equals(h1, p2)); - assertTrue(!CollectionUtils.equals(p2, h1)); + assertFalse(CollectionUtils.equals(h1, p2)); + assertFalse(CollectionUtils.equals(p2, h1)); p2.put("zyzzy", ""); h1.put("zyzzy2", ""); assertTrue(CollectionUtils.equals(h1, p2)); assertTrue(CollectionUtils.equals(p2, h1)); h1.put("dada", "1"); p2.put("dada", "2"); - assertTrue(!CollectionUtils.equals(h1, p2)); - assertTrue(!CollectionUtils.equals(p2, h1)); + assertFalse(CollectionUtils.equals(h1, p2)); + assertFalse(CollectionUtils.equals(p2, h1)); } } diff --git a/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java b/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java index 198723675..3bdede4c3 100644 --- a/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java @@ -413,7 +413,7 @@ public class FileUtilsTest { @Test public void testCreateNewFile() throws IOException { removeThis = new File("dummy"); - assertTrue(!removeThis.exists()); + assertFalse(removeThis.exists()); FILE_UTILS.createNewFile(removeThis); assertTrue(removeThis.exists()); } diff --git a/src/tests/junit/org/apache/tools/ant/util/LayoutPreservingPropertiesTest.java b/src/tests/junit/org/apache/tools/ant/util/LayoutPreservingPropertiesTest.java index 409f755bf..f12f9aaa7 100644 --- a/src/tests/junit/org/apache/tools/ant/util/LayoutPreservingPropertiesTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/LayoutPreservingPropertiesTest.java @@ -126,12 +126,12 @@ public class LayoutPreservingPropertiesTest { // and check that the resulting file looks okay String s = readFile(tmp); - assertTrue(!s.contains("\\ prop\\ one\\ =\\ \\ leading and" + assertFalse(s.contains("\\ prop\\ one\\ =\\ \\ leading and" + " trailing spaces ")); assertTrue(s.contains("\\ prop\\ one\\ =new one")); - assertTrue(!s.contains("prop\\ttwo=contains\\ttab")); + assertFalse(s.contains("prop\\ttwo=contains\\ttab")); assertTrue(s.contains("prop\\ttwo=new two")); - assertTrue(!s.contains("prop\\nthree=contains\\nnewline")); + assertFalse(s.contains("prop\\nthree=contains\\nnewline")); assertTrue(s.contains("prop\\nthree=new three")); } @@ -291,10 +291,10 @@ public class LayoutPreservingPropertiesTest { assertTrue(s.contains("alpha=new value for alpha")); assertTrue(s.contains("beta=new value for beta")); - assertTrue(!s.contains("prop\\:seven=contains\\:colon")); - assertTrue(!s.contains("prop\\=eight=contains\\=equals")); - assertTrue(!s.contains("alpha:set with a colon")); - assertTrue(!s.contains("beta set with a space")); + assertFalse(s.contains("prop\\:seven=contains\\:colon")); + assertFalse(s.contains("prop\\=eight=contains\\=equals")); + assertFalse(s.contains("alpha:set with a colon")); + assertFalse(s.contains("beta set with a space")); } private static String readFile(File f) throws IOException { diff --git a/src/tests/junit/org/apache/tools/ant/util/XMLFragmentTest.java b/src/tests/junit/org/apache/tools/ant/util/XMLFragmentTest.java index 576ec770c..3967f2572 100644 --- a/src/tests/junit/org/apache/tools/ant/util/XMLFragmentTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/XMLFragmentTest.java @@ -66,7 +66,7 @@ public class XMLFragmentTest { assertEquals(Node.ELEMENT_NODE, nl.item(0).getNodeType()); Element child1 = (Element) nl.item(0); assertEquals("child1", child1.getTagName()); - assertTrue(!child1.hasAttributes()); + assertFalse(child1.hasAttributes()); NodeList nl2 = child1.getChildNodes(); assertEquals(1, nl2.getLength()); assertEquals(Node.TEXT_NODE, nl2.item(0).getNodeType()); @@ -83,7 +83,7 @@ public class XMLFragmentTest { assertEquals(Node.ELEMENT_NODE, nl.item(2).getNodeType()); Element child3 = (Element) nl.item(2); assertEquals("child3", child3.getTagName()); - assertTrue(!child3.hasAttributes()); + assertFalse(child3.hasAttributes()); nl2 = child3.getChildNodes(); assertEquals(1, nl2.getLength()); assertEquals(Node.ELEMENT_NODE, nl2.item(0).getNodeType()); diff --git a/src/tests/junit/org/apache/tools/ant/util/facade/FacadeTaskHelperTest.java b/src/tests/junit/org/apache/tools/ant/util/facade/FacadeTaskHelperTest.java index 622095511..d75cc0523 100644 --- a/src/tests/junit/org/apache/tools/ant/util/facade/FacadeTaskHelperTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/facade/FacadeTaskHelperTest.java @@ -58,7 +58,7 @@ public class FacadeTaskHelperTest { fth.setMagicValue("foo"); assertTrue("magic has been set", fth.hasBeenSet()); fth.setMagicValue(null); - assertTrue(!fth.hasBeenSet()); + assertFalse(fth.hasBeenSet()); fth.setImplementation("baz"); assertTrue("set explicitly", fth.hasBeenSet()); }