Browse Source

Checkstyle and simplify assertions

master
Gintas Grigelionis 7 years ago
parent
commit
4a242817bd
34 changed files with 150 additions and 138 deletions
  1. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/EchoXML.java
  2. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/launcher/VmsCommandLauncher.java
  3. +1
    -1
      src/tests/junit/org/apache/tools/ant/DispatchTaskTest.java
  4. +24
    -29
      src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java
  5. +2
    -1
      src/tests/junit/org/apache/tools/ant/ProjectTest.java
  6. +2
    -3
      src/tests/junit/org/apache/tools/ant/PropertyExpansionTest.java
  7. +11
    -7
      src/tests/junit/org/apache/tools/ant/taskdefs/AntStructureTest.java
  8. +6
    -6
      src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java
  9. +3
    -2
      src/tests/junit/org/apache/tools/ant/taskdefs/ConcatTest.java
  10. +2
    -1
      src/tests/junit/org/apache/tools/ant/taskdefs/CopyTest.java
  11. +5
    -2
      src/tests/junit/org/apache/tools/ant/taskdefs/DefaultExcludesTest.java
  12. +1
    -1
      src/tests/junit/org/apache/tools/ant/taskdefs/EchoTest.java
  13. +3
    -2
      src/tests/junit/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java
  14. +1
    -1
      src/tests/junit/org/apache/tools/ant/taskdefs/JarTest.java
  15. +2
    -1
      src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java
  16. +20
    -19
      src/tests/junit/org/apache/tools/ant/taskdefs/MoveTest.java
  17. +2
    -1
      src/tests/junit/org/apache/tools/ant/taskdefs/SQLExecTest.java
  18. +1
    -1
      src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java
  19. +6
    -5
      src/tests/junit/org/apache/tools/ant/taskdefs/SyncTest.java
  20. +2
    -1
      src/tests/junit/org/apache/tools/ant/taskdefs/condition/ContainsTest.java
  21. +3
    -2
      src/tests/junit/org/apache/tools/ant/taskdefs/condition/EqualsTest.java
  22. +1
    -1
      src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsReferenceTest.java
  23. +3
    -3
      src/tests/junit/org/apache/tools/ant/taskdefs/condition/ParserSupportsTest.java
  24. +2
    -2
      src/tests/junit/org/apache/tools/ant/taskdefs/email/EmailTaskTest.java
  25. +1
    -1
      src/tests/junit/org/apache/tools/ant/taskdefs/optional/PvcsTest.java
  26. +2
    -2
      src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java
  27. +1
    -1
      src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java
  28. +10
    -10
      src/tests/junit/org/apache/tools/ant/taskdefs/optional/script/ScriptDefTest.java
  29. +1
    -1
      src/tests/junit/org/apache/tools/ant/types/optional/ScriptSelectorTest.java
  30. +19
    -18
      src/tests/junit/org/apache/tools/ant/util/CollectionUtilsTest.java
  31. +1
    -1
      src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java
  32. +7
    -7
      src/tests/junit/org/apache/tools/ant/util/LayoutPreservingPropertiesTest.java
  33. +2
    -2
      src/tests/junit/org/apache/tools/ant/util/XMLFragmentTest.java
  34. +1
    -1
      src/tests/junit/org/apache/tools/ant/util/facade/FacadeTaskHelperTest.java

+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/EchoXML.java View File

@@ -57,7 +57,7 @@ public class EchoXML extends XMLFragment {


/** /**
* Set the namespace policy for the xml file * 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 * @see org.apache.tools.ant.util.DOMElementWriter.XmlNamespacePolicy
*/ */
public void setNamespacePolicy(NamespacePolicy n) { public void setNamespacePolicy(NamespacePolicy n) {


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/launcher/VmsCommandLauncher.java View File

@@ -125,7 +125,7 @@ public class VmsCommandLauncher extends Java13CommandLauncher {
new Thread(() -> { new Thread(() -> {
try { try {
p.waitFor(); p.waitFor();
} catch(InterruptedException e) {
} catch (InterruptedException e) {
// ignore // ignore
} }
FileUtils.delete(f); FileUtils.delete(f);


+ 1
- 1
src/tests/junit/org/apache/tools/ant/DispatchTaskTest.java View File

@@ -39,7 +39,7 @@ public class DispatchTaskTest {
try { try {
buildRule.executeTarget("disp"); buildRule.executeTarget("disp");
fail("BuildException should have been thrown"); 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 //FIXME the previous method used here ignored the build exception - what are we trying to test
} }
} }


+ 24
- 29
src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java View File

@@ -259,12 +259,12 @@ public class IntrospectionHelperTest {
} }


private void assertElemMethod(String elemName, String methodName, private void assertElemMethod(String elemName, String methodName,
Class returnType, Class methodArg) {
Class<?> returnType, Class<?> methodArg) {
Method m = ih.getElementMethod(elemName); Method m = ih.getElementMethod(elemName);
assertEquals("Method name", methodName, m.getName()); 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()); assertEquals("Return type", expectedReturnType, m.getReturnType());
Class[] args = m.getParameterTypes();
Class<?>[] args = m.getParameterTypes();
if (methodArg != null) { if (methodArg != null) {
assertEquals("Arg Count", 1, args.length); assertEquals("Arg Count", 1, args.length);
assertEquals("Arg Type", methodArg, args[0]); assertEquals("Arg Type", methodArg, args[0]);
@@ -491,14 +491,14 @@ public class IntrospectionHelperTest {


@Test @Test
public void testGetAttributes() { public void testGetAttributes() {
Map attrMap = getExpectedAttributes();
Enumeration e = ih.getAttributes();
Map<String, Class<?>> attrMap = getExpectedAttributes();
Enumeration<String> e = ih.getAttributes();
while (e.hasMoreElements()) { 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); expect);
assertEquals("Type of "+name, expect, ih.getAttributeType(name));
assertEquals("Type of " + name, expect, ih.getAttributeType(name));
attrMap.remove(name); attrMap.remove(name);
} }
attrMap.remove("name"); attrMap.remove("name");
@@ -511,7 +511,7 @@ public class IntrospectionHelperTest {
Map<String, Class<?>> actualMap = ih.getAttributeMap(); Map<String, Class<?>> actualMap = ih.getAttributeMap();
for (Map.Entry<String, Class<?>> entry : actualMap.entrySet()) { for (Map.Entry<String, Class<?>> entry : actualMap.entrySet()) {
String attrName = entry.getKey(); String attrName = entry.getKey();
Class attrClass = attrMap.get(attrName);
Class<?> attrClass = attrMap.get(attrName);
assertNotNull("Support for " + attrName + assertNotNull("Support for " + attrName +
" in IntrospectionHelperTest?", attrClass); " in IntrospectionHelperTest?", attrClass);
assertEquals("Type of " + attrName, attrClass, entry.getValue()); assertEquals("Type of " + attrName, attrClass, entry.getValue());
@@ -568,7 +568,7 @@ public class IntrospectionHelperTest {
} }


private void assertAttrMethod(String attrName, String methodName, private void assertAttrMethod(String attrName, String methodName,
Class methodArg, Object arg, Object badArg) {
Class<?> methodArg, Object arg, Object badArg) {
Method m = ih.getAttributeMethod(attrName); Method m = ih.getAttributeMethod(attrName);
assertMethod(m, methodName, methodArg, arg, badArg); assertMethod(m, methodName, methodArg, arg, badArg);
} }
@@ -614,14 +614,14 @@ public class IntrospectionHelperTest {
} }


public void setEleven(boolean b) { public void setEleven(boolean b) {
assertTrue(!b);
assertFalse(b);
} }


public void setTwelve(Boolean b) { public void setTwelve(Boolean b) {
assertTrue(!b);
assertFalse(b);
} }


public void setThirteen(Class c) {
public void setThirteen(Class<?> c) {
assertEquals(Project.class, c); assertEquals(Project.class, c);
} }


@@ -664,7 +664,7 @@ public class IntrospectionHelperTest {


@Test @Test
public void testGetExtensionPoints() { public void testGetExtensionPoints() {
List extensions = ih.getExtensionPoints();
List<Method> extensions = ih.getExtensionPoints();
final int adders = 2; final int adders = 2;
assertEquals("extension count", adders, extensions.size()); assertEquals("extension count", adders, extensions.size());


@@ -675,28 +675,23 @@ public class IntrospectionHelperTest {
// combinatorics are too hard to check. We really only want // combinatorics are too hard to check. We really only want
// to ensure that the more derived Hashtable can be found // to ensure that the more derived Hashtable can be found
// before Map. // before Map.
// assertExtMethod(extensions.get(0), "add", Number.class,
// assertMethod(extensions.get(0), "add", Number.class,
// new Integer(2), new Integer(3)); // new Integer(2), new Integer(3));


// addConfigured(Hashtable) should come before addConfigured(Map) // addConfigured(Hashtable) should come before addConfigured(Map)
assertExtMethod(extensions.get(adders - 2),
assertMethod(extensions.get(adders - 2),
"addConfigured", Hashtable.class, "addConfigured", Hashtable.class,
makeTable("key", "value"), makeTable("1", "2")); 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<String, String>(), 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) { Object arg, Object badArg) {
assertEquals("Method name", methodName, m.getName()); assertEquals("Method name", methodName, m.getName());
assertEquals("Return type", Void.TYPE, m.getReturnType()); assertEquals("Return type", Void.TYPE, m.getReturnType());
Class[] args = m.getParameterTypes();
Class<?>[] args = m.getParameterTypes();
assertEquals("Arg Count", 1, args.length); assertEquals("Arg Count", 1, args.length);
assertEquals("Arg Type", methodArg, args[0]); assertEquals("Arg Type", methodArg, args[0]);


@@ -717,7 +712,7 @@ public class IntrospectionHelperTest {
} }
} }


public List add(List l) {
public List<Object> add(List l) {
// INVALID extension point // INVALID extension point
return null; return null;
} }
@@ -728,11 +723,11 @@ public class IntrospectionHelperTest {
// assertEquals(2, n.intValue()); // assertEquals(2, n.intValue());
// } // }


public void add(List l, int i) {
public void add(List<Object> l, int i) {
// INVALID extension point // INVALID extension point
} }


public void addConfigured(Map m) {
public void addConfigured(Map<Object, Object> m) {
// Valid extension point // Valid extension point
assertTrue(m.isEmpty()); assertTrue(m.isEmpty());
} }


+ 2
- 1
src/tests/junit/org/apache/tools/ant/ProjectTest.java View File

@@ -34,6 +34,7 @@ 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.assertFalse;
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.assertSame; import static org.junit.Assert.assertSame;
@@ -189,7 +190,7 @@ public class ProjectTest {
} catch (BuildException e) { } catch (BuildException e) {
assertEquals(message, e.getMessage()); assertEquals(message, e.getMessage());
mbl.assertEmpty(); mbl.assertEmpty();
assertTrue(!p.getTaskDefinitions().containsKey(dummyName));
assertFalse(p.getTaskDefinitions().containsKey(dummyName));
} }
} }




+ 2
- 3
src/tests/junit/org/apache/tools/ant/PropertyExpansionTest.java View File

@@ -90,9 +90,8 @@ public class PropertyExpansionTest {
/** /**
* little helper method to validate stuff * 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));
} }


} }

+ 11
- 7
src/tests/junit/org/apache/tools/ant/taskdefs/AntStructureTest.java View File

@@ -31,6 +31,7 @@ import java.util.Hashtable;


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.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;


@@ -83,31 +84,34 @@ public class AntStructureTest {
public void printHead(PrintWriter out, Project p, public void printHead(PrintWriter out, Project p,
Hashtable<String, Class<?>> tasks, Hashtable<String, Class<?>> tasks,
Hashtable<String, Class<?>> types) { Hashtable<String, Class<?>> types) {
assertTrue(!headCalled);
assertTrue(!targetCalled);
assertTrue(!tailCalled);
assertFalse(headCalled);
assertFalse(targetCalled);
assertFalse(tailCalled);
assertEquals(0, elementCalled); assertEquals(0, elementCalled);
headCalled = true; headCalled = true;
} }

public void printTargetDecl(PrintWriter out) { public void printTargetDecl(PrintWriter out) {
assertTrue(headCalled); assertTrue(headCalled);
assertTrue(!targetCalled);
assertTrue(!tailCalled);
assertFalse(targetCalled);
assertFalse(tailCalled);
assertEquals(0, elementCalled); 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) {
assertTrue(headCalled); assertTrue(headCalled);
assertTrue(targetCalled); assertTrue(targetCalled);
assertTrue(!tailCalled);
assertFalse(tailCalled);
elementCalled++; elementCalled++;
this.p = p; this.p = p;
} }

public void printTail(PrintWriter out) { public void printTail(PrintWriter out) {
assertTrue(headCalled); assertTrue(headCalled);
assertTrue(targetCalled); assertTrue(targetCalled);
assertTrue(!tailCalled);
assertFalse(tailCalled);
assertTrue(elementCalled > 0); assertTrue(elementCalled > 0);
tailCalled = true; tailCalled = true;
p.log(TAIL_CALLED); p.log(TAIL_CALLED);


+ 6
- 6
src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java View File

@@ -65,7 +65,7 @@ public class AntTest {
try { try {
buildRule.executeTarget("test1"); buildRule.executeTarget("test1");
fail("recursive call"); fail("recursive call");
} catch(BuildException ex) {
} catch (BuildException ex) {
//TODO assert exception message //TODO assert exception message
} }
} }
@@ -76,7 +76,7 @@ public class AntTest {
try { try {
buildRule.executeTarget("test2"); buildRule.executeTarget("test2");
fail("required argument not specified"); fail("required argument not specified");
} catch(BuildException ex) {
} catch (BuildException ex) {
//TODO assert exception message //TODO assert exception message
} }
} }
@@ -87,7 +87,7 @@ public class AntTest {
try { try {
buildRule.executeTarget("test1"); buildRule.executeTarget("test1");
fail("recursive call"); fail("recursive call");
} catch(BuildException ex) {
} catch (BuildException ex) {
//TODO assert exception message //TODO assert exception message
} }
} }
@@ -107,7 +107,7 @@ public class AntTest {
try { try {
buildRule.executeTarget("test4b"); buildRule.executeTarget("test4b");
fail("target doesn't exist"); fail("target doesn't exist");
} catch(BuildException ex) {
} catch (BuildException ex) {
//TODO assert exception message //TODO assert exception message
} }
} }
@@ -327,7 +327,7 @@ public class AntTest {
try { try {
buildRule.executeTarget("infinite-loop-via-depends"); buildRule.executeTarget("infinite-loop-via-depends");
fail("recursive call"); fail("recursive call");
} catch(BuildException ex) {
} catch (BuildException ex) {
//TODO assert exception message //TODO assert exception message
} }
} }
@@ -371,7 +371,7 @@ public class AntTest {
try { try {
buildRule.executeTarget("blank-target"); buildRule.executeTarget("blank-target");
fail("target name must not be empty"); fail("target name must not be empty");
} catch(BuildException ex) {
} catch (BuildException ex) {
//TODO assert exception message //TODO assert exception message
} }
} }


+ 3
- 2
src/tests/junit/org/apache/tools/ant/taskdefs/ConcatTest.java View File

@@ -31,6 +31,7 @@ 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.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;


@@ -240,7 +241,7 @@ public class ConcatTest {
try { try {
buildRule.executeTarget("samefile"); buildRule.executeTarget("samefile");
fail("Build exception should have been thrown - output file same as input"); fail("Build exception should have been thrown - output file same as input");
} catch(BuildException ex) {
} catch (BuildException ex) {
//TODO assert value //TODO assert value
} }
} }
@@ -261,7 +262,7 @@ public class ConcatTest {
public void testmultireader() { public void testmultireader() {
buildRule.executeTarget("testmultireader"); buildRule.executeTarget("testmultireader");
assertTrue(buildRule.getLog().contains("Bye")); assertTrue(buildRule.getLog().contains("Bye"));
assertTrue(!buildRule.getLog().contains("Hello"));
assertFalse(buildRule.getLog().contains("Hello"));
} }
/** /**
* Check if fixlastline works * Check if fixlastline works


+ 2
- 1
src/tests/junit/org/apache/tools/ant/taskdefs/CopyTest.java View File

@@ -35,6 +35,7 @@ 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.assertFalse;
import static org.junit.Assert.assertNotEquals; 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;
@@ -105,7 +106,7 @@ public class CopyTest {
@Test @Test
public void testFilterTest() { public void testFilterTest() {
buildRule.executeTarget("filtertest"); buildRule.executeTarget("filtertest");
assertTrue(!buildRule.getLog().contains("loop in tokens"));
assertFalse(buildRule.getLog().contains("loop in tokens"));
} }


@Test @Test


+ 5
- 2
src/tests/junit/org/apache/tools/ant/taskdefs/DefaultExcludesTest.java View File

@@ -159,8 +159,11 @@ public class DefaultExcludesTest {
assertEquals(message + " : string array length match", expected.length, actual.length); assertEquals(message + " : string array length match", expected.length, actual.length);
for (String element : expected) { for (String element : expected) {
boolean found = false; 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 " assertTrue(message + " : didn't find element "
+ element + " in array match", found); + element + " in array match", found);


+ 1
- 1
src/tests/junit/org/apache/tools/ant/taskdefs/EchoTest.java View File

@@ -68,7 +68,7 @@ public class EchoTest {
echo.setEncoding("UTF-8"); echo.setEncoding("UTF-8");
echo.execute(); echo.execute();
String x = FileUtils.readFully(new InputStreamReader(new FileInputStream(removeThis), "UTF-8")); String x = FileUtils.readFully(new InputStreamReader(new FileInputStream(removeThis), "UTF-8"));
assertEquals(x,"\u00e4\u00a9");
assertEquals(x, "\u00e4\u00a9");
} }


@After @After


+ 3
- 2
src/tests/junit/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java View File

@@ -28,6 +28,7 @@ import org.junit.internal.AssumptionViolatedException;


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;


/** /**
@@ -127,7 +128,7 @@ public class ExecuteWatchdogTest {
watchdog.start(process); watchdog.start(process);
int retCode = process.waitFor(); int retCode = process.waitFor();
assertFalse("process should not have been killed", watchdog.killedProcess()); 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 @Test
@@ -139,7 +140,7 @@ public class ExecuteWatchdogTest {
Thread thread = new Thread(() -> { Thread thread = new Thread(() -> {
try { try {
process.waitFor(); process.waitFor();
} catch(InterruptedException e) {
} catch (InterruptedException e) {
// not very nice but will do the job // not very nice but will do the job
throw new AssumptionViolatedException("process interrupted in thread", e); throw new AssumptionViolatedException("process interrupted in thread", e);
} }


+ 1
- 1
src/tests/junit/org/apache/tools/ant/taskdefs/JarTest.java View File

@@ -300,7 +300,7 @@ public class JarTest {
} }


assertTrue(foundSub); assertTrue(foundSub);
assertTrue(!foundSubFoo);
assertFalse(foundSubFoo);
assertTrue(foundFoo); assertTrue(foundFoo);
} }
} }


+ 2
- 1
src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java View File

@@ -37,6 +37,7 @@ 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.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;
@@ -389,7 +390,7 @@ public class ManifestTest {
buildRule.executeTarget("testUpdate"); buildRule.executeTarget("testUpdate");
Manifest mf = getManifest(new File(outDir, "mftest.mf")); Manifest mf = getManifest(new File(outDir, "mftest.mf"));
assertNotNull(mf); assertNotNull(mf);
assertTrue(!Manifest.getDefaultManifest().equals(mf));
assertNotEquals(Manifest.getDefaultManifest(), mf);
String mfAsString = mf.toString(); String mfAsString = mf.toString();
assertNotNull(mfAsString); assertNotNull(mfAsString);
assertTrue(mfAsString.startsWith("Manifest-Version: 2.0")); assertTrue(mfAsString.startsWith("Manifest-Version: 2.0"));


+ 20
- 19
src/tests/junit/org/apache/tools/ant/taskdefs/MoveTest.java View File

@@ -28,6 +28,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;


import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;


/** /**
@@ -69,14 +70,14 @@ public class MoveTest {


buildRule.executeTarget("testDirectoryRemoval"); buildRule.executeTarget("testDirectoryRemoval");
String output = buildRule.getProject().getProperty("output"); 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/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 */ /** Bugzilla Report 18886 */
@@ -84,10 +85,10 @@ public class MoveTest {
public void testDirectoryRetaining() { public void testDirectoryRetaining() {
buildRule.executeTarget("testDirectoryRetaining"); buildRule.executeTarget("testDirectoryRetaining");
String output = buildRule.getProject().getProperty("output"); 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 @Test
@@ -103,21 +104,21 @@ public class MoveTest {
private void testCompleteDirectoryMove(String target) { private void testCompleteDirectoryMove(String target) {
buildRule.executeTarget(target); buildRule.executeTarget(target);
String output = buildRule.getProject().getProperty("output"); 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());
// <path> swallows the basedir, it seems // <path> swallows the basedir, it seems
//assertTrue(!new File(getOutputDir(),"A").exists());
//assertFalse(new File(getOutputDir(), "A").exists());
} }


@Test @Test
public void testPathElementMove() { public void testPathElementMove() {
buildRule.executeTarget("testPathElementMove"); buildRule.executeTarget("testPathElementMove");
String output = buildRule.getProject().getProperty("output"); 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 @Test


+ 2
- 1
src/tests/junit/org/apache/tools/ant/taskdefs/SQLExecTest.java View File

@@ -34,6 +34,7 @@ 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.assertFalse;
import static org.junit.Assert.assertSame; import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
@@ -72,7 +73,7 @@ public class SQLExecTest {
@Test @Test
public void testDriverCaching() { public void testDriverCaching() {
SQLExec sql = createTask(getProperties(NULL)); SQLExec sql = createTask(getProperties(NULL));
assertTrue(!SQLExec.getLoaderMap().containsKey(NULL_DRIVER));
assertFalse(SQLExec.getLoaderMap().containsKey(NULL_DRIVER));
try { try {
sql.execute(); sql.execute();
fail("BuildException should have been thrown"); fail("BuildException should have been thrown");


+ 1
- 1
src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java View File

@@ -109,7 +109,7 @@ public class SignJarTest {
try { try {
buildRule.executeTarget("testTsaLocalhost"); buildRule.executeTarget("testTsaLocalhost");
fail("Should have thrown exception - no TSA at localhost:0"); fail("Should have thrown exception - no TSA at localhost:0");
} catch(BuildException ex) {
} catch (BuildException ex) {
assertEquals("jarsigner returned: 1", ex.getMessage()); assertEquals("jarsigner returned: 1", ex.getMessage());
} }
} }


+ 6
- 5
src/tests/junit/org/apache/tools/ant/taskdefs/SyncTest.java View File

@@ -24,6 +24,7 @@ import org.junit.Rule;
import org.junit.Test; 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.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;


public class SyncTest { public class SyncTest {
@@ -41,7 +42,7 @@ public class SyncTest {
buildRule.executeTarget("simplecopy"); buildRule.executeTarget("simplecopy");
String d = buildRule.getProject().getProperty("dest") + "/a/b/c/d"; String d = buildRule.getProject().getProperty("dest") + "/a/b/c/d";
assertFileIsPresent(d); assertFileIsPresent(d);
assertTrue(!buildRule.getFullLog().contains("dangling"));
assertFalse(buildRule.getFullLog().contains("dangling"));
} }


@Test @Test
@@ -51,7 +52,7 @@ public class SyncTest {
assertFileIsNotPresent(d); assertFileIsNotPresent(d);
String c = buildRule.getProject().getProperty("dest") + "/a/b/c"; String c = buildRule.getProject().getProperty("dest") + "/a/b/c";
assertFileIsNotPresent(c); assertFileIsNotPresent(c);
assertTrue(!buildRule.getFullLog().contains("dangling"));
assertFalse(buildRule.getFullLog().contains("dangling"));
} }


@Test @Test
@@ -61,7 +62,7 @@ public class SyncTest {
assertFileIsNotPresent(d); assertFileIsNotPresent(d);
String c = buildRule.getProject().getProperty("dest") + "/a/b/c"; String c = buildRule.getProject().getProperty("dest") + "/a/b/c";
assertFileIsPresent(c); assertFileIsPresent(c);
assertTrue(!buildRule.getFullLog().contains("dangling"));
assertFalse(buildRule.getFullLog().contains("dangling"));
} }


@Test @Test
@@ -123,7 +124,7 @@ public class SyncTest {
assertFileIsPresent(d); assertFileIsPresent(d);
String f = buildRule.getProject().getProperty("dest") + "/e/f"; String f = buildRule.getProject().getProperty("dest") + "/e/f";
assertFileIsPresent(f); assertFileIsPresent(f);
assertTrue(!buildRule.getFullLog().contains("Removing orphan file:"));
assertFalse(buildRule.getFullLog().contains("Removing orphan file:"));
} }


@Test @Test
@@ -133,7 +134,7 @@ public class SyncTest {
assertFileIsPresent(d); assertFileIsPresent(d);
String f = buildRule.getProject().getProperty("dest") + "/e/f"; String f = buildRule.getProject().getProperty("dest") + "/e/f";
assertFileIsPresent(f); assertFileIsPresent(f);
assertTrue(!buildRule.getFullLog().contains("Removing orphan file:"));
assertFalse(buildRule.getFullLog().contains("Removing orphan file:"));
} }


public void assertFileIsPresent(String f) { public void assertFileIsPresent(String f) {


+ 2
- 1
src/tests/junit/org/apache/tools/ant/taskdefs/condition/ContainsTest.java View File

@@ -20,6 +20,7 @@ package org.apache.tools.ant.taskdefs.condition;


import org.junit.Test; import org.junit.Test;


import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;


/** /**
@@ -33,7 +34,7 @@ public class ContainsTest {
Contains con = new Contains(); Contains con = new Contains();
con.setString("abc"); con.setString("abc");
con.setSubstring("A"); con.setSubstring("A");
assertTrue(!con.eval());
assertFalse(con.eval());


con.setCasesensitive(false); con.setCasesensitive(false);
assertTrue(con.eval()); assertTrue(con.eval());


+ 3
- 2
src/tests/junit/org/apache/tools/ant/taskdefs/condition/EqualsTest.java View File

@@ -20,6 +20,7 @@ package org.apache.tools.ant.taskdefs.condition;


import org.junit.Test; import org.junit.Test;


import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;


/** /**
@@ -33,7 +34,7 @@ public class EqualsTest {
Equals eq = new Equals(); Equals eq = new Equals();
eq.setArg1("a"); eq.setArg1("a");
eq.setArg2(" a"); eq.setArg2(" a");
assertTrue(!eq.eval());
assertFalse(eq.eval());


eq.setTrim(true); eq.setTrim(true);
assertTrue(eq.eval()); assertTrue(eq.eval());
@@ -47,7 +48,7 @@ public class EqualsTest {
Equals eq = new Equals(); Equals eq = new Equals();
eq.setArg1("a"); eq.setArg1("a");
eq.setArg2("A"); eq.setArg2("A");
assertTrue(!eq.eval());
assertFalse(eq.eval());


eq.setCasesensitive(false); eq.setCasesensitive(false);
assertTrue(eq.eval()); assertTrue(eq.eval());


+ 1
- 1
src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsReferenceTest.java View File

@@ -54,7 +54,7 @@ public class IsReferenceTest {
try { try {
buildRule.executeTarget("isreference-incomplete"); buildRule.executeTarget("isreference-incomplete");
fail("Build exception expected: refid attirbute has been omitted"); fail("Build exception expected: refid attirbute has been omitted");
} catch(BuildException ex) {
} catch (BuildException ex) {
assertEquals("No reference specified for isreference condition", ex.getMessage()); assertEquals("No reference specified for isreference condition", ex.getMessage());
} }
} }


+ 3
- 3
src/tests/junit/org/apache/tools/ant/taskdefs/condition/ParserSupportsTest.java View File

@@ -46,7 +46,7 @@ public class ParserSupportsTest {
try { try {
buildRule.executeTarget("testEmpty"); buildRule.executeTarget("testEmpty");
fail("Build exception expected: " + ParserSupports.ERROR_NO_ATTRIBUTES); fail("Build exception expected: " + ParserSupports.ERROR_NO_ATTRIBUTES);
} catch(BuildException ex) {
} catch (BuildException ex) {
assertEquals(ParserSupports.ERROR_NO_ATTRIBUTES, ex.getMessage()); assertEquals(ParserSupports.ERROR_NO_ATTRIBUTES, ex.getMessage());
} }
} }
@@ -56,7 +56,7 @@ public class ParserSupportsTest {
try { try {
buildRule.executeTarget("testBoth"); buildRule.executeTarget("testBoth");
fail("Build exception expected: " + ParserSupports.ERROR_BOTH_ATTRIBUTES); fail("Build exception expected: " + ParserSupports.ERROR_BOTH_ATTRIBUTES);
} catch(BuildException ex) {
} catch (BuildException ex) {
assertEquals(ParserSupports.ERROR_BOTH_ATTRIBUTES, ex.getMessage()); assertEquals(ParserSupports.ERROR_BOTH_ATTRIBUTES, ex.getMessage());
} }
} }
@@ -71,7 +71,7 @@ public class ParserSupportsTest {
try { try {
buildRule.executeTarget("testPropertyNoValue"); buildRule.executeTarget("testPropertyNoValue");
fail("Build exception expected: " + ParserSupports.ERROR_NO_VALUE); fail("Build exception expected: " + ParserSupports.ERROR_NO_VALUE);
} catch(BuildException ex) {
} catch (BuildException ex) {
assertEquals(ParserSupports.ERROR_NO_VALUE, ex.getMessage()); assertEquals(ParserSupports.ERROR_NO_VALUE, ex.getMessage());
} }
} }


+ 2
- 2
src/tests/junit/org/apache/tools/ant/taskdefs/email/EmailTaskTest.java View File

@@ -45,7 +45,7 @@ public class EmailTaskTest {
try { try {
buildRule.executeTarget("test1"); buildRule.executeTarget("test1");
fail("Build exception expected: SMTP auth only possibly with MIME mail"); fail("Build exception expected: SMTP auth only possibly with MIME mail");
} catch(BuildException ex) {
} catch (BuildException ex) {
//TODO assert exception message //TODO assert exception message
} }
} }
@@ -55,7 +55,7 @@ public class EmailTaskTest {
try { try {
buildRule.executeTarget("test2"); buildRule.executeTarget("test2");
fail("Build exception expected: SSL only possibly with MIME mail"); fail("Build exception expected: SSL only possibly with MIME mail");
} catch(BuildException ex) {
} catch (BuildException ex) {
//TODO assert exception message //TODO assert exception message
} }
} }


+ 1
- 1
src/tests/junit/org/apache/tools/ant/taskdefs/optional/PvcsTest.java View File

@@ -72,7 +72,7 @@ public class PvcsTest {
buildRule.executeTarget("test6"); buildRule.executeTarget("test6");
fail("Failed executing: /never/heard/of/a/directory/structure/like/this/pcli lvf -z " + 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"); "-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 //TODO assert exception message
} }
} }


+ 2
- 2
src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java View File

@@ -165,7 +165,7 @@ public class XmlValidateTest {
try { try {
buildRule.executeTarget("testUtf8"); buildRule.executeTarget("testUtf8");
fail("Invalid characters in file"); fail("Invalid characters in file");
} catch(BuildException ex) {
} catch (BuildException ex) {
//TODO assert exception message //TODO assert exception message
} }
} }
@@ -181,7 +181,7 @@ public class XmlValidateTest {
try { try {
buildRule.executeTarget("testProperty.invalidXML"); buildRule.executeTarget("testProperty.invalidXML");
fail("XML file does not satisfy schema"); fail("XML file does not satisfy schema");
} catch(BuildException ex) {
} catch (BuildException ex) {
//TODO assert exception message //TODO assert exception message
} }
} }


+ 1
- 1
src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java View File

@@ -50,7 +50,7 @@ public class XsltTest {
try { try {
buildRule.executeTarget("testCatchNoDtd"); buildRule.executeTarget("testCatchNoDtd");
fail("Expected failure"); fail("Expected failure");
} catch(BuildException ex) {
} catch (BuildException ex) {
//TODO assert exception message //TODO assert exception message
} }
} }


+ 10
- 10
src/tests/junit/org/apache/tools/ant/taskdefs/optional/script/ScriptDefTest.java View File

@@ -17,7 +17,6 @@
*/ */
package org.apache.tools.ant.taskdefs.optional.script; 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.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;
@@ -28,6 +27,7 @@ import org.junit.Test;


import java.io.File; import java.io.File;


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.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
@@ -67,8 +67,8 @@ public class ScriptDefTest {
try { try {
buildRule.executeTarget("nolang"); buildRule.executeTarget("nolang");
fail("Absence of language attribute not detected"); 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 { try {
buildRule.executeTarget("noname"); buildRule.executeTarget("noname");
fail("Absence of name attribute not detected"); 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 { try {
buildRule.executeTarget("exception"); buildRule.executeTarget("exception");
fail("Should have thrown an exception in the script"); 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 { try {
buildRule.executeTarget("doubleAttributeDef"); buildRule.executeTarget("doubleAttributeDef");
fail("Should have detected duplicate attirbute definition"); 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 + fail("should have failed with reader's encoding [" + readerEncoding +
"] different from the writer's encoding [" + "] different from the writer's encoding [" +
buildRule.getProject().getProperty("useSrcAndEncoding.encoding") + "]"); buildRule.getProject().getProperty("useSrcAndEncoding.encoding") + "]");
} catch(BuildException e) {
} catch (BuildException e) {
assertTrue(e.getMessage().matches( assertTrue(e.getMessage().matches(
"expected <eacute \\[\u00e9]> but was <eacute \\[\u00c3\u00a9]>")); "expected <eacute \\[\u00e9]> but was <eacute \\[\u00c3\u00a9]>"));
} }


+ 1
- 1
src/tests/junit/org/apache/tools/ant/types/optional/ScriptSelectorTest.java View File

@@ -44,7 +44,7 @@ public class ScriptSelectorTest {
try { try {
buildRule.executeTarget("testNolanguage"); buildRule.executeTarget("testNolanguage");
fail("Absence of language attribute not detected"); fail("Absence of language attribute not detected");
} catch(BuildException ex) {
} catch (BuildException ex) {
assertContains("script language must be specified", ex.getMessage()); assertContains("script language must be specified", ex.getMessage());


} }


+ 19
- 18
src/tests/junit/org/apache/tools/ant/util/CollectionUtilsTest.java View File

@@ -25,6 +25,7 @@ import java.util.Vector;


import org.junit.Test; import org.junit.Test;


import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;


/** /**
@@ -36,8 +37,8 @@ public class CollectionUtilsTest {


@Test @Test
public void testVectorEquals() { 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())); assertTrue(CollectionUtils.equals(new Vector(), new Vector()));
Vector<String> v1 = new Vector<>(); Vector<String> v1 = new Vector<>();
Stack<String> s2 = new Stack<>(); Stack<String> s2 = new Stack<>();
@@ -46,27 +47,27 @@ public class CollectionUtilsTest {
assertTrue(CollectionUtils.equals(v1, s2)); assertTrue(CollectionUtils.equals(v1, s2));
assertTrue(CollectionUtils.equals(s2, v1)); assertTrue(CollectionUtils.equals(s2, v1));
v1.addElement("bar"); 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"); s2.push("bar");
assertTrue(CollectionUtils.equals(v1, s2)); assertTrue(CollectionUtils.equals(v1, s2));
assertTrue(CollectionUtils.equals(s2, v1)); assertTrue(CollectionUtils.equals(s2, v1));
s2.push("baz"); 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"); v1.addElement("baz");
assertTrue(CollectionUtils.equals(v1, s2)); assertTrue(CollectionUtils.equals(v1, s2));
assertTrue(CollectionUtils.equals(s2, v1)); assertTrue(CollectionUtils.equals(s2, v1));
v1.addElement("zyzzy"); v1.addElement("zyzzy");
s2.push("zyzzy2"); s2.push("zyzzy2");
assertTrue(!CollectionUtils.equals(v1, s2));
assertTrue(!CollectionUtils.equals(s2, v1));
assertFalse(CollectionUtils.equals(v1, s2));
assertFalse(CollectionUtils.equals(s2, v1));
} }


@Test @Test
public void testDictionaryEquals() { 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())); assertTrue(CollectionUtils.equals(new Hashtable(), new Properties()));
Hashtable<String, String> h1 = new Hashtable<>(); Hashtable<String, String> h1 = new Hashtable<>();
Properties p2 = new Properties(); Properties p2 = new Properties();
@@ -75,28 +76,28 @@ public class CollectionUtilsTest {
assertTrue(CollectionUtils.equals(h1, p2)); assertTrue(CollectionUtils.equals(h1, p2));
assertTrue(CollectionUtils.equals(p2, h1)); assertTrue(CollectionUtils.equals(p2, h1));
h1.put("bar", ""); 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", ""); p2.put("bar", "");
assertTrue(CollectionUtils.equals(h1, p2)); assertTrue(CollectionUtils.equals(h1, p2));
assertTrue(CollectionUtils.equals(p2, h1)); assertTrue(CollectionUtils.equals(p2, h1));
p2.put("baz", ""); 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", ""); h1.put("baz", "");
assertTrue(CollectionUtils.equals(h1, p2)); assertTrue(CollectionUtils.equals(h1, p2));
assertTrue(CollectionUtils.equals(p2, h1)); assertTrue(CollectionUtils.equals(p2, h1));
h1.put("zyzzy", ""); h1.put("zyzzy", "");
p2.put("zyzzy2", ""); 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", ""); p2.put("zyzzy", "");
h1.put("zyzzy2", ""); h1.put("zyzzy2", "");
assertTrue(CollectionUtils.equals(h1, p2)); assertTrue(CollectionUtils.equals(h1, p2));
assertTrue(CollectionUtils.equals(p2, h1)); assertTrue(CollectionUtils.equals(p2, h1));
h1.put("dada", "1"); h1.put("dada", "1");
p2.put("dada", "2"); p2.put("dada", "2");
assertTrue(!CollectionUtils.equals(h1, p2));
assertTrue(!CollectionUtils.equals(p2, h1));
assertFalse(CollectionUtils.equals(h1, p2));
assertFalse(CollectionUtils.equals(p2, h1));
} }
} }

+ 1
- 1
src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java View File

@@ -413,7 +413,7 @@ public class FileUtilsTest {
@Test @Test
public void testCreateNewFile() throws IOException { public void testCreateNewFile() throws IOException {
removeThis = new File("dummy"); removeThis = new File("dummy");
assertTrue(!removeThis.exists());
assertFalse(removeThis.exists());
FILE_UTILS.createNewFile(removeThis); FILE_UTILS.createNewFile(removeThis);
assertTrue(removeThis.exists()); assertTrue(removeThis.exists());
} }


+ 7
- 7
src/tests/junit/org/apache/tools/ant/util/LayoutPreservingPropertiesTest.java View File

@@ -126,12 +126,12 @@ public class LayoutPreservingPropertiesTest {
// and check that the resulting file looks okay // and check that the resulting file looks okay
String s = readFile(tmp); String s = readFile(tmp);


assertTrue(!s.contains("\\ prop\\ one\\ =\\ \\ leading and"
assertFalse(s.contains("\\ prop\\ one\\ =\\ \\ leading and"
+ " trailing spaces ")); + " trailing spaces "));
assertTrue(s.contains("\\ prop\\ one\\ =new one")); 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\\ttwo=new two"));
assertTrue(!s.contains("prop\\nthree=contains\\nnewline"));
assertFalse(s.contains("prop\\nthree=contains\\nnewline"));
assertTrue(s.contains("prop\\nthree=new three")); 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("alpha=new value for alpha"));
assertTrue(s.contains("beta=new value for beta")); 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 { private static String readFile(File f) throws IOException {


+ 2
- 2
src/tests/junit/org/apache/tools/ant/util/XMLFragmentTest.java View File

@@ -66,7 +66,7 @@ public class XMLFragmentTest {
assertEquals(Node.ELEMENT_NODE, nl.item(0).getNodeType()); assertEquals(Node.ELEMENT_NODE, nl.item(0).getNodeType());
Element child1 = (Element) nl.item(0); Element child1 = (Element) nl.item(0);
assertEquals("child1", child1.getTagName()); assertEquals("child1", child1.getTagName());
assertTrue(!child1.hasAttributes());
assertFalse(child1.hasAttributes());
NodeList nl2 = child1.getChildNodes(); NodeList nl2 = child1.getChildNodes();
assertEquals(1, nl2.getLength()); assertEquals(1, nl2.getLength());
assertEquals(Node.TEXT_NODE, nl2.item(0).getNodeType()); assertEquals(Node.TEXT_NODE, nl2.item(0).getNodeType());
@@ -83,7 +83,7 @@ public class XMLFragmentTest {
assertEquals(Node.ELEMENT_NODE, nl.item(2).getNodeType()); assertEquals(Node.ELEMENT_NODE, nl.item(2).getNodeType());
Element child3 = (Element) nl.item(2); Element child3 = (Element) nl.item(2);
assertEquals("child3", child3.getTagName()); assertEquals("child3", child3.getTagName());
assertTrue(!child3.hasAttributes());
assertFalse(child3.hasAttributes());
nl2 = child3.getChildNodes(); nl2 = child3.getChildNodes();
assertEquals(1, nl2.getLength()); assertEquals(1, nl2.getLength());
assertEquals(Node.ELEMENT_NODE, nl2.item(0).getNodeType()); assertEquals(Node.ELEMENT_NODE, nl2.item(0).getNodeType());


+ 1
- 1
src/tests/junit/org/apache/tools/ant/util/facade/FacadeTaskHelperTest.java View File

@@ -58,7 +58,7 @@ public class FacadeTaskHelperTest {
fth.setMagicValue("foo"); fth.setMagicValue("foo");
assertTrue("magic has been set", fth.hasBeenSet()); assertTrue("magic has been set", fth.hasBeenSet());
fth.setMagicValue(null); fth.setMagicValue(null);
assertTrue(!fth.hasBeenSet());
assertFalse(fth.hasBeenSet());
fth.setImplementation("baz"); fth.setImplementation("baz");
assertTrue("set explicitly", fth.hasBeenSet()); assertTrue("set explicitly", fth.hasBeenSet());
} }


Loading…
Cancel
Save