ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gin...@apache.org
Subject [4/4] ant git commit: Deprecate AntAssert
Date Sat, 14 Apr 2018 12:42:01 GMT
Deprecate AntAssert

Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/81c3e6e3
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/81c3e6e3
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/81c3e6e3

Branch: refs/heads/master
Commit: 81c3e6e3ddf5b1ef4e66018f1047e1b2ae8b3173
Parents: 1026236
Author: Gintas Grigelionis <gintas@apache.org>
Authored: Sat Apr 14 14:36:57 2018 +0200
Committer: Gintas Grigelionis <gintas@apache.org>
Committed: Sat Apr 14 14:41:24 2018 +0200

----------------------------------------------------------------------
 WHATSNEW                                        |   6 +
 .../junit/org/apache/tools/ant/AntAssert.java   |   4 +
 .../org/apache/tools/ant/BuildFileRule.java     |  14 +-
 .../junit/org/apache/tools/ant/CaseTest.java    |  18 +-
 .../apache/tools/ant/ExtendedTaskdefTest.java   |  32 ++--
 .../junit/org/apache/tools/ant/IncludeTest.java |  68 +++-----
 .../org/apache/tools/ant/LoaderRefTest.java     |  16 +-
 .../org/apache/tools/ant/LocationTest.java      |  11 +-
 .../tools/ant/ProjectHelperRepositoryTest.java  |  31 +---
 .../junit/org/apache/tools/ant/ProjectTest.java |   5 +-
 .../apache/tools/ant/PropertyFileCLITest.java   |   5 +-
 .../org/apache/tools/ant/TaskContainerTest.java |  31 ++--
 .../tools/ant/filters/DynamicFilterTest.java    |   5 +-
 .../tools/ant/filters/TokenFilterTest.java      | 104 ++++++------
 .../apache/tools/ant/launch/LocatorTest.java    |  25 ++-
 .../tools/ant/taskdefs/AbstractCvsTaskTest.java |   7 +-
 .../tools/ant/taskdefs/AntStructureTest.java    |   5 +-
 .../org/apache/tools/ant/taskdefs/AntTest.java  |  17 +-
 .../tools/ant/taskdefs/CallTargetTest.java      |   7 +-
 .../apache/tools/ant/taskdefs/ConcatTest.java   |  28 ++--
 .../org/apache/tools/ant/taskdefs/CopyTest.java |  65 ++++----
 .../apache/tools/ant/taskdefs/EchoXMLTest.java  |   7 +-
 .../apache/tools/ant/taskdefs/FixCrLfTest.java  |  23 ++-
 .../org/apache/tools/ant/taskdefs/GetTest.java  |  99 +++++------
 .../apache/tools/ant/taskdefs/ImportTest.java   |  86 ++++------
 .../org/apache/tools/ant/taskdefs/JarTest.java  | 108 +++++-------
 .../org/apache/tools/ant/taskdefs/JavaTest.java | 114 +++++--------
 .../apache/tools/ant/taskdefs/JavacTest.java    |   9 +-
 .../apache/tools/ant/taskdefs/LoadFileTest.java |  56 +++----
 .../apache/tools/ant/taskdefs/MacroDefTest.java |  99 +++++------
 .../apache/tools/ant/taskdefs/MakeUrlTest.java  |  50 +++---
 .../ant/taskdefs/ManifestClassPathTest.java     |  82 +++++----
 .../apache/tools/ant/taskdefs/ManifestTest.java | 165 +++++++------------
 .../org/apache/tools/ant/taskdefs/NiceTest.java |  25 ++-
 .../tools/ant/taskdefs/PreSetDefTest.java       |  24 ++-
 .../apache/tools/ant/taskdefs/PropertyTest.java |  58 ++++---
 .../tools/ant/taskdefs/RmicAdvancedTest.java    |  63 +++----
 .../apache/tools/ant/taskdefs/SQLExecTest.java  |  44 ++---
 .../apache/tools/ant/taskdefs/StyleTest.java    |   9 +-
 .../apache/tools/ant/taskdefs/SubAntTest.java   |  41 +++--
 .../org/apache/tools/ant/taskdefs/SyncTest.java |  33 ++--
 .../apache/tools/ant/taskdefs/TaskdefTest.java  |  15 +-
 .../apache/tools/ant/taskdefs/TouchTest.java    |  17 +-
 .../tools/ant/taskdefs/TypeAdapterTest.java     |  25 ++-
 .../apache/tools/ant/taskdefs/TypedefTest.java  |  70 +++-----
 .../org/apache/tools/ant/taskdefs/ZipTest.java  |  67 ++++----
 .../compilers/DefaultCompilerAdapterTest.java   |  14 +-
 .../taskdefs/condition/IsFileSelectedTest.java  |  17 +-
 .../ant/taskdefs/condition/IsReachableTest.java |  56 +++----
 .../ant/taskdefs/condition/TypeFoundTest.java   |  15 +-
 .../tools/ant/taskdefs/optional/ANTLRTest.java  |  17 +-
 .../taskdefs/optional/EchoPropertiesTest.java   |  65 +++-----
 .../tools/ant/taskdefs/optional/RpmTest.java    |  18 +-
 .../taskdefs/optional/SchemaValidateTest.java   |  56 +++----
 .../ant/taskdefs/optional/XmlValidateTest.java  |  69 +++-----
 .../tools/ant/taskdefs/optional/XsltTest.java   |  19 +--
 .../taskdefs/optional/depend/DependTest.java    |  37 ++---
 .../ant/taskdefs/optional/image/ImageTest.java  |  32 ++--
 .../taskdefs/optional/jdepend/JDependTest.java  |  16 +-
 .../optional/junit/JUnitReportTest.java         |  15 +-
 .../taskdefs/optional/junit/JUnitTaskTest.java  |  73 ++++----
 .../optional/junit/JUnitTestListenerTest.java   |  37 +++--
 .../optional/junit/JUnitTestRunnerTest.java     |   5 +-
 .../optional/junit/TearDownOnVmCrashTest.java   |   9 +-
 .../junit/XMLFormatterWithCDATAOnSystemOut.java |   7 +-
 .../ant/taskdefs/optional/net/FTPTest.java      |   5 +-
 .../taskdefs/optional/script/ScriptDefTest.java |  84 ++++------
 .../org/apache/tools/ant/types/AddTypeTest.java |  46 +++---
 .../apache/tools/ant/types/AssertionsTest.java  |  42 +++--
 .../tools/ant/types/CommandlineJavaTest.java    |  12 +-
 .../org/apache/tools/ant/types/PathTest.java    |   4 +-
 .../org/apache/tools/ant/types/PolyTest.java    |  11 +-
 .../tools/ant/types/RedirectorElementTest.java  |   9 +-
 .../ant/types/optional/ScriptSelectorTest.java  |   5 +-
 .../types/selectors/ModifiedSelectorTest.java   |   8 +-
 .../util/LayoutPreservingPropertiesTest.java    |  88 +++++-----
 76 files changed, 1247 insertions(+), 1537 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/81c3e6e3/WHATSNEW
----------------------------------------------------------------------
diff --git a/WHATSNEW b/WHATSNEW
index a017dfd..611ff14 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -13,6 +13,12 @@ Fixed bugs:
  * The junit task when used with includeantruntime="no" was incorrectly
    printing a warning about multiple versions of ant detected in path
 
+Other changes:
+--------------
+
+ * AntAssert is deprecated, assertThat from JUnit 4.4+, Hamcrest matchers and/or
+   ExpectedException rule provide equivalent functionality
+
 Changes from Ant 1.10.2 TO Ant 1.10.3
 =====================================
 

http://git-wip-us.apache.org/repos/asf/ant/blob/81c3e6e3/src/tests/junit/org/apache/tools/ant/AntAssert.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/AntAssert.java b/src/tests/junit/org/apache/tools/ant/AntAssert.java
index d23792e..93a1562 100644
--- a/src/tests/junit/org/apache/tools/ant/AntAssert.java
+++ b/src/tests/junit/org/apache/tools/ant/AntAssert.java
@@ -23,7 +23,11 @@ import static org.junit.Assert.assertTrue;
 /**
  * Provides common assert functions for use across multiple tests, similar to the <tt>Assert</tt>s
  * within JUnit.
+ *
+ * @deprecated use assertThat() in JUnit 4.4+ in combination with containsString() matcher;
+ * for exception messages, use ExpectedException rule.
  */
+@Deprecated
 public class AntAssert {
 
     /**

http://git-wip-us.apache.org/repos/asf/ant/blob/81c3e6e3/src/tests/junit/org/apache/tools/ant/BuildFileRule.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/BuildFileRule.java b/src/tests/junit/org/apache/tools/ant/BuildFileRule.java
index c5a71c7..dcbbcea 100644
--- a/src/tests/junit/org/apache/tools/ant/BuildFileRule.java
+++ b/src/tests/junit/org/apache/tools/ant/BuildFileRule.java
@@ -35,6 +35,9 @@ import org.junit.rules.ExternalResource;
  *     \@Rule
  *     public BuildFileRule rule = new BuildFileRule();
  *
+ *     \@Rule
+ *     public ExpectedException thrown = ExpectedException.none();
+ *
  *     \@Before
  *     public void setUp() {
  *         rule.configureProject("my/and/file.xml");
@@ -48,12 +51,9 @@ import org.junit.rules.ExternalResource;
  *
  *     \@Test
  *     public void testException() {
- *         try {
- *             rule.executeTarget("failingTarget");
- *             fail("Target should have thrown a BuildException");
- *         } catch (BuildException ex) {
- *             assertContains("Exception did not contain correct text", "Could not find compiler on classpath", ex.getMessage());
- *         }
+ *         thrown.expect(BuildException.class);
+ *         thrown.expectMessage("Could not find compiler on classpath");
+ *         rule.executeTarget("failingTarget");
  *     }
  *
  * }
@@ -68,8 +68,6 @@ public class BuildFileRule extends ExternalResource {
     private StringBuffer outputBuffer;
     private StringBuffer errorBuffer;
 
-
-
     /**
      * Tidies up following a test execution. If the currently configured
      * project has a <tt>tearDown</tt> target then this will automatically

http://git-wip-us.apache.org/repos/asf/ant/blob/81c3e6e3/src/tests/junit/org/apache/tools/ant/CaseTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/CaseTest.java b/src/tests/junit/org/apache/tools/ant/CaseTest.java
index a466ea4..d2abc27 100644
--- a/src/tests/junit/org/apache/tools/ant/CaseTest.java
+++ b/src/tests/junit/org/apache/tools/ant/CaseTest.java
@@ -21,9 +21,7 @@ package org.apache.tools.ant;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-
-import static org.apache.tools.ant.AntAssert.assertContains;
-import static org.junit.Assert.fail;
+import org.junit.rules.ExpectedException;
 
 /**
  * Simple tests of build file processing
@@ -33,6 +31,9 @@ public class CaseTest {
     @Rule
     public BuildFileRule buildRule = new BuildFileRule();
 
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
     @Before
     public void setUp() {
         buildRule.configureProject("src/etc/testcases/core/case.xml");
@@ -49,15 +50,12 @@ public class CaseTest {
 
     /**
      * Test whether the build file uses case when determining
-     * task names.
+     * task names. Task name should be case sensitive.
      */
     @Test
     public void testTaskCase() {
-        try {
-            buildRule.executeTarget("taskcase");
-            fail("Build exception should have been thrown due to case sensitivity of name");
-        } catch (BuildException ex) {
-            assertContains("Task names should be case sensitive", "Problem: failed to create task or type ecHO", ex.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("Problem: failed to create task or type ecHO");
+        buildRule.executeTarget("taskcase");
     }
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/81c3e6e3/src/tests/junit/org/apache/tools/ant/ExtendedTaskdefTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/ExtendedTaskdefTest.java b/src/tests/junit/org/apache/tools/ant/ExtendedTaskdefTest.java
index e5413b6..74143fa 100644
--- a/src/tests/junit/org/apache/tools/ant/ExtendedTaskdefTest.java
+++ b/src/tests/junit/org/apache/tools/ant/ExtendedTaskdefTest.java
@@ -17,14 +17,11 @@
  */
 package org.apache.tools.ant;
 
-import static org.junit.Assert.fail;
-
-import static org.apache.tools.ant.AntAssert.assertContains;
-
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 
 /**
  * created 16-Mar-2006 12:25:12
@@ -35,6 +32,9 @@ public class ExtendedTaskdefTest {
     @Rule
     public BuildFileRule buildRule = new BuildFileRule();
 
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
     @Before
     public void setUp() {
         buildRule.configureProject("src/etc/testcases/core/extended-taskdef.xml");
@@ -45,24 +45,24 @@ public class ExtendedTaskdefTest {
         buildRule.executeTarget("teardown");
     }
 
+    /**
+     * Exception should be thrown by a subclass
+     */
     @Test
     public void testRun() {
-        try {
-            buildRule.executeTarget("testRun");
-            fail("BuildException should have been thrown");
-        } catch (BuildException ex) {
-            assertContains("exception thrown by the subclass", "executing the Foo task", ex.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("executing the Foo task");
+        buildRule.executeTarget("testRun");
     }
 
+    /**
+     * Exception should be thrown by a subclass
+     */
     @Test
     public void testRun2() {
-        try {
-            buildRule.executeTarget("testRun2");
-            fail("BuildException should have been thrown");
-        } catch (BuildException ex) {
-            assertContains("exception thrown by the subclass", "executing the Foo task", ex.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("executing the Foo task");
+        buildRule.executeTarget("testRun2");
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/81c3e6e3/src/tests/junit/org/apache/tools/ant/IncludeTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/IncludeTest.java b/src/tests/junit/org/apache/tools/ant/IncludeTest.java
index 80e53fe..444008d 100644
--- a/src/tests/junit/org/apache/tools/ant/IncludeTest.java
+++ b/src/tests/junit/org/apache/tools/ant/IncludeTest.java
@@ -18,13 +18,16 @@
 
 package org.apache.tools.ant;
 
-import static org.apache.tools.ant.AntAssert.assertContains;
+import static org.hamcrest.Matchers.both;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasProperty;
+import static org.hamcrest.Matchers.startsWith;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 
 /**
  * Test the build file inclusion using XML entities.
@@ -35,6 +38,9 @@ public class IncludeTest {
     @Rule
     public BuildFileRule buildRule = new BuildFileRule();
 
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
     @Test
     public void test1() {
         buildRule.configureProject("src/etc/testcases/core/include/basic/include.xml");
@@ -72,59 +78,39 @@ public class IncludeTest {
 
     @Test
     public void testParseErrorInIncluding() {
-        try {
+        thrown.expect(BuildException.class);
+        thrown.expect(hasProperty("location", hasProperty("fileName",
+                containsString("build.xml"))));
             buildRule.configureProject("src/etc/testcases/core/include/including_file_parse_error/build.xml");
-            fail("should have caused a parser exception");
-        } catch (BuildException e) {
-            assertContains(e.getLocation().toString()
-                       + " should refer to build.xml",
-                       "build.xml:", e.getLocation().toString());
-        }
     }
 
     @Test
     public void testTaskErrorInIncluding() {
+        thrown.expect(BuildException.class);
+        thrown.expect(hasProperty("location",
+                both(hasProperty("fileName", containsString("build.xml")))
+                        .and(hasProperty("lineNumber", equalTo(14)))));
+        thrown.expectMessage(startsWith("Warning: Could not find file "));
         buildRule.configureProject("src/etc/testcases/core/include/including_file_task_error/build.xml");
-        try {
-            buildRule.executeTarget("test");
-            fail("should have cause a build failure");
-        } catch (BuildException e) {
-            assertTrue(e.getMessage()
-                       + " should start with \'Warning: Could not find",
-                         e.getMessage().startsWith("Warning: Could not find file "));
-            assertTrue(e.getLocation().toString()
-                       + " should end with build.xml:14: ",
-                       e.getLocation().toString().endsWith("build.xml:14: "));
-        }
     }
 
     @Test
     public void testParseErrorInIncluded() {
-        try {
-            buildRule.configureProject("src/etc/testcases/core/include/included_file_parse_error/build.xml");
-            fail("should have caused a parser exception");
-        } catch (BuildException e) {
-            assertContains(e.getLocation().toString()
-                       + " should refer to included_file.xml",
-                       "included_file.xml:",
-                       e.getLocation().toString());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expect(hasProperty("location",
+                hasProperty("fileName", containsString("included_file.xml"))));
+        buildRule.configureProject("src/etc/testcases/core/include/included_file_parse_error/build.xml");
     }
 
     @Test
     public void testTaskErrorInIncluded() {
+        thrown.expect(BuildException.class);
+        thrown.expect(hasProperty("location",
+                both(hasProperty("fileName", containsString("included_file.xml")))
+                        .and(hasProperty("lineNumber", equalTo(2)))));
+        thrown.expectMessage(startsWith("Warning: Could not find file "));
         buildRule.configureProject("src/etc/testcases/core/include/included_file_task_error/build.xml");
-        try {
-            buildRule.executeTarget("test");
-            fail("should have cause a build failure");
-        } catch (BuildException e) {
-            assertTrue(e.getMessage()
-                       + " should start with \'Warning: Could not find",
-                         e.getMessage().startsWith("Warning: Could not find file "));
-            assertTrue(e.getLocation().toString()
-                       + " should end with included_file.xml:2: ",
-                       e.getLocation().toString().endsWith("included_file.xml:2: "));
-        }
+        buildRule.executeTarget("test");
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ant/blob/81c3e6e3/src/tests/junit/org/apache/tools/ant/LoaderRefTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/LoaderRefTest.java b/src/tests/junit/org/apache/tools/ant/LoaderRefTest.java
index 668170b..14c5a15 100644
--- a/src/tests/junit/org/apache/tools/ant/LoaderRefTest.java
+++ b/src/tests/junit/org/apache/tools/ant/LoaderRefTest.java
@@ -18,12 +18,10 @@
 
 package org.apache.tools.ant;
 
-import static org.apache.tools.ant.AntAssert.assertContains;
-import static org.junit.Assert.fail;
-
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 
 /**
  */
@@ -32,6 +30,9 @@ public class LoaderRefTest {
     @Rule
     public BuildFileRule buildRule = new BuildFileRule();
 
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
     @Before
     public void setUp() {
         buildRule.configureProject("src/etc/testcases/core/loaderref/loaderref.xml");
@@ -41,11 +42,8 @@ public class LoaderRefTest {
     // override allowed on <available>
     @Test
     public void testBadRef() {
-        try {
-            buildRule.executeTarget("testbadref");
-            fail("BuildRule should have thrown an exception due to a bad classloader being specified");
-        } catch (BuildException ex) {
-            assertContains("Should fail due to ref not being a class loader", "does not reference a class loader", ex.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("does not reference a class loader");
+        buildRule.executeTarget("testbadref");
     }
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/81c3e6e3/src/tests/junit/org/apache/tools/ant/LocationTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/LocationTest.java b/src/tests/junit/org/apache/tools/ant/LocationTest.java
index e6e3d53..035167f 100644
--- a/src/tests/junit/org/apache/tools/ant/LocationTest.java
+++ b/src/tests/junit/org/apache/tools/ant/LocationTest.java
@@ -25,10 +25,11 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 
+import static org.hamcrest.Matchers.containsString;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertThat;
 
 public class LocationTest {
 
@@ -71,16 +72,16 @@ public class LocationTest {
     public void testMacrodefWrappedTask() {
         buildRule.executeTarget("testMacrodefWrappedTask");
         Echo e = buildRule.getProject().getReference("echo3");
-        assertTrue(buildRule.getLog().contains("Line: "
-                + (e.getLocation().getLineNumber() + 1)));
+        assertThat(buildRule.getLog(),
+                containsString("Line: " + (e.getLocation().getLineNumber() + 1)));
     }
 
     @Test
     public void testPresetdefWrappedTask() {
         buildRule.executeTarget("testPresetdefWrappedTask");
         Echo e = buildRule.getProject().getReference("echo4");
-        assertTrue(buildRule.getLog().contains("Line: "
-                + (e.getLocation().getLineNumber() + 1)));
+        assertThat(buildRule.getLog(),
+                containsString("Line: " + (e.getLocation().getLineNumber() + 1)));
     }
 
     public static class EchoLocation extends Task {

http://git-wip-us.apache.org/repos/asf/ant/blob/81c3e6e3/src/tests/junit/org/apache/tools/ant/ProjectHelperRepositoryTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/ProjectHelperRepositoryTest.java b/src/tests/junit/org/apache/tools/ant/ProjectHelperRepositoryTest.java
index 6b766f3..3d72a75 100644
--- a/src/tests/junit/org/apache/tools/ant/ProjectHelperRepositoryTest.java
+++ b/src/tests/junit/org/apache/tools/ant/ProjectHelperRepositoryTest.java
@@ -26,7 +26,6 @@ import org.apache.tools.ant.types.resources.StringResource;
 import org.junit.Test;
 
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 /**
  * Testing around the management of the project helpers
@@ -74,32 +73,20 @@ public class ProjectHelperRepositoryTest {
         assertTrue(helper instanceof ProjectHelper2);
     }
 
-    @Test
-    public void testNoDefaultContructor() {
+    @Test(expected = BuildException.class)
+    public void testNoDefaultConstructor() {
 
-        class IncrrectHelper extends ProjectHelper {
+        class IncorrectHelper extends ProjectHelper {
             // the default constructor is not visible to ant here
         }
 
-        ProjectHelperRepository repo = ProjectHelperRepository.getInstance();
-        try {
-            repo.registerProjectHelper(IncrrectHelper.class);
-            fail("Registring an helper with no default constructor should fail");
-        } catch (BuildException e) {
-            // ok
-            //TODO we should be asserting a value in here
-        }
+        ProjectHelperRepository.getInstance().registerProjectHelper(IncorrectHelper.class);
+        // TODO we should be asserting a value in here
     }
 
-    @Test
-    public void testUnkwnowHelper() {
-        ProjectHelperRepository repo = ProjectHelperRepository.getInstance();
-        try {
-            repo.registerProjectHelper("xxx.yyy.zzz.UnknownHelper");
-            fail("Registring an unknwon helper should fail");
-        } catch (BuildException e) {
-            // ok
-            //TODO we should be asserting a value in here
-        }
+    @Test(expected = BuildException.class)
+    public void testUnknownHelper() {
+        ProjectHelperRepository.getInstance().registerProjectHelper("xxx.yyy.zzz.UnknownHelper");
+        // TODO we should be asserting a value in here
     }
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/81c3e6e3/src/tests/junit/org/apache/tools/ant/ProjectTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/ProjectTest.java b/src/tests/junit/org/apache/tools/ant/ProjectTest.java
index 15340b6..b98cf73 100644
--- a/src/tests/junit/org/apache/tools/ant/ProjectTest.java
+++ b/src/tests/junit/org/apache/tools/ant/ProjectTest.java
@@ -32,12 +32,13 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 
-import static org.apache.tools.ant.AntAssert.assertContains;
+import static org.hamcrest.Matchers.containsString;
 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;
+import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -268,7 +269,7 @@ public class ProjectTest {
         // overriding target from imported buildfile is allowed
         buildRule.configureProject("src/etc/testcases/core/duplicate-target2.xml");
         buildRule.executeTarget("once");
-        assertContains("once from buildfile", buildRule.getLog());
+        assertThat(buildRule.getLog(), containsString("once from buildfile"));
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ant/blob/81c3e6e3/src/tests/junit/org/apache/tools/ant/PropertyFileCLITest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/PropertyFileCLITest.java b/src/tests/junit/org/apache/tools/ant/PropertyFileCLITest.java
index 3718882..4f5e78e 100644
--- a/src/tests/junit/org/apache/tools/ant/PropertyFileCLITest.java
+++ b/src/tests/junit/org/apache/tools/ant/PropertyFileCLITest.java
@@ -24,7 +24,8 @@ import java.io.FileWriter;
 import org.apache.tools.ant.util.FileUtils;
 import org.junit.Test;
 
-import static org.apache.tools.ant.AntAssert.assertContains;
+import static org.hamcrest.Matchers.containsString;
+import static org.junit.Assert.assertThat;
 
 public class PropertyFileCLITest {
 
@@ -54,7 +55,7 @@ public class PropertyFileCLITest {
                     "-l", log.getAbsolutePath()
                 }, null, null);
             String l = FileUtils.safeReadFully(fr = new FileReader(log));
-            assertContains("Hello, world", l);
+            assertThat(l, containsString("Hello, world"));
         } finally {
             FileUtils.close(fw);
             FileUtils.close(fr);

http://git-wip-us.apache.org/repos/asf/ant/blob/81c3e6e3/src/tests/junit/org/apache/tools/ant/TaskContainerTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/TaskContainerTest.java b/src/tests/junit/org/apache/tools/ant/TaskContainerTest.java
index 491d361..888bbeb 100644
--- a/src/tests/junit/org/apache/tools/ant/TaskContainerTest.java
+++ b/src/tests/junit/org/apache/tools/ant/TaskContainerTest.java
@@ -22,7 +22,8 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 
-import static org.junit.Assert.assertTrue;
+import static org.hamcrest.Matchers.containsString;
+import static org.junit.Assert.assertThat;
 
 public class TaskContainerTest {
 
@@ -37,30 +38,30 @@ public class TaskContainerTest {
     @Test
     public void testPropertyExpansion() {
         buildRule.executeTarget("testPropertyExpansion");
-        assertTrue("attribute worked",
-                buildRule.getLog().contains("As attribute: it worked"));
-        assertTrue("nested text worked",
-                buildRule.getLog().contains("As nested text: it worked"));
+        assertThat("attribute worked", buildRule.getLog(),
+                containsString(("As attribute: it worked")));
+        assertThat("nested text worked", buildRule.getLog(),
+                containsString(("As nested text: it worked")));
     }
 
     @Test
     public void testTaskdef() {
         buildRule.executeTarget("testTaskdef");
-        assertTrue("attribute worked",
-                buildRule.getLog().contains("As attribute: it worked"));
-        assertTrue("nested text worked",
-                buildRule.getLog().contains("As nested text: it worked"));
-        assertTrue("nested text worked",
-                buildRule.getLog().contains("As nested task: it worked"));
+        assertThat("attribute worked", buildRule.getLog(),
+                containsString(("As attribute: it worked")));
+        assertThat("nested text worked", buildRule.getLog(),
+                containsString(("As nested text: it worked")));
+        assertThat("nested text worked", buildRule.getLog(),
+                containsString(("As nested task: it worked")));
     }
 
     @Test
     public void testCaseInsensitive() {
         buildRule.executeTarget("testCaseInsensitive");
-        assertTrue("works outside of container",
-                buildRule.getLog().contains("hello "));
-        assertTrue("works inside of container",
-                buildRule.getLog().contains("world"));
+        assertThat("works outside of container", buildRule.getLog(),
+                containsString(("hello ")));
+        assertThat("works inside of container", buildRule.getLog(),
+                containsString(("world")));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/81c3e6e3/src/tests/junit/org/apache/tools/ant/filters/DynamicFilterTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/filters/DynamicFilterTest.java b/src/tests/junit/org/apache/tools/ant/filters/DynamicFilterTest.java
index 85df0ce..b85b41e 100644
--- a/src/tests/junit/org/apache/tools/ant/filters/DynamicFilterTest.java
+++ b/src/tests/junit/org/apache/tools/ant/filters/DynamicFilterTest.java
@@ -28,7 +28,8 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 
-import static org.apache.tools.ant.AntAssert.assertContains;
+import static org.hamcrest.Matchers.containsString;
+import static org.junit.Assert.assertThat;
 
 public class DynamicFilterTest {
 
@@ -46,7 +47,7 @@ public class DynamicFilterTest {
         buildRule.executeTarget("dynamicfilter");
         String content = FileUtilities.getFileContents(
                 new File(buildRule.getProject().getProperty("output") + "/dynamicfilter"));
-        assertContains("hellO wOrld", content);
+        assertThat(content, containsString("hellO wOrld"));
     }
 
     public static class CustomFilter implements ChainableReader {

http://git-wip-us.apache.org/repos/asf/ant/blob/81c3e6e3/src/tests/junit/org/apache/tools/ant/filters/TokenFilterTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/filters/TokenFilterTest.java b/src/tests/junit/org/apache/tools/ant/filters/TokenFilterTest.java
index 7d82670..fb60f2c 100644
--- a/src/tests/junit/org/apache/tools/ant/filters/TokenFilterTest.java
+++ b/src/tests/junit/org/apache/tools/ant/filters/TokenFilterTest.java
@@ -18,9 +18,10 @@
 
 package org.apache.tools.ant.filters;
 
-import static org.apache.tools.ant.AntAssert.assertContains;
-import static org.apache.tools.ant.AntAssert.assertNotContains;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.not;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assume.assumeTrue;
 
@@ -58,57 +59,57 @@ public class TokenFilterTest {
     @Test
     public void testTrimignore() {
         buildRule.executeTarget("trimignore");
-        assertContains("Hello-World", buildRule.getLog());
+        assertThat(buildRule.getLog(), containsString("Hello-World"));
     }
 
     @Test
     public void testStringTokenizer() {
         buildRule.executeTarget("stringtokenizer");
-        assertContains("#This#is#a#number#of#words#", buildRule.getLog());
+        assertThat(buildRule.getLog(), containsString("#This#is#a#number#of#words#"));
     }
 
     @Test
     public void testUnixLineOutput() throws IOException {
         buildRule.executeTarget("unixlineoutput");
-        assertContains("\nThis\nis\na\nnumber\nof\nwords\n",
-                getFileString(buildRule.getProject().getProperty("output") + "/unixlineoutput"));
+        assertThat(getFileString(buildRule.getProject().getProperty("output") + "/unixlineoutput"),
+                containsString("\nThis\nis\na\nnumber\nof\nwords\n"));
     }
 
     @Test
     public void testDosLineOutput() throws IOException {
 
         buildRule.executeTarget("doslineoutput");
-        assertContains("\r\nThis\r\nis\r\na\r\nnumber\r\nof\r\nwords\r\n",
-                getFileString(buildRule.getProject().getProperty("output") + "/doslineoutput"));
+        assertThat(getFileString(buildRule.getProject().getProperty("output") + "/doslineoutput"),
+                containsString("\r\nThis\r\nis\r\na\r\nnumber\r\nof\r\nwords\r\n"));
     }
 
     @Test
     public void testFileTokenizer() throws IOException {
         buildRule.executeTarget("filetokenizer");
         String contents = getFileString(buildRule.getProject().getProperty("output") + "/filetokenizer");
-        assertContains("   of words", contents);
-        assertNotContains(" This is", contents);
+        assertThat(contents, containsString("   of words"));
+        assertThat(contents, not(containsString(" This is")));
     }
 
     @Test
     public void testReplaceString() throws IOException {
         buildRule.executeTarget("replacestring");
-        assertContains("this is the moon",
-                getFileString(buildRule.getProject().getProperty("output") + "/replacestring"));
+        assertThat(getFileString(buildRule.getProject().getProperty("output") + "/replacestring"),
+                containsString("this is the moon"));
     }
 
     @Test
     public void testReplaceStrings() {
         buildRule.executeTarget("replacestrings");
-        assertContains("bar bar bar", buildRule.getLog());
+        assertThat(buildRule.getLog(), containsString("bar bar bar"));
     }
 
     @Test
     public void testContainsString() throws IOException {
         buildRule.executeTarget("containsstring");
         String contents = getFileString(buildRule.getProject().getProperty("output") + "/containsstring");
-        assertContains("this is a line contains foo", contents);
-        assertNotContains("this line does not", contents);
+        assertThat(contents, containsString("this is a line contains foo"));
+        assertThat(contents, not(containsString("this line does not")));
     }
 
     @Test
@@ -120,12 +121,12 @@ public class TokenFilterTest {
 
         buildRule.executeTarget("replaceregex");
         String contents = getFileString(buildRule.getProject().getProperty("output") + "/replaceregex");
-        assertContains("world world world world", contents);
-        assertContains("dog Cat dog", contents);
-        assertContains("moon Sun Sun", contents);
-        assertContains("found WhiteSpace", contents);
-        assertContains("Found digits [1234]", contents);
-        assertNotContains("This is a line with digits", contents);
+        assertThat(contents, containsString("world world world world"));
+        assertThat(contents, containsString("dog Cat dog"));
+        assertThat(contents, containsString("moon Sun Sun"));
+        assertThat(contents, containsString("found WhiteSpace"));
+        assertThat(contents, containsString("Found digits [1234]"));
+        assertThat(contents, not(containsString("This is a line with digits")));
     }
 
     @Test
@@ -135,15 +136,16 @@ public class TokenFilterTest {
                 getFileString(buildRule.getProject().getProperty("output") + "/replaceregexp").contains("bye world"));
 
         buildRule.executeTarget("filterreplaceregex");
-        String contents = getFileString(buildRule.getProject().getProperty("output") + "/filterreplaceregex");
-        assertContains("world world world world", contents);
+        assertThat(getFileString(buildRule.getProject().getProperty("output") + "/filterreplaceregex"),
+                containsString("world world world world"));
 
     }
 
     @Test
     public void testHandleDollerMatch() throws IOException {
         buildRule.executeTarget("hasregex");
-        assumeTrue("Regex not present", getFileString(buildRule.getProject().getProperty("output") + "/replaceregexp").contains("bye world"));
+        assumeTrue("Regex not present",
+                getFileString(buildRule.getProject().getProperty("output") + "/replaceregexp").contains("bye world"));
 
         buildRule.executeTarget("dollermatch");
     }
@@ -154,7 +156,7 @@ public class TokenFilterTest {
         String contents = getFileString(buildRule.getProject().getProperty("output") + "/trimfile");
         assertTrue("no ws at start", contents.startsWith("This is th"));
         assertTrue("no ws at end", contents.endsWith("second line."));
-        assertContains("  This is the second", contents);
+        assertThat(contents, containsString("  This is the second"));
     }
 
     @Test
@@ -163,21 +165,21 @@ public class TokenFilterTest {
         String contents = getFileString(buildRule.getProject().getProperty("output") + "/trimfilebyline");
         assertFalse("no ws at start", contents.startsWith("This is th"));
         assertFalse("no ws at end", contents.endsWith("second line."));
-        assertNotContains("  This is the second", contents);
-        assertContains("file.\nThis is the second", contents);
+        assertThat(contents, not(containsString("  This is the second")));
+        assertThat(contents, containsString("file.\nThis is the second"));
     }
 
     @Test
     public void testFilterReplaceString() throws IOException {
         buildRule.executeTarget("filterreplacestring");
-        String contents = getFileString(buildRule.getProject().getProperty("output") + "/filterreplacestring");
-        assertContains("This is the moon", contents);
+        assertThat(getFileString(buildRule.getProject().getProperty("output") + "/filterreplacestring"),
+                containsString("This is the moon"));
     }
 
     @Test
     public void testFilterReplaceStrings() {
         buildRule.executeTarget("filterreplacestrings");
-        assertContains("bar bar bar", buildRule.getLog());
+        assertThat(buildRule.getLog(), containsString("bar bar bar"));
     }
 
     @Test
@@ -189,40 +191,42 @@ public class TokenFilterTest {
 
         buildRule.executeTarget("containsregex");
         String contents = getFileString(buildRule.getProject().getProperty("output") + "/containsregex");
-        assertContains("hello world", contents);
-        assertNotContains("this is the moon", contents);
-        assertContains("World here", contents);
+        assertThat(contents, containsString("hello world"));
+        assertThat(contents, not(containsString("this is the moon")));
+        assertThat(contents, containsString("World here"));
     }
 
     @Test
     public void testFilterContainsRegex() throws IOException {
         buildRule.executeTarget("hasregex");
-        assumeTrue("Regex not present", getFileString(buildRule.getProject().getProperty("output") + "/replaceregexp").contains("bye world"));
+        assumeTrue("Regex not present",
+                getFileString(buildRule.getProject().getProperty("output") + "/replaceregexp").contains("bye world"));
 
         buildRule.executeTarget("filtercontainsregex");
         String contents = getFileString(buildRule.getProject().getProperty("output") + "/filtercontainsregex");
-        assertContains("hello world", contents);
-        assertNotContains("this is the moon", contents);
-        assertContains("World here", contents);
+        assertThat(contents, containsString("hello world"));
+        assertThat(contents, not(containsString("this is the moon")));
+        assertThat(contents, containsString("World here"));
     }
 
     @Test
     public void testContainsRegex2() throws IOException {
         buildRule.executeTarget("hasregex");
-        assumeTrue("Regex not present", getFileString(buildRule.getProject().getProperty("output") + "/replaceregexp").contains("bye world"));
+        assumeTrue("Regex not present",
+                getFileString(buildRule.getProject().getProperty("output") + "/replaceregexp").contains("bye world"));
 
         buildRule.executeTarget("containsregex2");
-        String contents = getFileString(buildRule.getProject().getProperty("output") + "/containsregex2");
-        assertContains("void register_bits();", contents);
+        assertThat(getFileString(buildRule.getProject().getProperty("output") + "/containsregex2"),
+                containsString("void register_bits();"));
     }
 
     @Test
     public void testDeleteCharacters() throws IOException {
         buildRule.executeTarget("deletecharacters");
         String contents = getFileString(buildRule.getProject().getProperty("output") + "/deletechars");
-        assertNotContains("#", contents);
-        assertNotContains("*", contents);
-        assertContains("This is some ", contents);
+        assertThat(contents, not(containsString("#")));
+        assertThat(contents, not(containsString("*")));
+        assertThat(contents, containsString("This is some "));
     }
 
     @Test
@@ -230,21 +234,25 @@ public class TokenFilterTest {
         assumeTrue("Project does not have 'testScriptFilter' target",
                 buildRule.getProject().getTargets().contains("testScriptFilter"));
         buildRule.executeTarget("scriptfilter");
-        assertContains("HELLO WORLD", getFileString(buildRule.getProject().getProperty("output") + "/scriptfilter"));
+        assertThat(getFileString(buildRule.getProject().getProperty("output") + "/scriptfilter"),
+                containsString("HELLO WORLD"));
 
     }
 
     @Test
     public void testScriptFilter2() throws IOException {
-        assumeTrue("Project does not have 'testScriptFilter' target", buildRule.getProject().getTargets().contains("testScriptFilter"));
+        assumeTrue("Project does not have 'testScriptFilter' target",
+                buildRule.getProject().getTargets().contains("testScriptFilter"));
         buildRule.executeTarget("scriptfilter2");
-        assertContains("HELLO MOON", getFileString(buildRule.getProject().getProperty("output") + "/scriptfilter2"));
+        assertThat(getFileString(buildRule.getProject().getProperty("output") + "/scriptfilter2"),
+                containsString("HELLO MOON"));
     }
 
     @Test
     public void testCustomTokenFilter() throws IOException {
         buildRule.executeTarget("customtokenfilter");
-        assertContains("Hello World", getFileString(buildRule.getProject().getProperty("output") + "/custom"));
+        assertThat(getFileString(buildRule.getProject().getProperty("output") + "/custom"),
+                containsString("Hello World"));
     }
 
     // ------------------------------------------------------
@@ -255,7 +263,7 @@ public class TokenFilterTest {
         Reader r = null;
         try {
             r = new FileReader(FILE_UTILS.resolveFile(buildRule.getProject().getBaseDir(),filename));
-            return  FileUtils.readFully(r);
+            return FileUtils.readFully(r);
         }
         finally {
             FileUtils.close(r);

http://git-wip-us.apache.org/repos/asf/ant/blob/81c3e6e3/src/tests/junit/org/apache/tools/ant/launch/LocatorTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/launch/LocatorTest.java b/src/tests/junit/org/apache/tools/ant/launch/LocatorTest.java
index b4e1e9b..fc43899 100644
--- a/src/tests/junit/org/apache/tools/ant/launch/LocatorTest.java
+++ b/src/tests/junit/org/apache/tools/ant/launch/LocatorTest.java
@@ -22,11 +22,12 @@ import java.io.File;
 import org.apache.tools.ant.taskdefs.condition.Os;
 import org.junit.Before;
 import org.junit.Ignore;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 
-import static junit.framework.Assert.assertEquals;
-import static org.apache.tools.ant.AntAssert.assertContains;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assume.assumeTrue;
 
 /** Test the locator in the ant-launch JAR */
 public class LocatorTest {
@@ -36,6 +37,8 @@ public class LocatorTest {
     private static final String SHARED_JAR_URI = "jar:file:" + LAUNCHER_JAR
             + "!/org/apache/tools/ant/launch/Launcher.class";
 
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
 
     @Before
     public void setUp() {
@@ -136,25 +139,19 @@ public class LocatorTest {
      */
     @Test
     public void testFileFromRemoteShare() {
+        assumeTrue("not Windows", windows);
         String resolved = Locator.fromJarURI(SHARED_JAR_URI);
         File f = new File(resolved);
         String path = f.getAbsolutePath();
-        if (windows) {
-            assertEquals(0, path.indexOf("\\\\"));
-        }
+        assertEquals(0, path.indexOf("\\\\"));
     }
 
     @Test
     public void testHttpURI() {
         String url = "http://ant.apache.org";
-        try {
-            Locator.fromURI(url);
-            fail("Exception should have been thrown");
-        } catch (IllegalArgumentException e) {
-            String message = e.getMessage();
-            assertContains(Locator.ERROR_NOT_FILE_URI, message);
-            assertContains(url, message);
-        }
+        thrown.expect(IllegalArgumentException.class);
+        thrown.expectMessage(Locator.ERROR_NOT_FILE_URI + url);
+        Locator.fromURI(url);
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ant/blob/81c3e6e3/src/tests/junit/org/apache/tools/ant/taskdefs/AbstractCvsTaskTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/AbstractCvsTaskTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/AbstractCvsTaskTest.java
index 1f5ceea..7b7e6c3 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/AbstractCvsTaskTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/AbstractCvsTaskTest.java
@@ -25,8 +25,9 @@ import org.junit.Test;
 
 import java.io.File;
 
-import static org.apache.tools.ant.AntAssert.assertContains;
+import static org.hamcrest.Matchers.containsString;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 
 /**
@@ -57,7 +58,7 @@ public class AbstractCvsTaskTest {
         File f = new File(buildRule.getProject().getProperty("output") + "/src/Makefile");
         assertFalse("starting empty", f.exists());
         buildRule.executeTarget("package-attribute");
-        assertContains("U src/Makefile", buildRule.getLog());
+        assertThat(buildRule.getLog(), containsString("U src/Makefile"));
         assertTrue("now it is there", f.exists());
     }
 
@@ -66,7 +67,7 @@ public class AbstractCvsTaskTest {
         File f = new File(buildRule.getProject().getProperty("output") + "/src/Makefile");
         assertFalse("starting empty", f.exists());
         buildRule.executeTarget("tag-attribute");
-        assertContains("OPENBSD_5_3", buildRule.getLog());
+        assertThat(buildRule.getLog(), containsString("OPENBSD_5_3"));
         assertTrue("now it is there", f.exists());
     }
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/81c3e6e3/src/tests/junit/org/apache/tools/ant/taskdefs/AntStructureTest.java
----------------------------------------------------------------------
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 1eb24bc..8c05288 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/AntStructureTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/AntStructureTest.java
@@ -29,9 +29,10 @@ import org.junit.Test;
 import java.io.PrintWriter;
 import java.util.Hashtable;
 
-import static org.apache.tools.ant.AntAssert.assertContains;
+import static org.hamcrest.Matchers.containsString;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -70,7 +71,7 @@ public class AntStructureTest {
         // the test has likely been loaded via a different classloader
         // than this class.  Therefore we make the printer assert its
         // state and only check for the tail invocation.
-        assertContains(MyPrinter.TAIL_CALLED, buildRule.getLog());
+        assertThat(buildRule.getLog(), containsString(MyPrinter.TAIL_CALLED));
     }
 
     public static class MyPrinter implements AntStructure.StructurePrinter {

http://git-wip-us.apache.org/repos/asf/ant/blob/81c3e6e3/src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java
----------------------------------------------------------------------
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 9b93c77..778fba7 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java
@@ -34,12 +34,13 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 
-import static org.apache.tools.ant.AntAssert.assertContains;
+import static org.hamcrest.Matchers.containsString;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -290,7 +291,7 @@ public class AntTest {
         buildRule.getProject().setUserProperty("test", "7");
         buildRule.executeTarget("test-property-override-inheritall-start");
 
-        assertContains("The value of test is 7", buildRule.getLog());
+        assertThat(buildRule.getLog(), containsString("The value of test is 7"));
     }
 
     @Test
@@ -298,28 +299,28 @@ public class AntTest {
         buildRule.getProject().setUserProperty("test", "7");
         buildRule.executeTarget("test-property-override-no-inheritall-start");
 
-        assertContains("The value of test is 7", buildRule.getLog());
+        assertThat(buildRule.getLog(), containsString("The value of test is 7"));
     }
 
     @Test
     public void testOverrideWinsInheritAll() {
         buildRule.executeTarget("test-property-override-inheritall-start");
 
-        assertContains("The value of test is 4", buildRule.getLog());
+        assertThat(buildRule.getLog(), containsString("The value of test is 4"));
     }
 
     @Test
     public void testOverrideWinsNoInheritAll() {
         buildRule.executeTarget("test-property-override-no-inheritall-start");
-        assertContains("The value of test is 4", buildRule.getLog());
+        assertThat(buildRule.getLog(), containsString("The value of test is 4"));
     }
 
     @Test
     public void testPropertySet() {
         buildRule.executeTarget("test-propertyset");
-        assertTrue(buildRule.getLog().contains("test1 is ${test1}"));
-        assertTrue(buildRule.getLog().contains("test2 is ${test2}"));
-        assertTrue(buildRule.getLog().contains("test1.x is 1"));
+        assertThat(buildRule.getLog(), containsString("test1 is ${test1}"));
+        assertThat(buildRule.getLog(), containsString("test2 is ${test2}"));
+        assertThat(buildRule.getLog(), containsString("test1.x is 1"));
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ant/blob/81c3e6e3/src/tests/junit/org/apache/tools/ant/taskdefs/CallTargetTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/CallTargetTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/CallTargetTest.java
index 6100d06..81f7cbf 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/CallTargetTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/CallTargetTest.java
@@ -26,8 +26,9 @@ import org.junit.Test;
 
 import java.util.Vector;
 
-import static org.apache.tools.ant.AntAssert.assertContains;
+import static org.hamcrest.Matchers.containsString;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
 import static org.junit.Assert.fail;
 
 /**
@@ -47,7 +48,7 @@ public class CallTargetTest {
     @Test
     public void testInheritRefFileSet() {
         buildRule.executeTarget("testinheritreffileset");
-        assertContains("calltarget.xml", buildRule.getLog());
+        assertThat(buildRule.getLog(), containsString("calltarget.xml"));
     }
 
     // see bugrep 21724 (references not passing through with antcall)
@@ -64,7 +65,7 @@ public class CallTargetTest {
         v.add("call-multi");
         v.add("call-multi");
         buildRule.getProject().executeTargets(v);
-        assertContains("multi is SETmulti is SET", buildRule.getLog());
+        assertThat(buildRule.getLog(), containsString("multi is SETmulti is SET"));
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ant/blob/81c3e6e3/src/tests/junit/org/apache/tools/ant/taskdefs/ConcatTest.java
----------------------------------------------------------------------
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 2491937..e4e8b3f 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/ConcatTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ConcatTest.java
@@ -29,9 +29,10 @@ import org.junit.Test;
 import java.io.File;
 import java.io.IOException;
 
-import static org.apache.tools.ant.AntAssert.assertContains;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.not;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -150,7 +151,7 @@ public class ConcatTest {
         String filename = "src/etc/testcases/taskdefs/thisfiledoesnotexist"
             .replace('/', File.separatorChar);
         buildRule.executeTarget("test6");
-        assertContains(filename + " does not exist", buildRule.getLog());
+        assertThat(buildRule.getLog(), containsString(filename + " does not exist"));
     }
 
     @Test
@@ -200,7 +201,7 @@ public class ConcatTest {
     @Test
     public void testFilter() {
         buildRule.executeTarget("testfilter");
-        assertTrue(buildRule.getLog().contains("REPLACED"));
+        assertThat(buildRule.getLog(), containsString("REPLACED"));
     }
 
     @Test
@@ -252,7 +253,7 @@ public class ConcatTest {
     @Test
     public void testfilterinline() {
         buildRule.executeTarget("testfilterinline");
-        assertTrue(buildRule.getLog().contains("REPLACED"));
+        assertThat(buildRule.getLog(), containsString("REPLACED"));
     }
 
     /**
@@ -261,8 +262,8 @@ public class ConcatTest {
     @Test
     public void testmultireader() {
         buildRule.executeTarget("testmultireader");
-        assertTrue(buildRule.getLog().contains("Bye"));
-        assertFalse(buildRule.getLog().contains("Hello"));
+        assertThat(buildRule.getLog(), containsString("Bye"));
+        assertThat(buildRule.getLog(), not(containsString("Hello")));
     }
     /**
      * Check if fixlastline works
@@ -270,8 +271,8 @@ public class ConcatTest {
     @Test
     public void testfixlastline() throws IOException {
         buildRule.executeTarget("testfixlastline");
-        assertContains("end of line" + System.lineSeparator() + "This has",
-                FileUtilities.getFileContents(buildRule.getProject(), "concat.line4"));
+        assertThat(FileUtilities.getFileContents(buildRule.getProject(), "concat.line4"),
+                containsString("end of line" + System.lineSeparator() + "This has"));
     }
 
     /**
@@ -280,7 +281,8 @@ public class ConcatTest {
     @Test
     public void testfixlastlineeol() throws IOException {
         buildRule.executeTarget("testfixlastlineeol");
-        assertContains("end of line\rThis has", FileUtilities.getFileContents(buildRule.getProject(), "concat.linecr"));
+        assertThat(FileUtilities.getFileContents(buildRule.getProject(), "concat.linecr"),
+                containsString("end of line\rThis has"));
     }
 
     @Test
@@ -300,10 +302,8 @@ public class ConcatTest {
         throws IOException {
         buildRule.executeTarget(target);
         String content = FileUtilities.getFileContents(buildRule.getProject(), filename);
-        assertTrue(
-            "expecting file " + filename + " to contain " +
-            contains +
-            " but got " + content, content.contains(contains));
+        assertThat("expecting file " + filename + " to contain " + contains + " but got " + content,
+                content, containsString(contains));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/81c3e6e3/src/tests/junit/org/apache/tools/ant/taskdefs/CopyTest.java
----------------------------------------------------------------------
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 e7905af..64bb09c 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/CopyTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/CopyTest.java
@@ -27,18 +27,21 @@ import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileReader;
 import java.io.IOException;
 
-import static org.apache.tools.ant.AntAssert.assertContains;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.endsWith;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.startsWith;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 import static org.junit.Assume.assumeTrue;
 
 /**
@@ -50,6 +53,8 @@ public class CopyTest {
     @Rule
     public final BuildFileRule buildRule = new BuildFileRule();
 
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
 
     @Before
     public void setUp() {
@@ -61,18 +66,14 @@ public class CopyTest {
     public void test1() {
         buildRule.executeTarget("test1");
         File f = new File(buildRule.getProject().getProperty("output"), "copytest1.tmp");
-        if (!f.exists()) {
-            fail("Copy failed");
-        }
+        assertTrue("Copy failed", f.exists());
     }
 
     @Test
     public void test2() {
         buildRule.executeTarget("test2");
         File f = new File(buildRule.getProject().getProperty("output"), "copytest1dir/copy.xml");
-        if (!f.exists()) {
-            fail("Copy failed");
-        }
+        assertTrue("Copy failed", f.exists());
     }
 
     @Test
@@ -100,19 +101,18 @@ public class CopyTest {
         // file time checks for java1.2+
         assertEquals(file3a.lastModified(), file3.lastModified());
         assertTrue(file3c.lastModified() < file3a.lastModified());
-
     }
 
     @Test
     public void testFilterTest() {
         buildRule.executeTarget("filtertest");
-        assertFalse(buildRule.getLog().contains("loop in tokens"));
+        assertThat(buildRule.getLog(), not(containsString("loop in tokens")));
     }
 
     @Test
     public void testInfiniteFilter() {
         buildRule.executeTarget("infinitetest");
-        assertContains("loop in tokens", buildRule.getOutput());
+        assertThat(buildRule.getOutput(), containsString("loop in tokens"));
     }
 
     @Test
@@ -128,7 +128,7 @@ public class CopyTest {
     public void testFilterChain() throws IOException {
         buildRule.executeTarget("testFilterChain");
         File tmp  = new File(buildRule.getProject().getProperty("output"), "copy.filterchain.tmp");
-        File check  = new File(buildRule.getProject().getBaseDir(), "expected/copy.filterset.filtered");
+        File check = new File(buildRule.getProject().getBaseDir(), "expected/copy.filterset.filtered");
         assertTrue(tmp.exists());
         assertEquals(FileUtilities.getFileContents(tmp), FileUtilities.getFileContents(check));
     }
@@ -136,16 +136,16 @@ public class CopyTest {
     @Test
     public void testSingleFileFileset() {
         buildRule.executeTarget("test_single_file_fileset");
-        File file  = new File(buildRule.getProject().getProperty("output"),
-                                        "copytest_single_file_fileset.tmp");
+        File file = new File(buildRule.getProject().getProperty("output"),
+                "copytest_single_file_fileset.tmp");
         assertTrue(file.exists());
     }
 
     @Test
     public void testSingleFilePath() {
         buildRule.executeTarget("test_single_file_path");
-        File file  = new File(buildRule.getProject().getProperty("output"),
-                                        "copytest_single_file_path.tmp");
+        File file = new File(buildRule.getProject().getProperty("output"),
+                "copytest_single_file_path.tmp");
         assertTrue(file.exists());
     }
 
@@ -160,34 +160,27 @@ public class CopyTest {
     @Test
     public void testMissingFileIgnore() {
         buildRule.executeTarget("testMissingFileIgnore");
-        assertContains("Warning: Could not find file", buildRule.getLog());
+        assertThat(buildRule.getLog(), containsString("Warning: Could not find file"));
     }
 
     @Test
     public void testMissingFileBail() {
-        try {
-            buildRule.executeTarget("testMissingFileBail");
-            fail("not-there doesn't exist");
-        } catch (BuildException ex) {
-            assertTrue(ex.getMessage()
-                    .startsWith("Warning: Could not find file "));
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage(startsWith("Warning: Could not find file "));
+        buildRule.executeTarget("testMissingFileBail");
     }
 
     @Test
     public void testMissingDirIgnore() {
         buildRule.executeTarget("testMissingDirIgnore");
-        assertContains("Warning: ", buildRule.getLog());
+        assertThat(buildRule.getLog(), containsString("Warning: "));
     }
 
     @Test
     public void testMissingDirBail() {
-        try {
-            buildRule.executeTarget("testMissingDirBail");
-            fail("not-there doesn't exist");
-        } catch (BuildException ex) {
-            assertTrue(ex.getMessage().endsWith(" does not exist."));
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage(endsWith(" does not exist."));
+        buildRule.executeTarget("testMissingDirBail");
     }
 
     @Test
@@ -218,11 +211,9 @@ public class CopyTest {
         buildRule.executeTarget("testFileResourceWithFilter");
         File file1 = new File(buildRule.getProject().getProperty("to.dir") + "/fileNR.txt");
         assertTrue(file1.exists());
-        try {
-            try (FileReader f = new FileReader(file1)) {
-                String file1Content = FileUtils.readFully(f);
-                assertEquals("This is file 42", file1Content);
-            }
+        try (FileReader f = new FileReader(file1)) {
+            String file1Content = FileUtils.readFully(f);
+            assertEquals("This is file 42", file1Content);
         } catch (IOException e) {
             // no-op: not a real business error
         }

http://git-wip-us.apache.org/repos/asf/ant/blob/81c3e6e3/src/tests/junit/org/apache/tools/ant/taskdefs/EchoXMLTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/EchoXMLTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/EchoXMLTest.java
index cc9ec24..5d83a8f 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/EchoXMLTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/EchoXMLTest.java
@@ -25,7 +25,8 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 
-import static org.apache.tools.ant.AntAssert.assertContains;
+import static org.hamcrest.Matchers.containsString;
+import static org.junit.Assert.assertThat;
 import static org.junit.Assert.fail;
 
 public class EchoXMLTest {
@@ -54,7 +55,7 @@ public class EchoXMLTest {
             buildRule.executeTarget("testFail");
             fail("BuildException expected: must fail");
         } catch (BuildException ex) {
-            assertContains("${foo}=bar", ex.getMessage());
+            assertThat(ex.getMessage(), containsString("${foo}=bar"));
         }
     }
 
@@ -64,7 +65,7 @@ public class EchoXMLTest {
             buildRule.executeTarget("testEmpty");
             fail("BuildException expected: must fail");
         } catch (BuildException ex) {
-            assertContains("No nested XML specified", ex.getMessage());
+            assertThat(ex.getMessage(), containsString("No nested XML specified"));
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ant/blob/81c3e6e3/src/tests/junit/org/apache/tools/ant/taskdefs/FixCrLfTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/FixCrLfTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/FixCrLfTest.java
index 48f1fd4..a34b9f4 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/FixCrLfTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/FixCrLfTest.java
@@ -31,10 +31,10 @@ import org.apache.tools.ant.BuildFileRule;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 
-import static org.apache.tools.ant.AntAssert.assertContains;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertTrue;
 
 /**
  */
@@ -43,6 +43,9 @@ public class FixCrLfTest {
     @Rule
     public BuildFileRule buildRule = new BuildFileRule();
 
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
     @Before
     public void setUp() {
         buildRule.configureProject("src/etc/testcases/taskdefs/fixcrlf/build.xml");
@@ -150,12 +153,9 @@ public class FixCrLfTest {
 
     @Test
     public void testFixFileExclusive() {
-        try {
-            buildRule.executeTarget("testFixFileExclusive");
-            fail(FixCRLF.ERROR_FILE_AND_SRCDIR);
-        } catch (BuildException ex) {
-            assertContains(FixCRLF.ERROR_FILE_AND_SRCDIR, ex.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage(FixCRLF.ERROR_FILE_AND_SRCDIR);
+        buildRule.executeTarget("testFixFileExclusive");
     }
 
     /**
@@ -231,11 +231,8 @@ public class FixCrLfTest {
 
     // not used, but public so theoretically must remain for BC?
     @Deprecated
-    public void assertEqualContent(File expect, File result)
-        throws AssertionFailedError, IOException {
-        if (!result.exists()) {
-            fail("Expected file " + result + " doesn\'t exist");
-        }
+    public void assertEqualContent(File expect, File result) throws AssertionFailedError, IOException {
+        assertTrue("Expected file " + result + " doesn\'t exist", result.exists());
 
         try (InputStream inExpect = new BufferedInputStream(new FileInputStream(expect));
              InputStream inResult = new BufferedInputStream(new FileInputStream(result))) {

http://git-wip-us.apache.org/repos/asf/ant/blob/81c3e6e3/src/tests/junit/org/apache/tools/ant/taskdefs/GetTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/GetTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/GetTest.java
index f079adb..a011ada 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/GetTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/GetTest.java
@@ -24,11 +24,13 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 
-import static org.apache.tools.ant.AntAssert.assertContains;
-import static org.apache.tools.ant.AntAssert.assertNotContains;
+import static org.hamcrest.Matchers.both;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.not;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertThat;
 
 /**
  */
@@ -37,6 +39,9 @@ public class GetTest {
     @Rule
     public final BuildFileRule buildRule = new BuildFileRule();
 
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
     @Before
     public void setUp() {
         buildRule.configureProject("src/etc/testcases/taskdefs/get.xml");
@@ -47,54 +52,49 @@ public class GetTest {
         buildRule.executeTarget("cleanup");
     }
 
-    @Test
+    /**
+     * Fail due to missing required argument
+     */
+    @Test(expected = BuildException.class)
     public void test1() {
-        try {
-            buildRule.executeTarget("test1");
-            fail("required argument missing");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test1");
+        // TODO assert value
     }
 
-    @Test
+    /**
+     * Fail due to missing required argument
+     */
+    @Test(expected = BuildException.class)
     public void test2() {
-        try {
-            buildRule.executeTarget("test2");
-            fail("required argument missing");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test2");
+        // TODO assert value
     }
 
-    @Test
+    /**
+     * Fail due to missing required argument
+     */
+    @Test(expected = BuildException.class)
     public void test3() {
-        try {
-            buildRule.executeTarget("test3");
-            fail("required argument missing");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test3");
+        // TODO assert value
     }
 
-    @Test
+    /**
+     * Fail due to invalid src argument
+     */
+    @Test(expected = BuildException.class)
     public void test4() {
-        try {
-            buildRule.executeTarget("test4");
-            fail("src invalid");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test4");
+        // TODO assert value
     }
 
-    @Test
+    /**
+     * Fail due to invalid dest argument or no HTTP server on localhost
+     */
+    @Test(expected = BuildException.class)
     public void test5() {
-        try {
-            buildRule.executeTarget("test5");
-            fail("dest invalid (or no http-server on local machine");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test5");
+        // TODO assert value
     }
 
     @Test
@@ -102,15 +102,17 @@ public class GetTest {
         buildRule.executeTarget("test6");
     }
 
+    /**
+     * Fail due to null or empty userAgent argument
+     */
     @Test
     public void test7() {
+        thrown.expect(BuildException.class);
         try {
             buildRule.executeTarget("test7");
-            assertNotContains("Adding header", buildRule.getLog());
-
-            fail("userAgent may not be null or empty");
-        } catch (BuildException ex) {
-            //TODO assert value
+        } finally {
+            // post-mortem
+            assertThat(buildRule.getLog(), not(containsString("Adding header")));
         }
     }
 
@@ -127,22 +129,21 @@ public class GetTest {
     @Test
     public void testTwoHeadersAreAddedOK() {
         buildRule.executeTarget("testTwoHeadersAreAddedOK");
-        String log = buildRule.getLog();
-        assertContains("Adding header 'header1'", log);
-        assertContains("Adding header 'header2'", log);
+        assertThat(buildRule.getLog(), both(containsString("Adding header 'header1'"))
+                        .and(containsString("Adding header 'header2'")));
     }
 
     @Test
     public void testEmptyHeadersAreNeverAdded() {
         buildRule.executeTarget("testEmptyHeadersAreNeverAdded");
-        assertNotContains("Adding header", buildRule.getLog());
+        assertThat(buildRule.getLog(), not(containsString("Adding header")));
     }
 
     @Test
     public void testThatWhenMoreThanOneHeaderHaveSameNameOnlyLastOneIsAdded() {
         buildRule.executeTarget("testThatWhenMoreThanOneHeaderHaveSameNameOnlyLastOneIsAdded");
         String log = buildRule.getLog();
-        assertContains("Adding header 'header1'", log);
+        assertThat(log, containsString("Adding header 'header1'"));
 
         int actualHeaderCount = log.split("Adding header ").length - 1;
 
@@ -152,7 +153,7 @@ public class GetTest {
     @Test
     public void testHeaderSpaceTrimmed() {
         buildRule.executeTarget("testHeaderSpaceTrimmed");
-        assertContains("Adding header 'header1'", buildRule.getLog());
+        assertThat(buildRule.getLog(), containsString("Adding header 'header1'"));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/81c3e6e3/src/tests/junit/org/apache/tools/ant/taskdefs/ImportTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ImportTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ImportTest.java
index ec53f6f..29680f0 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/ImportTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ImportTest.java
@@ -18,33 +18,36 @@
 
 package org.apache.tools.ant.taskdefs;
 
-import static org.apache.tools.ant.AntAssert.assertContains;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.hasProperty;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertThat;
 import static org.junit.Assume.assumeTrue;
 
 import java.io.File;
-import java.io.IOException;
 
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.BuildFileRule;
-import org.apache.tools.ant.Location;
 import org.apache.tools.ant.Project;
 import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 
 public class ImportTest {
 
     @Rule
     public BuildFileRule buildRule = new BuildFileRule();
 
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
     @Test
     public void testSimpleImport() {
         buildRule.configureProject("src/etc/testcases/taskdefs/import/import.xml");
-        assertContains("Before importIn imported topAfter import", buildRule.getLog());
+        assertThat(buildRule.getLog(), containsString("Before importIn imported topAfter import"));
     }
 
     @Test
@@ -58,9 +61,9 @@ public class ImportTest {
     @Test
     public void testSerial() {
         buildRule.configureProject("src/etc/testcases/taskdefs/import/subdir/serial.xml");
-        assertContains("Unnamed2.xmlUnnamed1.xml", buildRule.getLog());
-        assertContains("Expected string was not found in log",
-                "Skipped already imported file", buildRule.getFullLog());
+        assertThat(buildRule.getLog(), containsString("Unnamed2.xmlUnnamed1.xml"));
+        assertThat("Expected string was not found in log",
+                buildRule.getFullLog(), containsString("Skipped already imported file"));
     }
 
     // allow this as imported in targets are only tested when a target is run
@@ -83,15 +86,10 @@ public class ImportTest {
 
     @Test
     public void testImportInTargetNotAllowed() {
-        buildRule.configureProject(
-            "src/etc/testcases/taskdefs/import/subdir/importintarget.xml");
-        try {
-            buildRule.executeTarget("do-import");
-            fail("Build exception should have been thrown as import only allowed in top level task");
-        } catch (BuildException ex) {
-            assertContains("not a top level task", "import only allowed as a top-level task",
-                    ex.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("import only allowed as a top-level task");
+        buildRule.configureProject("src/etc/testcases/taskdefs/import/subdir/importintarget.xml");
+        buildRule.executeTarget("do-import");
     }
 
     @Test
@@ -105,31 +103,18 @@ public class ImportTest {
 
     @Test
     public void testImportSameTargets() {
-        try {
-            buildRule.configureProject(
-                "src/etc/testcases/taskdefs/import/same_target.xml");
-            fail("Expected build exception");
-        } catch (BuildException ex) {
-            assertContains("Message did not contain expected contents", "Duplicate target",
-                    ex.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("Duplicate target");
+        buildRule.configureProject("src/etc/testcases/taskdefs/import/same_target.xml");
     }
 
     @Test
     public void testImportError() {
-        try {
-            buildRule.configureProject(
-                "src/etc/testcases/taskdefs/import/import_bad_import.xml");
-            fail("Build exception should have been thrown");
-        } catch (BuildException ex) {
-            Location lo = ex.getLocation();
-            assertNotNull(
-                "expected location of build exception to be set", lo);
-            assertContains(
-                "expected location to contain calling file", "import_bad_import.xml", lo.getFileName());
-            assertContains(
-                "expected message of ex to contain called file", "bad.xml", ex.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("bad.xml");
+        thrown.expect(hasProperty("location",
+                hasProperty("fileName", containsString("import_bad_import.xml"))));
+        buildRule.configureProject("src/etc/testcases/taskdefs/import/import_bad_import.xml");
     }
 
     @Test
@@ -140,21 +125,15 @@ public class ImportTest {
         }
         assumeTrue("Current system does not support Symlinks", new File(ln).exists());
         String symlink = "src/etc/testcases/taskdefs/import/symlinks/d3b";
-        File symlinkFile = new File(System.getProperty("root"), symlink);
-        if (Runtime.getRuntime().exec(new String[] {ln, "-s", "d3a", symlinkFile.getAbsolutePath()}).waitFor() != 0) {
-            throw new IOException("'" + ln + " -s d3a " + symlink + "' failed");
-        }
+        File symlinkFile = new File(symlink);
+        assertEquals("'" + ln + " -s d3a " + symlink + "' failed",
+                Runtime.getRuntime().exec(new String[] {ln, "-s", "d3a", symlinkFile.getAbsolutePath()}).waitFor(), 0);
         try {
-            buildRule.configureProject(
-                "src/etc/testcases/taskdefs/import/symlinks/d1/p1.xml");
-            assertEquals(
-                buildRule.getProject().getProperty("ant.file.p2"),
-                new File(System.getProperty("root"), "src/etc/testcases/taskdefs/import/symlinks/d2/p2.xml")
-                .getAbsolutePath());
-            assertEquals(
-                buildRule.getProject().getProperty("ant.file.p3"),
-                new File(System.getProperty("root"), "src/etc/testcases/taskdefs/import/symlinks/d3b/p3.xml")
-                .getAbsolutePath());
+            buildRule.configureProject("src/etc/testcases/taskdefs/import/symlinks/d1/p1.xml");
+            assertEquals(buildRule.getProject().getProperty("ant.file.p2"),
+                new File("src/etc/testcases/taskdefs/import/symlinks/d2/p2.xml").getAbsolutePath());
+            assertEquals(buildRule.getProject().getProperty("ant.file.p3"),
+                new File("src/etc/testcases/taskdefs/import/symlinks/d3b/p3.xml").getAbsolutePath());
         } finally {
             symlinkFile.delete();
         }
@@ -163,7 +142,8 @@ public class ImportTest {
     @Test
     public void testTargetFirst() {
         buildRule.configureProject("src/etc/testcases/taskdefs/import/importtargetfirst.xml");
-        assertContains("Importing targetfirstAfter target firstAfter importing", buildRule.getLog());
+        assertThat(buildRule.getLog(),
+                containsString("Importing targetfirstAfter target firstAfter importing"));
     }
 
     @Test


Mime
View raw message