You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by gi...@apache.org on 2018/04/22 22:48:45 UTC

[1/2] ant git commit: Expected exceptions galore

Repository: ant
Updated Branches:
  refs/heads/master 8a3b1658c -> ad98e27d0


http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/UntarTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/UntarTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/UntarTest.java
index ea0c60c..681409b 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/UntarTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/UntarTest.java
@@ -30,8 +30,6 @@ import java.io.IOException;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
 
 public class UntarTest {
 
@@ -73,14 +71,10 @@ public class UntarTest {
         testLogoExtraction("testBzip2TarTask");
     }
 
-    @Test
+    @Test(expected = BuildException.class)
     public void testSrcDirTest() {
-        try {
-            buildRule.executeTarget("srcDirTest");
-            fail("Src cannot be a directory.");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("srcDirTest");
+        // TODO assert value
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/UnzipTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/UnzipTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/UnzipTest.java
index f95c37d..e719271 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/UnzipTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/UnzipTest.java
@@ -31,7 +31,6 @@ import java.io.IOException;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 public class UnzipTest {
 
@@ -43,37 +42,33 @@ public class UnzipTest {
         buildRule.configureProject("src/etc/testcases/taskdefs/unzip.xml");
     }
 
-    @Test
+    /**
+     * Expected failure due to required argument not specified
+     */
+    @Test(expected = BuildException.class)
     public void test1() {
-        try {
-            buildRule.executeTarget("test1");
-            fail("BuildException expected: required argument not specified");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test1");
+        // TODO Assert exception message
     }
 
-    @Test
+    /**
+     * Expected failure due to required argument not specified
+     */
+    @Test(expected = BuildException.class)
     public void test2() {
-        try {
-            buildRule.executeTarget("test2");
-            fail("BuildException expected: required argument not specified");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test2");
+        // TODO Assert exception message
     }
 
-    @Test
+    /**
+     * Expected failure due to required argument not specified
+     */
+    @Test(expected = BuildException.class)
     public void test3() {
-        try {
-            buildRule.executeTarget("test3");
-            fail("BuildException expected: required argument not specified");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test3");
+        // TODO Assert exception message
     }
 
-
     @Test
     public void testRealTest() throws IOException {
         buildRule.executeTarget("realTest");
@@ -173,7 +168,6 @@ public class UnzipTest {
         buildRule.executeTarget("selfExtractingArchive");
     }
 
-
     /*
      * PR 20969
      */
@@ -186,7 +180,6 @@ public class UnzipTest {
                 buildRule.getProject().getProperty("output") + "/unziptestout/2/bar");
     }
 
-
     /*
      * PR 10504
      */
@@ -240,14 +233,13 @@ public class UnzipTest {
                 buildRule.getProject().getProperty("output") + "/unziptestout/1/foo.txt");
     }
 
-    @Test
+    /**
+     * Expected failure due to multiple mappers
+     */
+    @Test(expected = BuildException.class)
     public void testTwoMappers() {
-        try {
-            buildRule.executeTarget("testTwoMappers");
-            fail("BuildException expected: " + Expand.ERROR_MULTIPLE_MAPPERS);
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("testTwoMappers");
+        // TODO Assert exception message
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/XmlnsTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/XmlnsTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/XmlnsTest.java
index 379fc02..4f3f65d 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/XmlnsTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/XmlnsTest.java
@@ -18,15 +18,15 @@
 
 package org.apache.tools.ant.taskdefs;
 
+import static org.junit.Assert.assertEquals;
+
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.BuildFileRule;
 import org.apache.tools.ant.Task;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import org.junit.rules.ExpectedException;
 
 
 public class XmlnsTest {
@@ -34,6 +34,9 @@ public class XmlnsTest {
     @Rule
     public final BuildFileRule buildRule = new BuildFileRule();
 
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
     @Before
     public void setUp() {
         buildRule.configureProject("src/etc/testcases/taskdefs/xmlns.xml");
@@ -59,12 +62,9 @@ public class XmlnsTest {
 
     @Test
     public void testExcluded() {
-        try {
-            buildRule.executeTarget("excluded");
-            fail("BuildException expected: excluded uri");
-        } catch (BuildException ex) {
-            assertEquals("Attempt to use a reserved URI ant:notallowed", ex.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("Attempt to use a reserved URI ant:notallowed");
+        buildRule.executeTarget("excluded");
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/condition/HttpTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/condition/HttpTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/condition/HttpTest.java
index 15a9d2d..1c0c695 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/condition/HttpTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/condition/HttpTest.java
@@ -25,7 +25,6 @@ import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
 
 /**
  * Testcases for the <http> condition. All these tests require
@@ -63,14 +62,12 @@ public class HttpTest {
         assertNull(buildRule.getProject().getProperty("test-get-request-bad-url"));
     }
 
-    @Test
+    /**
+     * Expected failure due to invalid HTTP request method specified
+     */
+    @Test(expected = BuildException.class)
     public void testBadRequestMethod() {
-        try {
-            buildRule.executeTarget("bad-request-method");
-            fail("Exception should have been thrown as invalid HTTP request method specified");
-        } catch (BuildException ex) {
-            //TODO we should assert the correct build exception was thrown
-        }
+        buildRule.executeTarget("bad-request-method");
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsReferenceTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsReferenceTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsReferenceTest.java
index e8e178b..f6e0daf 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsReferenceTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsReferenceTest.java
@@ -22,9 +22,9 @@ 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.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
 import static org.junit.Assert.assertNull;
 
 /**
@@ -36,6 +36,9 @@ public class IsReferenceTest {
     @Rule
     public BuildFileRule buildRule = new BuildFileRule();
 
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
     @Before
     public void setUp() {
         buildRule.configureProject("src/etc/testcases/taskdefs/conditions/isreference.xml");
@@ -49,14 +52,14 @@ public class IsReferenceTest {
         assertNull(buildRule.getProject().getProperty("undefined"));
     }
 
+    /**
+     * Expected failure due to omitted refid attribute
+     */
     @Test
     public void testNotEnoughArgs() {
-        try {
-            buildRule.executeTarget("isreference-incomplete");
-            fail("Build exception expected: refid attirbute has been omitted");
-        } catch (BuildException ex) {
-            assertEquals("No reference specified for isreference condition", ex.getMessage());
-        }
+        thrown.expect(BuildException .class) ;
+            thrown.expectMessage("No reference specified for isreference condition");
+        buildRule.executeTarget("isreference-incomplete");
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/condition/ParserSupportsTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/condition/ParserSupportsTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/condition/ParserSupportsTest.java
index c5c2f04..9f1c3cf 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/condition/ParserSupportsTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/condition/ParserSupportsTest.java
@@ -24,9 +24,7 @@ import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import org.junit.rules.ExpectedException;
 
 /**
 
@@ -36,6 +34,9 @@ public class ParserSupportsTest {
     @Rule
     public BuildFileRule buildRule = new BuildFileRule();
 
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
     @Before
     public void setUp() {
         buildRule.configureProject("src/etc/testcases/taskdefs/conditions/parsersupports.xml");
@@ -43,22 +44,16 @@ public class ParserSupportsTest {
 
     @Test
     public void testEmpty() {
-        try {
-            buildRule.executeTarget("testEmpty");
-            fail("Build exception expected: " + ParserSupports.ERROR_NO_ATTRIBUTES);
-        } catch (BuildException ex) {
-            assertEquals(ParserSupports.ERROR_NO_ATTRIBUTES, ex.getMessage());
-        }
+        thrown.expect(BuildException .class) ;
+            thrown.expectMessage(ParserSupports.ERROR_NO_ATTRIBUTES);
+        buildRule.executeTarget("testEmpty");
     }
 
     @Test
     public void testBoth() {
-        try {
-            buildRule.executeTarget("testBoth");
-            fail("Build exception expected: " + ParserSupports.ERROR_BOTH_ATTRIBUTES);
-        } catch (BuildException ex) {
-            assertEquals(ParserSupports.ERROR_BOTH_ATTRIBUTES, ex.getMessage());
-        }
+        thrown.expect(BuildException .class) ;
+            thrown.expectMessage(ParserSupports.ERROR_BOTH_ATTRIBUTES);
+        buildRule.executeTarget("testBoth");
     }
 
     @Test
@@ -68,12 +63,9 @@ public class ParserSupportsTest {
 
     @Test
     public void testPropertyNoValue() {
-        try {
-            buildRule.executeTarget("testPropertyNoValue");
-            fail("Build exception expected: " + ParserSupports.ERROR_NO_VALUE);
-        } catch (BuildException ex) {
-            assertEquals(ParserSupports.ERROR_NO_VALUE, ex.getMessage());
-        }
+        thrown.expect(BuildException .class) ;
+            thrown.expectMessage(ParserSupports.ERROR_NO_VALUE);
+        buildRule.executeTarget("testPropertyNoValue");
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/email/EmailTaskTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/email/EmailTaskTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/email/EmailTaskTest.java
index f3dc622..1bdb4d4 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/email/EmailTaskTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/email/EmailTaskTest.java
@@ -24,8 +24,6 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 
-import static org.junit.Assert.fail;
-
 /**
  * TODO : develop these testcases - the email task needs to have attributes allowing
  * to simulate sending mail and to catch the output in text files or streams
@@ -40,24 +38,22 @@ public class EmailTaskTest {
         buildRule.configureProject("src/etc/testcases/taskdefs/email/mail.xml");
     }
 
-    @Test
+    /**
+     * Expected failure attempting SMTP auth without MIME
+     */
+    @Test(expected = BuildException.class)
     public void test1() {
-        try {
-            buildRule.executeTarget("test1");
-            fail("Build exception expected: SMTP auth only possibly with MIME mail");
-        } catch (BuildException ex) {
-            //TODO assert exception message
-        }
+        buildRule.executeTarget("test1");
+        // TODO Assert exception message
     }
 
-    @Test
+    /**
+     * Expected failure attempting SSL without MIME
+     */
+    @Test(expected = BuildException.class)
     public void test2() {
-        try {
-            buildRule.executeTarget("test2");
-            fail("Build exception expected: SSL only possibly with MIME mail");
-        } catch (BuildException ex) {
-            //TODO assert exception message
-        }
+        buildRule.executeTarget("test2");
+        // TODO Assert exception message
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java
index 056d756..ea063c0 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java
@@ -30,9 +30,8 @@ import java.io.FilenameFilter;
 
 import static org.hamcrest.Matchers.containsString;
 import static org.hamcrest.Matchers.not;
+import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 /**
  * If you want to run tests, it is highly recommended
@@ -57,25 +56,23 @@ public class ANTLRTest {
         buildRule.configureProject(TASKDEFS_DIR + "antlr.xml");
     }
 
-    @Test
+    /**
+     * Expected failure due to missing required argument, target
+     */
+    @Test(expected = BuildException.class)
     public void test1() {
-        try {
-            buildRule.executeTarget("test1");
-            fail("required argument, target, missing");
-        } catch (BuildException ex) {
-            //TODO should check exception message
-        }
+        buildRule.executeTarget("test1");
+        // TODO Check exception message
     }
 
-    @Test
+    /**
+     * Expected failure due to invalid output directory
+     */
+    @Test(expected = BuildException.class)
     public void test2() {
-        try {
-            buildRule.executeTarget("test2");
-            fail("Invalid output directory");
-        } catch (BuildException ex) {
-            //TODO should check exception message
-        }
-    }
+        buildRule.executeTarget("test2");
+        // TODO Check exception message
+     }
 
     @Test
     public void test3() {
@@ -87,16 +84,14 @@ public class ANTLRTest {
         buildRule.executeTarget("test4");
     }
 
-    @Test
+    /**
+     * should print "panic: Cannot find importVocab file 'JavaTokenTypes.txt'"
+     * since it needs to run java.g first before java.tree.g
+     */
+    @Test(expected = BuildException.class)
     public void test5() {
-        // should print "panic: Cannot find importVocab file 'JavaTokenTypes.txt'"
-        // since it needs to run java.g first before java.tree.g
-        try {
-            buildRule.executeTarget("test5");
-            fail("ANTLR returned: 1");
-        } catch (BuildException ex) {
-            //TODO should check exception message
-        }
+        buildRule.executeTarget("test5");
+        // TODO Check exception message
     }
 
     @Test
@@ -104,27 +99,22 @@ public class ANTLRTest {
         buildRule.executeTarget("test6");
     }
 
-    @Test
+    /**
+     * Expected failure due to inability to determine generated class
+     */
+    @Test(expected = BuildException.class)
     public void test7() {
-        try {
-            buildRule.executeTarget("test7");
-            fail("Unable to determine generated class");
-        } catch (BuildException ex) {
-            //TODO should check exception message
-        }
+        buildRule.executeTarget("test7");
+        // TODO Check exception message
     }
 
     /**
      * Expected failure due to invalid super grammar (glib) option.
      */
-    @Test
+    @Test(expected = BuildException.class)
     public void test8() {
-        try {
-            buildRule.executeTarget("test8");
-            fail("Invalid super grammar file");
-        } catch (BuildException ex) {
-            //TODO should check exception message
-        }
+        buildRule.executeTarget("test8");
+        // TODO Check exception message
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JspcTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JspcTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JspcTest.java
index 555ab2f..9b57a2f 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JspcTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JspcTest.java
@@ -30,10 +30,10 @@ import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 /**
  * Tests the Jspc task.
@@ -47,6 +47,9 @@ public class JspcTest {
     private static final String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/";
 
     @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
+    @Rule
     public BuildFileRule buildRule = new BuildFileRule();
 
     @Before
@@ -88,12 +91,9 @@ public class JspcTest {
 
     @Test
     public void testNoTld() {
-        try {
-            buildRule.executeTarget("testNoTld");
-            fail("Not found");
-        } catch (BuildException ex) {
-            assertEquals("Java returned: 9", ex.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("Java returned: 9");
+        buildRule.executeTarget("testNoTld");
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PvcsTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PvcsTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PvcsTest.java
index c89ccd0..bcdfb69 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PvcsTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PvcsTest.java
@@ -24,8 +24,6 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 
-import static org.junit.Assert.fail;
-
 public class PvcsTest {
 
     @Rule
@@ -36,14 +34,12 @@ public class PvcsTest {
         buildRule.configureProject("src/etc/testcases/taskdefs/optional/pvcs.xml");
     }
 
-    @Test
+    /**
+     * Expected failure due to missing argument "repository"
+     */
+    @Test(expected = BuildException.class)
     public void test1() {
-        try {
             buildRule.executeTarget("test1");
-            fail("Required argument repository not specified");
-        } catch (BuildException ex) {
-            //TODO check exception message
-        }
     }
 
     @Test
@@ -66,14 +62,12 @@ public class PvcsTest {
         buildRule.executeTarget("test5");
     }
 
-    @Test
+    /**
+     * Expected failure due to nonexistent directory structure
+     */
+    @Test(expected = BuildException.class)
     public void test6() {
-        try {
-            buildRule.executeTarget("test6");
-            fail("Failed executing: /never/heard/of/a/directory/structure/like/this/pcli lvf -z " +
-                    "-aw -pr//ct4serv2/pvcs/monitor /. Exception: /never/heard/of/a/directory/structure/like/this/pcli: not found");
-        } catch (BuildException ex) {
-            //TODO assert exception message
-        }
+        buildRule.executeTarget("test6");
+        //TODO assert exception message
     }
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junitlauncher/JUnitLauncherTaskTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junitlauncher/JUnitLauncherTaskTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junitlauncher/JUnitLauncherTaskTest.java
index 1649a84..be574ca 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junitlauncher/JUnitLauncherTaskTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junitlauncher/JUnitLauncherTaskTest.java
@@ -10,8 +10,6 @@ import org.junit.Test;
 
 import java.io.File;
 
-import static org.junit.Assert.fail;
-
 /**
  * Tests the {@link JUnitLauncherTask}
  */
@@ -72,14 +70,9 @@ public class JUnitLauncherTaskTest {
      * Tests that when a test, that's configured with {@code haltOnFailure=true}, stops the build, when the
      * test fails
      */
-    @Test
+    @Test(expected = BuildException.class)
     public void testFailureStopsBuild() {
-        try {
-            project.executeTarget("test-failure-stops-build");
-            fail("Test execution failure was expected to stop the build but didn't");
-        } catch (BuildException be) {
-            // expected
-        }
+        project.executeTarget("test-failure-stops-build");
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/optional/net/FTPTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/net/FTPTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/net/FTPTest.java
index 7628b27..9104a40 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/net/FTPTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/net/FTPTest.java
@@ -20,8 +20,6 @@ package org.apache.tools.ant.taskdefs.optional.net;
 import static org.hamcrest.Matchers.containsString;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 import static org.junit.Assume.assumeTrue;
 
 import java.io.File;
@@ -613,17 +611,11 @@ public class FTPTest {
         performConfigTest("configuration.3", expectedCounts);
     }
 
-    @Test
+    @Test(expected = BuildException.class)
     public void testConfigurationLang() {
         int[] expectedCounts = {1, 1, 0, 0, 0, 0, 1};
         performConfigTest("configuration.lang.good", expectedCounts);
-
-        try {
-            performConfigTest("configuration.lang.bad", expectedCounts);
-            fail("BuildException Expected");
-        } catch (Exception bx) {
-            assertTrue(bx instanceof BuildException);
-        }
+        performConfigTest("configuration.lang.bad", expectedCounts);
     }
     /**
      * Tests the systemTypeKey attribute.
@@ -757,21 +749,13 @@ public class FTPTest {
 
     public void testGetWithSelectorRetryable1() {
         buildRule.getProject().addTaskDefinition("ftp", oneFailureFTP.class);
-        try {
-            buildRule.getProject().executeTarget("ftp-get-with-selector-retryable");
-        } catch (BuildException bx) {
-            fail("Two retries expected, failed after one.");
-        }
+        buildRule.getProject().executeTarget("ftp-get-with-selector-retryable");
     }
 
     @Test
     public void testGetWithSelectorRetryable2() {
         buildRule.getProject().addTaskDefinition("ftp", twoFailureFTP.class);
-        try {
-            buildRule.getProject().executeTarget("ftp-get-with-selector-retryable");
-        } catch (BuildException bx) {
-            fail("Two retries expected, failed after two.");
-        }
+        buildRule.getProject().executeTarget("ftp-get-with-selector-retryable");
     }
 
     /**
@@ -786,12 +770,8 @@ public class FTPTest {
     @Test
     public void testGetWithSelectorRetryableRandom() {
         buildRule.getProject().addTaskDefinition("ftp", randomFailureFTP.class);
-        try {
-            buildRule.getProject().setProperty("ftp.retries", "forever");
-            buildRule.getProject().executeTarget("ftp-get-with-selector-retryable");
-        } catch (BuildException bx) {
-            fail("Retry forever specified, but failed.");
-        }
+        buildRule.getProject().setProperty("ftp.retries", "forever");
+        buildRule.getProject().executeTarget("ftp-get-with-selector-retryable");
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java
index e77c347..e5e7bf7 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java
@@ -28,9 +28,9 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
 
 /**
  *  Testcase to ensure that command line generation and required attributes are
@@ -55,7 +55,11 @@ public class SOSTest {
     private static final String VERSION = "007";
 
     @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
+    @Rule
     public BuildFileRule buildRule = new BuildFileRule();
+
     private Project project;
 
     @Before
@@ -317,12 +321,9 @@ public class SOSTest {
 
     private void expectSpecificBuildException(String target, String errorMessage,
                                               String exceptionMessage) {
-        try {
-            buildRule.executeTarget(target);
-            fail(errorMessage);
-        } catch (BuildException ex) {
-            assertEquals(exceptionMessage, ex.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage(exceptionMessage);
+        buildRule.executeTarget(target);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ssh/ScpTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ssh/ScpTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ssh/ScpTest.java
index 80283ef..03edb37 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ssh/ScpTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ssh/ScpTest.java
@@ -39,7 +39,6 @@ import org.junit.Test;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 /**
  * This is a unit test for the Scp task in Ant.  It must be
@@ -170,22 +169,19 @@ public class ScpTest {
         scpTask.execute();
     }
 
+    /**
+     * Expected failure due to invalid remoteToDir
+     *
+     * @throws IOException
+     */
+    @Test(expected = BuildException.class)
+    public void testInvalidRemoteToDir() throws IOException {
+        scpTask.setRemoteTodir("host:/a/path/without/an/at");
+    }
+
     @Test
     public void testRemoteToDir() {
-
-        // first try an invalid URI
-        try {
-            scpTask.setRemoteTodir("host:/a/path/without/an/at");
-            fail("Expected a BuildException to be thrown due to invalid"
-                    + " remoteToDir");
-        } catch (BuildException e) {
-            // expected
-            //TODO we should be asserting a value in here
-        }
-
-        // And this one should work
         scpTask.setRemoteTodir("user:password@host:/a/path/with/an/at");
-        // no exception
     }
 
     private void addCleanup(File file) {

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/types/CommandlineTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/types/CommandlineTest.java b/src/tests/junit/org/apache/tools/ant/types/CommandlineTest.java
index 4ba00bb..adf6a00 100644
--- a/src/tests/junit/org/apache/tools/ant/types/CommandlineTest.java
+++ b/src/tests/junit/org/apache/tools/ant/types/CommandlineTest.java
@@ -19,10 +19,11 @@
 package org.apache.tools.ant.types;
 
 import org.apache.tools.ant.BuildException;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
 import static org.junit.Assert.assertNotNull;
 
 /**
@@ -30,6 +31,9 @@ import static org.junit.Assert.assertNotNull;
  */
 public class CommandlineTest {
 
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
     @Test
     public void testTokenizer() {
         String[] s = Commandline.translateCommandline("1 2 3");
@@ -100,22 +104,26 @@ public class CommandlineTest {
         s = Commandline.translateCommandline("\'\'");
         assertEquals("Singlequoted null arg", 1, s.length);
         assertEquals("Singlequoted null arg", "", s[0]);
+    }
 
-        // now to the expected failures
-
-        try {
-            Commandline.translateCommandline("a \'b c");
-            fail("unbalanced single quotes undetected");
-        } catch (BuildException be) {
-            assertEquals("unbalanced quotes in a \'b c", be.getMessage());
-        }
+    /**
+     * Expected failure due to unbalanced single quote
+     */
+    @Test
+    public void testTokenizerUnbalancedSingleQuote() {
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("unbalanced quotes in a \'b c");
+        Commandline.translateCommandline("a \'b c");
+    }
 
-        try {
-            Commandline.translateCommandline("a \"b c");
-            fail("unbalanced double quotes undetected");
-        } catch (BuildException be) {
-            assertEquals("unbalanced quotes in a \"b c", be.getMessage());
-        }
+    /**
+     * Expected failure due to unbalanced double quote
+     */
+    @Test
+    public void testTokenizerUnbalancedDoubleQuote() {
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("unbalanced quotes in a \"b c");
+        Commandline.translateCommandline("a \"b c");
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/types/EnumeratedAttributeTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/types/EnumeratedAttributeTest.java b/src/tests/junit/org/apache/tools/ant/types/EnumeratedAttributeTest.java
index fd80b97..86d40cb 100644
--- a/src/tests/junit/org/apache/tools/ant/types/EnumeratedAttributeTest.java
+++ b/src/tests/junit/org/apache/tools/ant/types/EnumeratedAttributeTest.java
@@ -24,7 +24,6 @@ import org.junit.Test;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 /**
  * JUnit testcases for org.apache.tools.ant.EnumeratedAttribute.
@@ -37,8 +36,7 @@ public class EnumeratedAttributeTest {
     public void testContains() {
         EnumeratedAttribute t1 = new TestNormal();
         for (String value : expected) {
-            assertTrue(value + " is in TestNormal",
-                    t1.containsValue(value));
+            assertTrue(value + " is in TestNormal", t1.containsValue(value));
             assertFalse(value.toUpperCase() + " is in TestNormal",
                     t1.containsValue(value.toUpperCase()));
         }
@@ -47,43 +45,40 @@ public class EnumeratedAttributeTest {
                 (new TestNull()).containsValue("d"));
     }
 
-    @Test
+    /**
+     * Expected failure due to attempt to set an illegal value
+     */
+    @Test(expected = BuildException.class)
     public void testFactory() {
         Factory ea = (Factory) EnumeratedAttribute.getInstance(Factory.class, "one");
         assertEquals("Factory did not set the right value.", ea.getValue(), "one");
-        try {
-            EnumeratedAttribute.getInstance(Factory.class, "illegal");
-            fail("Factory should fail when trying to set an illegal value.");
-        } catch (BuildException be) {
-            // was expected
-            //TODO assert exception message
-        }
+        EnumeratedAttribute.getInstance(Factory.class, "illegal");
     }
 
     @Test
-    public void testExceptions() {
+    public void testExceptionsNormal() {
         EnumeratedAttribute t1 = new TestNormal();
         for (String value : expected) {
-            try {
-                t1.setValue(value);
-            } catch (BuildException be) {
-                fail("unexpected exception for value " + value);
-            }
-        }
-        try {
-            t1.setValue("d");
-            fail("expected exception for value \"d\"");
-        } catch (BuildException be) {
-         //TODO assert build exception
-        }
-        try {
-            (new TestNull()).setValue("d");
-            fail("expected exception for value \"d\" in TestNull");
-        } catch (BuildException be) {
-            //TODO assert exception message
+            t1.setValue(value);
         }
     }
 
+    /**
+     * Expected exception for value "d" in TestNormal
+     */
+    @Test(expected = BuildException.class)
+    public void testExceptionNormal() {
+        new TestNormal().setValue("d");
+    }
+
+    /**
+     * Expected exception for value "d" in TestNull
+     */
+    @Test(expected = BuildException.class)
+    public void testExceptionNull() {
+        new TestNull().setValue("d");
+    }
+
     public static class TestNormal extends EnumeratedAttribute {
         public String[] getValues() {
             return expected;

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/types/FilterSetTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/types/FilterSetTest.java b/src/tests/junit/org/apache/tools/ant/types/FilterSetTest.java
index 9f01a7a..a057a60 100644
--- a/src/tests/junit/org/apache/tools/ant/types/FilterSetTest.java
+++ b/src/tests/junit/org/apache/tools/ant/types/FilterSetTest.java
@@ -32,7 +32,6 @@ import java.util.Hashtable;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 /**
  * FilterSet testing
@@ -189,14 +188,10 @@ public class FilterSetTest {
         buildRule.executeTarget("testMultipleFiltersFiles");
     }
 
-    @Test
+    @Test(expected = BuildException.class)
     public void testMissingFiltersFile() {
-        try {
-            buildRule.executeTarget("testMissingFiltersFile");
-            fail("should fail due to missing  filtersfile");
-        } catch (BuildException ex) {
-            //TODO assert exception text
-        }
+        buildRule.executeTarget("testMissingFiltersFile");
+        // TODO assert exception text
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/types/RedirectorElementTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/types/RedirectorElementTest.java b/src/tests/junit/org/apache/tools/ant/types/RedirectorElementTest.java
index 567d378..4055ffe 100644
--- a/src/tests/junit/org/apache/tools/ant/types/RedirectorElementTest.java
+++ b/src/tests/junit/org/apache/tools/ant/types/RedirectorElementTest.java
@@ -27,7 +27,6 @@ import org.junit.Test;
 import static org.hamcrest.Matchers.containsString;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 public class RedirectorElementTest {
 
@@ -46,24 +45,20 @@ public class RedirectorElementTest {
             instanceof RedirectorElement));
     }
 
-    @Test
+    /**
+     * Expected failure due to multiple attributes when using refid
+     */
+    @Test(expected = BuildException.class)
     public void test2() {
-        try {
-            buildRule.executeTarget("test2");
-            fail("You must not specify more than one attribute when using refid");
-        } catch (BuildException ex) {
-            //TODO assert exception message
-        }
+        buildRule.executeTarget("test2");
     }
 
-    @Test
+    /**
+     * Expected failure due to nested elements when using refid
+     */
+    @Test(expected = BuildException.class)
     public void test3() {
-        try {
-            buildRule.executeTarget("test3");
-            fail("You must not specify nested elements when using refid");
-        } catch (BuildException ex) {
-            //TODO assert exception message
-        }
+        buildRule.executeTarget("test3");
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/types/ResourceOutputTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/types/ResourceOutputTest.java b/src/tests/junit/org/apache/tools/ant/types/ResourceOutputTest.java
index 25a653d..167d3e7 100644
--- a/src/tests/junit/org/apache/tools/ant/types/ResourceOutputTest.java
+++ b/src/tests/junit/org/apache/tools/ant/types/ResourceOutputTest.java
@@ -23,6 +23,7 @@ import java.io.IOException;
 import java.net.UnknownServiceException;
 
 import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.taskdefs.Zip;
 import org.apache.tools.ant.types.resources.ImmutableResourceException;
@@ -33,34 +34,40 @@ import org.apache.tools.ant.types.resources.ZipResource;
 import org.apache.tools.ant.util.FileUtils;
 import org.apache.tools.ant.util.ResourceUtils;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
 
 public class ResourceOutputTest {
 
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
+
     private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
-    private static final File basedir = new File(System.getProperty("root"),
-        "src/etc/testcases/types/resources");
+    private static final String BASE_DIR = "src/etc/testcases/types/resources";
 
     private Project project;
 
     @Before
     public void setUp() {
-        project = new Project();
-        project.init();
-        project.setUserProperty("basedir", basedir.getAbsolutePath());
+        buildRule.configureProject(BASE_DIR + "/resourcelist.xml");
+        project = buildRule.getProject();
+        if (System.getProperty("root") != null) {
+            project.setBasedir(System.getProperty("root"));
+        }
     }
 
-    @Test
+    /**
+     * Expected failure
+     */
+    @Test(expected = UnsupportedOperationException.class)
     public void testresourceoutput() {
-        try {
-            testoutputbe(new Resource("foo"));
-            fail("should have caught UnsupportedOperationException");
-        } catch (UnsupportedOperationException e) {
-            //TODO assert exception message
-        }
+        testoutputbe(new Resource("foo"));
     }
 
     @Test
@@ -70,15 +77,20 @@ public class ResourceOutputTest {
         assertEquals("foo", r.getValue());
     }
 
-    @Test
+    /**
+     * Expected failure
+     *
+     * @throws IOException if something goes wrong
+     */
+    @Test(expected = ImmutableResourceException.class)
     public void teststringoutput2() throws IOException {
         StringResource r = new StringResource("bar");
-        try {
-            testoutput(r);
-            fail("should have caught ImmutableResourceException");
-        } catch (ImmutableResourceException e) {
-            //TODO assert exception message
-        }
+        testoutput(r);
+    }
+
+    @Test
+    public void teststringoutput3() throws IOException {
+        StringResource r = new StringResource("bar");
         assertEquals("bar", r.getValue());
     }
 
@@ -89,28 +101,32 @@ public class ResourceOutputTest {
         assertEquals("foo", project.getProperty("bar"));
     }
 
-    @Test
+    /**
+     * Expected failure
+     *
+     * @throws IOException if something goes wrong
+     */
+    @Test(expected = ImmutableResourceException.class)
     public void testpropertyoutput2() throws IOException {
         project.setNewProperty("bar", "bar");
         PropertyResource r = new PropertyResource(project, "bar");
-        try {
-            testoutput(r);
-            fail("should have caught ImmutableResourceException");
-        } catch (ImmutableResourceException e) {
-            //TODO assert exception message
-        }
+        testoutput(r);
+    }
+
+    @Test
+    public void testpropertyoutput3() throws IOException {
+        project.setNewProperty("bar", "bar");
         assertEquals("bar", project.getProperty("bar"));
     }
 
     @Test
     public void testurloutput() throws IOException {
+        thrown.expect(UnknownServiceException.class);
+        // TODO assert exception message
         File f = project.resolveFile("testurloutput");
         try {
             FILE_UTILS.createNewFile(f);
             testoutput(new URLResource(f));
-            fail("should have caught UnknownServiceException");
-        } catch (UnknownServiceException e) {
-            //TODO assert exception message
         } finally {
             if (!f.delete()) {
                 f.deleteOnExit();
@@ -120,12 +136,14 @@ public class ResourceOutputTest {
 
     @Test
     public void testzipentryoutput() {
+        thrown.expect(UnsupportedOperationException.class);
+        // TODO assert exception message
         Zip z = new Zip();
         z.setProject(project);
         Zip.WhenEmpty create = new Zip.WhenEmpty();
         create.setValue("create");
         z.setWhenempty(create);
-        z.setBasedir(basedir);
+        z.setBasedir(project.getBaseDir());
         z.setExcludes("**/*");
         File f = project.resolveFile("foo");
         z.setDestFile(f);
@@ -135,9 +153,6 @@ public class ResourceOutputTest {
         r.setName("foo");
         try {
             testoutputbe(r);
-            fail("should have caught UnsupportedOperationException");
-        } catch (UnsupportedOperationException e) {
-            //TODO assert exception message
         } finally {
             if (!f.delete()) {
                 f.deleteOnExit();

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/types/resources/LazyResourceCollectionTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/types/resources/LazyResourceCollectionTest.java b/src/tests/junit/org/apache/tools/ant/types/resources/LazyResourceCollectionTest.java
index 24de5c0..8cb20aa 100644
--- a/src/tests/junit/org/apache/tools/ant/types/resources/LazyResourceCollectionTest.java
+++ b/src/tests/junit/org/apache/tools/ant/types/resources/LazyResourceCollectionTest.java
@@ -28,7 +28,6 @@ import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 public class LazyResourceCollectionTest {
 
@@ -76,7 +75,7 @@ public class LazyResourceCollectionTest {
         }
     }
 
-    @Test
+    @Test(expected = NoSuchElementException.class)
     public void testLazyLoading() {
         StringResourceCollection collectionTest = new StringResourceCollection();
         LazyResourceCollectionWrapper lazyCollection = new LazyResourceCollectionWrapper();
@@ -103,12 +102,7 @@ public class LazyResourceCollectionTest {
         assertEquals("Iterating 3 times load more than 3 resources", 3,
             stringResourceIterator.cursor);
 
-        try {
-            it.next();
-            fail("NoSuchElementException should have been raised");
-        } catch (NoSuchElementException e) {
-            // ok
-        }
+        it.next();
     }
 
     private void assertOneCreatedIterator(
@@ -117,7 +111,7 @@ public class LazyResourceCollectionTest {
                 testCollection.createdIterators.size());
     }
 
-    @Test
+    @Test(expected = NoSuchElementException.class)
     public void testCaching() {
         StringResourceCollection collectionTest = new StringResourceCollection();
         LazyResourceCollectionWrapper lazyCollection = new LazyResourceCollectionWrapper();
@@ -160,18 +154,14 @@ public class LazyResourceCollectionTest {
             "The first iterator did not lookup in the cache for a resource", 3,
             stringResourceIterator.cursor);
 
+        // next() must throw the expected NoSuchElementException;
+        // if that does not happen, assertions throw the unexpected Assertion error
         try {
             it1.next();
-            fail("NoSuchElementException should have been raised");
-        } catch (NoSuchElementException e) {
-            // ok
-        }
-
-        try {
+            assertTrue(it1.hasNext());
+        } finally {
             it2.next();
-            fail("NoSuchElementException should have been raised");
-        } catch (NoSuchElementException e) {
-            // ok
+            assertTrue(it2.hasNext());
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/util/VectorSetTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/util/VectorSetTest.java b/src/tests/junit/org/apache/tools/ant/util/VectorSetTest.java
index 1ec09c9..0785631 100644
--- a/src/tests/junit/org/apache/tools/ant/util/VectorSetTest.java
+++ b/src/tests/junit/org/apache/tools/ant/util/VectorSetTest.java
@@ -27,7 +27,6 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 public class VectorSetTest {
 
@@ -108,18 +107,12 @@ public class VectorSetTest {
         assertEquals(1, v.size());
     }
 
-    @Test
+    @Test(expected = ArrayIndexOutOfBoundsException.class)
     public void testRemoveIndex() {
         v.add(O);
         assertSame(O, v.remove(0));
         assertEquals(0, v.size());
-        try {
-            v.remove(0);
-            fail("expected an AIOBE");
-        } catch (ArrayIndexOutOfBoundsException e) {
-            //TODO assert exception values
-            // expected
-        }
+        v.remove(0);
     }
 
     @Test
@@ -204,18 +197,12 @@ public class VectorSetTest {
         assertFalse(v.removeElement(O));
     }
 
-    @Test
+    @Test(expected = ArrayIndexOutOfBoundsException.class)
     public void testRemoveElementAt() {
         v.add(O);
         v.removeElementAt(0);
         assertEquals(0, v.size());
-        try {
-            v.removeElementAt(0);
-            fail("expected an AIOBE");
-        } catch (ArrayIndexOutOfBoundsException e) {
-            //TODO assert exception values
-            // expected
-        }
+        v.removeElementAt(0);
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/zip/ExtraFieldUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/zip/ExtraFieldUtilsTest.java b/src/tests/junit/org/apache/tools/zip/ExtraFieldUtilsTest.java
index 841a2fc..ea9fb88 100644
--- a/src/tests/junit/org/apache/tools/zip/ExtraFieldUtilsTest.java
+++ b/src/tests/junit/org/apache/tools/zip/ExtraFieldUtilsTest.java
@@ -18,12 +18,15 @@
 
 package org.apache.tools.zip;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import java.util.zip.ZipException;
 
 /**
  * JUnit 4 testcases for org.apache.tools.zip.ExtraFieldUtils.
@@ -43,6 +46,9 @@ public class ExtraFieldUtilsTest implements UnixStat {
     private byte[] data;
     private byte[] aLocal;
 
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
     @Before
     public void setUp() {
         a = new AsiExtraField();
@@ -73,6 +79,10 @@ public class ExtraFieldUtilsTest implements UnixStat {
      */
     @Test
     public void testParse() throws Exception {
+        thrown.expect(ZipException.class);
+        thrown.expectMessage("bad extra field starting at " + (4 + aLocal.length)
+                        + ".  Block length of 1 bytes exceeds remaining data of 0 bytes.");
+
         ZipExtraField[] ze = ExtraFieldUtils.parse(data);
         assertEquals("number of fields", 2, ze.length);
         assertTrue("type field 1", ze[0] instanceof AsiExtraField);
@@ -84,15 +94,7 @@ public class ExtraFieldUtilsTest implements UnixStat {
 
         byte[] data2 = new byte[data.length - 1];
         System.arraycopy(data, 0, data2, 0, data2.length);
-        try {
-            ExtraFieldUtils.parse(data2);
-            fail("data should be invalid");
-        } catch (Exception e) {
-            assertEquals("message",
-                         "bad extra field starting at " + (4 + aLocal.length)
-                         + ".  Block length of 1 bytes exceeds remaining data of 0 bytes.",
-                         e.getMessage());
-        }
+        ExtraFieldUtils.parse(data2);
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/zip/ZipEntryTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/zip/ZipEntryTest.java b/src/tests/junit/org/apache/tools/zip/ZipEntryTest.java
index 7e1e3c7..7750b5c 100644
--- a/src/tests/junit/org/apache/tools/zip/ZipEntryTest.java
+++ b/src/tests/junit/org/apache/tools/zip/ZipEntryTest.java
@@ -18,20 +18,24 @@
 
 package org.apache.tools.zip;
 
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 
 import java.util.NoSuchElementException;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertSame;
-import static org.junit.Assert.fail;
 
 /**
  * JUnit 4 testcases for org.apache.tools.zip.ZipEntry.
  */
 public class ZipEntryTest {
 
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
     /**
      * test handling of extra fields
      */
@@ -79,12 +83,9 @@ public class ZipEntryTest {
         assertSame(u3, result[1]);
         assertEquals("length fourth pass", data2.length, data3.length);
 
-        try {
-            ze.removeExtraField(ExtraFieldUtilsTest.UNRECOGNIZED_HEADER);
-            fail("should be no such element");
-        } catch (NoSuchElementException nse) {
-            //TODO assert exception values
-        }
+        thrown.expect(NoSuchElementException.class);
+        //TODO assert exception values
+        ze.removeExtraField(ExtraFieldUtilsTest.UNRECOGNIZED_HEADER);
     }
 
     /**


[2/2] ant git commit: Expected exceptions galore

Posted by gi...@apache.org.
Expected exceptions galore

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

Branch: refs/heads/master
Commit: ad98e27d0caff44ec10b16b8eed07e9c4264898f
Parents: 8a3b165
Author: Gintas Grigelionis <gi...@apache.org>
Authored: Mon Apr 23 00:48:06 2018 +0200
Committer: Gintas Grigelionis <gi...@apache.org>
Committed: Mon Apr 23 00:48:06 2018 +0200

----------------------------------------------------------------------
 .../org/apache/tools/ant/DispatchTaskTest.java  |   9 +-
 .../org/apache/tools/ant/ExecutorTest.java      |  51 +++---
 .../taskdefs/AntLikeTasksAtTopLevelTest.java    |  37 ++--
 .../tools/ant/taskdefs/AntStructureTest.java    |  13 +-
 .../tools/ant/taskdefs/AvailableTest.java       | 174 ++++++++++++-------
 .../apache/tools/ant/taskdefs/BasenameTest.java |  31 +---
 .../apache/tools/ant/taskdefs/CVSPassTest.java  |  24 ++-
 .../tools/ant/taskdefs/CallTargetTest.java      |  13 +-
 .../apache/tools/ant/taskdefs/ConcatTest.java   |  35 +---
 .../tools/ant/taskdefs/ConditionTest.java       |  88 ++++------
 .../apache/tools/ant/taskdefs/CopydirTest.java  |  53 +++---
 .../apache/tools/ant/taskdefs/CopyfileTest.java |  49 ++----
 .../apache/tools/ant/taskdefs/DeleteTest.java   |  29 +++-
 .../apache/tools/ant/taskdefs/DeltreeTest.java  |  15 +-
 .../apache/tools/ant/taskdefs/DirnameTest.java  |  42 ++---
 .../org/apache/tools/ant/taskdefs/FailTest.java | 123 +++++--------
 .../apache/tools/ant/taskdefs/FilterTest.java   |  57 ++----
 .../apache/tools/ant/taskdefs/GUnzipTest.java   |  27 ++-
 .../apache/tools/ant/taskdefs/InputTest.java    |  23 +--
 .../apache/tools/ant/taskdefs/MkdirTest.java    |  35 ++--
 .../apache/tools/ant/taskdefs/RenameTest.java   |  52 +++---
 .../apache/tools/ant/taskdefs/ReplaceTest.java  |  81 ++++-----
 .../apache/tools/ant/taskdefs/SignJarTest.java  |  14 +-
 .../apache/tools/ant/taskdefs/SleepTest.java    |  18 +-
 .../apache/tools/ant/taskdefs/StyleTest.java    |  35 ++--
 .../org/apache/tools/ant/taskdefs/TarTest.java  |  79 ++++-----
 .../apache/tools/ant/taskdefs/TaskdefTest.java  |  67 ++++---
 .../apache/tools/ant/taskdefs/UntarTest.java    |  12 +-
 .../apache/tools/ant/taskdefs/UnzipTest.java    |  56 +++---
 .../apache/tools/ant/taskdefs/XmlnsTest.java    |  18 +-
 .../tools/ant/taskdefs/condition/HttpTest.java  |  13 +-
 .../ant/taskdefs/condition/IsReferenceTest.java |  17 +-
 .../taskdefs/condition/ParserSupportsTest.java  |  34 ++--
 .../tools/ant/taskdefs/email/EmailTaskTest.java |  28 ++-
 .../tools/ant/taskdefs/optional/ANTLRTest.java  |  70 ++++----
 .../tools/ant/taskdefs/optional/JspcTest.java   |  14 +-
 .../tools/ant/taskdefs/optional/PvcsTest.java   |  26 ++-
 .../junitlauncher/JUnitLauncherTaskTest.java    |  11 +-
 .../ant/taskdefs/optional/net/FTPTest.java      |  32 +---
 .../ant/taskdefs/optional/sos/SOSTest.java      |  15 +-
 .../ant/taskdefs/optional/ssh/ScpTest.java      |  24 ++-
 .../apache/tools/ant/types/CommandlineTest.java |  38 ++--
 .../ant/types/EnumeratedAttributeTest.java      |  53 +++---
 .../apache/tools/ant/types/FilterSetTest.java   |  11 +-
 .../tools/ant/types/RedirectorElementTest.java  |  25 ++-
 .../tools/ant/types/ResourceOutputTest.java     |  83 +++++----
 .../resources/LazyResourceCollectionTest.java   |  26 +--
 .../apache/tools/ant/util/VectorSetTest.java    |  21 +--
 .../apache/tools/zip/ExtraFieldUtilsTest.java   |  26 +--
 .../org/apache/tools/zip/ZipEntryTest.java      |  15 +-
 50 files changed, 844 insertions(+), 1098 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/DispatchTaskTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/DispatchTaskTest.java b/src/tests/junit/org/apache/tools/ant/DispatchTaskTest.java
index dab734f..4c76dc5 100644
--- a/src/tests/junit/org/apache/tools/ant/DispatchTaskTest.java
+++ b/src/tests/junit/org/apache/tools/ant/DispatchTaskTest.java
@@ -18,8 +18,6 @@
 
 package org.apache.tools.ant;
 
-import static org.junit.Assert.fail;
-
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -34,13 +32,8 @@ public class DispatchTaskTest {
         buildRule.configureProject("src/etc/testcases/core/dispatch/dispatch.xml");
     }
 
-    @Test
+    @Test(expected = BuildException.class)
     public void testDisp() {
-        try {
             buildRule.executeTarget("disp");
-            fail("BuildException should have been thrown");
-        } catch (BuildException ex) {
-            //FIXME the previous method used here ignored the build exception - what are we trying to test
-        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/ExecutorTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/ExecutorTest.java b/src/tests/junit/org/apache/tools/ant/ExecutorTest.java
index 283b04e..acf526f 100644
--- a/src/tests/junit/org/apache/tools/ant/ExecutorTest.java
+++ b/src/tests/junit/org/apache/tools/ant/ExecutorTest.java
@@ -19,23 +19,29 @@
 package org.apache.tools.ant;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
 
 import java.util.Vector;
 
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 
 /**
  * Executor tests
  */
 public class ExecutorTest implements BuildListener  {
 
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
+
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
     private static final String SINGLE_CHECK
-        = "org.apache.tools.ant.helper.SingleCheckExecutor";
+            = "org.apache.tools.ant.helper.SingleCheckExecutor";
     private static final String IGNORE_DEPS
-        = "org.apache.tools.ant.helper.IgnoreDependenciesExecutor";
+            = "org.apache.tools.ant.helper.IgnoreDependenciesExecutor";
 
     private static final Vector<String> TARGET_NAMES;
     static {
@@ -44,9 +50,6 @@ public class ExecutorTest implements BuildListener  {
         TARGET_NAMES.add("b");
     }
 
-    @Rule
-    public BuildFileRule buildRule = new BuildFileRule();
-
     private int targetCount;
 
     /* BuildListener stuff */
@@ -117,22 +120,22 @@ public class ExecutorTest implements BuildListener  {
 
     @Test
     public void testDefaultFailure() {
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("failfoo");
         try {
             getProject(null, true).executeTargets(TARGET_NAMES);
-            fail("should fail");
-        } catch (BuildException e) {
-            assertEquals("failfoo", e.getMessage());
+        } finally {
             assertEquals(1, targetCount);
         }
     }
 
     @Test
     public void testSingleCheckFailure() {
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("failfoo");
         try {
             getProject(SINGLE_CHECK, true).executeTargets(TARGET_NAMES);
-            fail("should fail");
-        } catch (BuildException e) {
-            assertEquals("failfoo", e.getMessage());
+        } finally {
             assertEquals(1, targetCount);
         }
     }
@@ -145,36 +148,36 @@ public class ExecutorTest implements BuildListener  {
 
     @Test
     public void testKeepGoingDefault() {
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("failfoo");
         try {
             getProject(null, true, true).executeTargets(TARGET_NAMES);
-            fail("should fail");
-        } catch (BuildException e) {
-            assertEquals("failfoo", e.getMessage());
+        } finally {
             assertEquals(2, targetCount);
         }
     }
 
     @Test
     public void testKeepGoingSingleCheck() {
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("failfoo");
         try {
             getProject(SINGLE_CHECK, true, true).executeTargets(TARGET_NAMES);
-            fail("should fail");
-        } catch (BuildException e) {
-            assertEquals("failfoo", e.getMessage());
+        } finally {
             assertEquals(1, targetCount);
         }
     }
 
     @Test
     public void testKeepGoingIgnoreDependencies() {
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("failfoo");
+        Vector<String> targetNames = new Vector<>(TARGET_NAMES);
+        // explicitly add foo for failure
+        targetNames.add(0, "foo");
         try {
-            //explicitly add foo for failure
-            Vector<String> targetNames = new Vector<>(TARGET_NAMES);
-            targetNames.add(0, "foo");
             getProject(IGNORE_DEPS, true, true).executeTargets(targetNames);
-            fail("should fail");
-        } catch (BuildException e) {
-            assertEquals("failfoo", e.getMessage());
+        } finally {
             assertEquals(3, targetCount);
         }
     }

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/AntLikeTasksAtTopLevelTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/AntLikeTasksAtTopLevelTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/AntLikeTasksAtTopLevelTest.java
index cb03609..6333106 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/AntLikeTasksAtTopLevelTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/AntLikeTasksAtTopLevelTest.java
@@ -22,9 +22,7 @@ import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.BuildFileRule;
 import org.junit.Rule;
 import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import org.junit.rules.ExpectedException;
 
 /**
  * @since Ant 1.6
@@ -34,37 +32,28 @@ public class AntLikeTasksAtTopLevelTest {
     @Rule
     public BuildFileRule buildRule = new BuildFileRule();
 
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
     @Test
     public void testAnt() {
-        try {
-            buildRule.configureProject("src/etc/testcases/taskdefs/toplevelant.xml");
-            fail("no exception thrown");
-        } catch (BuildException e) {
-            assertEquals("ant task at the top level must not invoke its own"
-                         + " build file.", e.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("ant task at the top level must not invoke its own build file.");
+        buildRule.configureProject("src/etc/testcases/taskdefs/toplevelant.xml");
     }
 
     @Test
     public void testSubant() {
-        try {
-            buildRule.configureProject("src/etc/testcases/taskdefs/toplevelsubant.xml");
-            fail("no exception thrown");
-        } catch (BuildException e) {
-            assertEquals("subant task at the top level must not invoke its own"
-                         + " build file.", e.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("subant task at the top level must not invoke its own build file.");
+        buildRule.configureProject("src/etc/testcases/taskdefs/toplevelsubant.xml");
     }
 
     @Test
     public void testAntcall() {
-        try {
-            buildRule.configureProject("src/etc/testcases/taskdefs/toplevelantcall.xml");
-            fail("no exception thrown");
-        } catch (BuildException e) {
-            assertEquals("antcall must not be used at the top level.",
-                         e.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("antcall must not be used at the top level.");
+        buildRule.configureProject("src/etc/testcases/taskdefs/toplevelantcall.xml");
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/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 8c05288..6787436 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/AntStructureTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/AntStructureTest.java
@@ -34,7 +34,6 @@ 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;
 
 /**
  */
@@ -53,14 +52,12 @@ public class AntStructureTest {
         buildRule.executeTarget("tearDown");
     }
 
-    @Test
+    /**
+     * Expected failure due lacking a required argument
+     */
+    @Test(expected = BuildException.class)
     public void test1() {
-        try {
-            buildRule.executeTarget("test1");
-            fail("required argument not specified");
-        } catch (BuildException ex) {
-            //TODO assert exception message
-        }
+        buildRule.executeTarget("test1");
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/AvailableTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/AvailableTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/AvailableTest.java
index be14160..0666a72 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/AvailableTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/AvailableTest.java
@@ -21,12 +21,12 @@ package org.apache.tools.ant.taskdefs;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.BuildFileRule;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
 
 /**
  * JUnit test for the Available task/condition.
@@ -43,95 +43,104 @@ public class AvailableTest {
         buildRule.executeTarget("setUp");
     }
 
-    // Nothing specified -> Fail
-    @Test
+    /**
+     *  Nothing specified -&gt; Fail
+     */
+    @Test(expected = BuildException.class)
     public void test1() {
-        try {
-            buildRule.executeTarget("test1");
-            fail("Required argument not specified");
-        } catch (BuildException ex) {
-            //TODO assert exception message
-        }
+        buildRule.executeTarget("test1");
     }
 
-    // Only property specified -> Fail
-    @Test
+    /**
+     * Only property specified -&gt; Fail
+     */
+    @Test(expected = BuildException.class)
     public void test2() {
-        try {
-            buildRule.executeTarget("test2");
-            fail("Required argument not specified");
-        } catch (BuildException ex) {
-            //TODO assert exception message
-        }
+        buildRule.executeTarget("test2");
     }
 
-    // Only file specified -> Fail
-    @Test
+    /**
+     * Only file specified -&gt; Fail
+     */
+    @Test(expected = BuildException.class)
     public void test3() {
-        try {
-            buildRule.executeTarget("test3");
-            fail("Required argument not specified");
-        } catch (BuildException ex) {
-            //TODO assert exception message
-        }
+        buildRule.executeTarget("test3");
     }
 
-    // file doesn't exist -> property 'test' == null
+    /**
+     * File doesn't exist -&gt; property 'test' == null
+     */
     @Test
     public void test4() {
         buildRule.executeTarget("test4");
         assertNull(buildRule.getProject().getProperty("test"));
     }
 
-    // file does exist -> property 'test' == 'true'
+    /**
+     * File does exist -&gt; property 'test' == 'true'
+     */
     public void test5() {
         buildRule.executeTarget("test5");
         assertEquals("true", buildRule.getProject().getProperty("test"));
     }
 
-    // resource doesn't exist -> property 'test' == null
+    /**
+     * Resource doesn't exist -&gt; property 'test' == null
+     */
     @Test
     public void test6() {
         buildRule.executeTarget("test6");
         assertNull(buildRule.getProject().getProperty("test"));
     }
 
-    // resource does exist -> property 'test' == 'true'
+    /**
+     * Resource does exist -&gt; property 'test' == 'true'
+     */
     @Test
     public void test7() {
         buildRule.executeTarget("test7");
         assertEquals("true", buildRule.getProject().getProperty("test"));
     }
 
-    // class doesn't exist -> property 'test' == null
+    /**
+     * Class doesn't exist -&gt; property 'test' == null
+     */
     @Test
     public void test8() {
         buildRule.executeTarget("test8");
         assertNull(buildRule.getProject().getProperty("test"));
     }
 
-    // class does exist -> property 'test' == 'true'
+    /**
+     * class does exist -&gt; property 'test' == 'true'
+     */
     @Test
     public void test9() {
         buildRule.executeTarget("test9");
         assertEquals("true", buildRule.getProject().getProperty("test"));
     }
 
-    // All three specified and all three exist -> true
+    /**
+     * All three specified and all three exist -&gt; true
+     */
     @Test
     public void test10() {
         buildRule.executeTarget("test10");
         assertEquals("true", buildRule.getProject().getProperty("test"));
     }
 
-    // All three specified but class missing -> null
+    /**
+     * All three specified but class missing -&gt; null
+     */
     @Test
     public void test11() {
         buildRule.executeTarget("test11");
         assertNull(buildRule.getProject().getProperty("test"));
     }
 
-    // Specified property-name is "" -> true
+    /**
+     * Specified property-name is "" -&gt; true
+     */
     @Test
     public void test12() {
         buildRule.executeTarget("test12");
@@ -139,131 +148,162 @@ public class AvailableTest {
         assertEquals("true", buildRule.getProject().getProperty(""));
     }
 
-    // Specified file is "" -> invalid files do not exist
+    /**
+     * Specified file is "" -&gt; invalid files do not exist
+     */
     @Test
     public void test13() {
         buildRule.executeTarget("test13");
         assertNull(buildRule.getProject().getProperty("test"));
     }
 
-    // Specified file is "" actually a directory, so it should pass
+    /**
+     * Specified file is "" actually a directory, so it should pass
+     */
     @Test
     public void test13b() {
         buildRule.executeTarget("test13b");
         assertEquals("true", buildRule.getProject().getProperty("test"));
     }
 
-    // Specified resource is "" -> can such a thing exist?
-    /*
-     * returns non null IBM JDK 1.3 Linux
+    /**
+     * Specified resource is "" -gt; can such a thing exist?
      */
-//    public void test14() {
-//        buildRule.executeTarget("test14");
-//        assertEquals(buildRule.getProject().getProperty("test"), null);
-//    }
+    @Ignore("returns non null IBM JDK 1.3 Linux")
+    @Test
+    public void test14() {
+        buildRule.executeTarget("test14");
+        assertEquals(buildRule.getProject().getProperty("test"), null);
+    }
 
-    // Specified class is "" -> can not exist
+    /**
+     * Specified class is "" -&gt; can not exist
+     */
     @Test
     public void test15() {
         buildRule.executeTarget("test15");
         assertNull(buildRule.getProject().getProperty("test"));
     }
 
-    // Specified dir is "" -> this is the current directory and should
-    // always exist
+    /**
+     * Specified dir is "" -&gt; this is the current directory and should always exist
+     */
     @Test
     public void test16() {
         buildRule.executeTarget("test16");
         assertEquals("true", buildRule.getProject().getProperty("test"));
     }
 
-    // Specified dir is "../taskdefs" -> should exist since it's the
-    // location of the buildfile used...
+    /**
+     * Specified dir is "../taskdefs" -&gt; should exist since it's the location
+     * of the buildfile used...
+     */
     @Test
     public void test17() {
         buildRule.executeTarget("test17");
         assertEquals("true", buildRule.getProject().getProperty("test"));
     }
 
-    // Specified dir is "../this_dir_should_never_exist" -> null
+    /**
+     * Specified dir is "../this_dir_should_never_exist" -&gt; null
+     */
     @Test
     public void test18() {
         buildRule.executeTarget("test18");
         assertNull(buildRule.getProject().getProperty("test"));
     }
 
-    // Invalid type specified
-    @Test
+    /**
+     * Invalid type specified
+     */
+    @Test(expected = BuildException.class)
     public void test19() {
-        try {
-            buildRule.executeTarget("test19");
-            fail("Invalid value for type attribute");
-        } catch (BuildException ex) {
-            //TODO assert exception message
-        }
+        buildRule.executeTarget("test19");
     }
 
-    // Core class that exists in system classpath is ignored
+    /**
+     * Core class that exists in system classpath is ignored
+     */
     @Test
     public void test20() {
         buildRule.executeTarget("test20");
         assertNull(buildRule.getProject().getProperty("test"));
     }
 
-    // Core class that exists in system classpath is ignored, but found in specified classpath
+    /**
+     * Core class that exists in system classpath is ignored, but found in specified classpath
+     */
     @Test
     public void test21() {
         buildRule.executeTarget("test21");
         assertEquals("true", buildRule.getProject().getProperty("test"));
     }
 
-    // Core class that exists in system classpath is not ignored with ignoresystemclass="false"
+    /**
+     * Core class that exists in system classpath is not ignored with ignoresystemclass="false"
+     */
     @Test
     public void test22() {
         buildRule.executeTarget("test22");
         assertEquals("true", buildRule.getProject().getProperty("test"));
     }
 
-    // Core class that exists in system classpath is not ignored with default ignoresystemclasses value
+    /**
+     * Core class that exists in system classpath is not ignored with default
+     * ignoresystemclasses value
+     */
     @Test
     public void test23() {
         buildRule.executeTarget("test23");
         assertEquals("true", buildRule.getProject().getProperty("test"));
     }
 
-    // Class is found in specified classpath
+    /**
+     * Class is found in specified classpath
+     */
     @Test
     public void test24() {
         buildRule.executeTarget("test24");
         assertEquals("true", buildRule.getProject().getProperty("test"));
     }
 
-    // File is not found in specified filepath
+    /**
+     * File is not found in specified filepath
+     */
     @Test
     public void testSearchInPathNotThere() {
         buildRule.executeTarget("searchInPathNotThere");
         assertNull(buildRule.getProject().getProperty("test"));
     }
 
-    // File is not found in specified filepath
+    /**
+     * File is not found in specified filepath
+     */
     @Test
     public void testSearchInPathIsThere() {
         buildRule.executeTarget("searchInPathIsThere");
         assertEquals("true", buildRule.getProject().getProperty("test"));
     }
 
-    // test when file begins with basedir twice
+    /**
+     * File begins with basedir twice
+     */
     @Test
     public void testDoubleBasedir() {
         buildRule.executeTarget("testDoubleBasedir");
     }
 
-    // test for searching parents
+    /**
+     * Search parents
+     */
     @Test
     public void testSearchParents() {
         buildRule.executeTarget("search-parents");
     }
-    // test for not searching parents
+
+    /**
+     * Do not search parents
+     */
     @Test
     public void testSearchParentsNot() {
         buildRule.executeTarget("search-parents-not");

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/BasenameTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/BasenameTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/BasenameTest.java
index 3915d6b..313271d 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/BasenameTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/BasenameTest.java
@@ -25,7 +25,6 @@ import org.junit.Rule;
 import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
 
 /**
  */
@@ -39,34 +38,22 @@ public class BasenameTest {
         buildRule.configureProject("src/etc/testcases/taskdefs/basename.xml");
     }
 
-    @Test
+    @Test(expected = BuildException.class)
     public void test1() {
-        try {
-            buildRule.executeTarget("test1");
-            fail("Required attribute missing");
-        } catch (BuildException ex) {
-            //TODO assert exception message
-        }
+        buildRule.executeTarget("test1");
+        // TODO assert exception message
     }
 
-    @Test
+    @Test(expected = BuildException.class)
     public void test2() {
-        try {
-            buildRule.executeTarget("test2");
-            fail("Required attribute missing");
-        } catch (BuildException ex) {
-            //TODO assert exception message
-        }
+        buildRule.executeTarget("test2");
+        // TODO assert exception message
     }
 
-    @Test
+    @Test(expected = BuildException.class)
     public void test3() {
-        try {
-            buildRule.executeTarget("test3");
-            fail("Required attribute missing");
-        } catch (BuildException ex) {
-            //TODO assert exception message
-        }
+        buildRule.executeTarget("test3");
+        // TODO assert exception message
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/CVSPassTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/CVSPassTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/CVSPassTest.java
index a83a9c3..22329d2 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/CVSPassTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/CVSPassTest.java
@@ -27,10 +27,10 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 /**
  * Tests CVSLogin task.
@@ -46,8 +46,10 @@ public class CVSPassTest {
         ":pserver:guest@cvs.tigris.org:/cvs AIbdZ,";
 
     @Rule
-    public final BuildFileRule buildRule = new BuildFileRule();
+    public ExpectedException thrown = ExpectedException.none();
 
+    @Rule
+    public final BuildFileRule buildRule = new BuildFileRule();
 
     @Before
     public void setUp() {
@@ -56,22 +58,16 @@ public class CVSPassTest {
 
     @Test
     public void testNoCVSRoot() {
-        try {
-            buildRule.executeTarget("test1");
-            fail("BuildException not thrown");
-        } catch (BuildException e) {
-            assertEquals("cvsroot is required", e.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("cvsroot is required");
+        buildRule.executeTarget("test1");
     }
 
     @Test
     public void testNoPassword() {
-        try {
-            buildRule.executeTarget("test2");
-            fail("BuildException not thrown");
-        } catch (BuildException e) {
-            assertEquals("password is required", e.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("password is required");
+        buildRule.executeTarget("test2");
     }
 
     @After

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/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 81f7cbf..f7dddcf 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/CallTargetTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/CallTargetTest.java
@@ -29,7 +29,6 @@ import java.util.Vector;
 import static org.hamcrest.Matchers.containsString;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
 
 /**
  */
@@ -68,14 +67,12 @@ public class CallTargetTest {
         assertThat(buildRule.getLog(), containsString("multi is SETmulti is SET"));
     }
 
-    @Test
+    /**
+     * Expected failure due to empty target name
+     */
+    @Test(expected = BuildException.class)
     public void testBlankTarget() {
-        try {
-            buildRule.executeTarget("blank-target");
-            fail("target name must not be empty");
-        } catch (BuildException ex) {
-            //TODO assert exception contents
-        }
+        buildRule.executeTarget("blank-target");
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/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 e4e8b3f..0e8f4cc 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/ConcatTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ConcatTest.java
@@ -34,7 +34,6 @@ import static org.hamcrest.Matchers.not;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 /**
  * A test class for the 'concat' task, used to concatenate a series of
@@ -79,28 +78,19 @@ public class ConcatTest {
     /**
      * Expect an exception when insufficient information is provided.
      */
-    @Test
+    @Test(expected = BuildException.class)
     public void test1() {
-        try {
-            buildRule.executeTarget("test1");
-            fail("BuildException should have been thrown - Insufficient information");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
-
+        buildRule.executeTarget("test1");
+        // TODO assert value
     }
 
     /**
      * Expect an exception when the destination file is invalid.
      */
-    @Test
+    @Test(expected = BuildException.class)
     public void test2() {
-        try {
-            buildRule.executeTarget("test2");
-            fail("BuildException should have been thrown - Invalid destination file");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test2");
+        // TODO assert value
     }
 
     /**
@@ -108,14 +98,12 @@ public class ConcatTest {
      */
     @Test
     public void test3() {
-
         File file = new File(buildRule.getProject().getBaseDir(), tempFile);
         if (file.exists()) {
             file.delete();
         }
 
         buildRule.executeTarget("test3");
-
         assertTrue(file.exists());
     }
 
@@ -179,7 +167,6 @@ public class ConcatTest {
         final long newSize = file2.length();
 
         assertEquals(origSize, newSize);
-
     }
 
     @Test
@@ -195,7 +182,6 @@ public class ConcatTest {
         final long newSize = file2.length();
 
         assertEquals(origSize * 2, newSize);
-
     }
 
     @Test
@@ -237,14 +223,9 @@ public class ConcatTest {
     /**
      * Expect an exception when attempting to cat an file to itself
      */
-    @Test
+    @Test(expected = BuildException.class)
     public void testsame() {
-        try {
-            buildRule.executeTarget("samefile");
-            fail("Build exception should have been thrown - output file same as input");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("samefile");
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/ConditionTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ConditionTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ConditionTest.java
index 9329512..0b4d227 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/ConditionTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ConditionTest.java
@@ -23,16 +23,18 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
 
 public class ConditionTest {
 
     @Rule
-    public BuildFileRule buildRule = new BuildFileRule();
+    public ExpectedException thrown = ExpectedException.none();
 
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
     /**
      * The JUnit setup method
@@ -59,22 +61,16 @@ public class ConditionTest {
 
     @Test
     public void testConditionIncomplete() {
-        try {
-            buildRule.executeTarget("condition-incomplete");
-            fail("BuildException should have been thrown - property attribute has been omitted");
-        } catch (BuildException ex) {
-            assertEquals("The property attribute is required.", ex.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("The property attribute is required.");
+        buildRule.executeTarget("condition-incomplete");
     }
 
     @Test
     public void testConditionEmpty() {
-        try {
-            buildRule.executeTarget("condition-empty");
-            fail("BuildException should have been thrown - no conditions");
-        } catch (BuildException ex) {
-            assertEquals("You must nest a condition into <condition>", ex.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("You must nest a condition into <condition>");
+        buildRule.executeTarget("condition-empty");
     }
 
     @Test
@@ -109,12 +105,9 @@ public class ConditionTest {
 
     @Test
     public void testNegationIncomplete() {
-        try {
-            buildRule.executeTarget("negationincomplete");
-            fail("BuildException should have been thrown - no conditions in <not>");
-        } catch (BuildException ex) {
-            assertEquals("You must nest a condition into <not>", ex.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("You must nest a condition into <not>");
+        buildRule.executeTarget("negationincomplete");
     }
 
     @Test
@@ -173,12 +166,9 @@ public class ConditionTest {
 
     @Test
     public void testFilesmatchIncomplete() {
-        try {
-            buildRule.executeTarget("filesmatch-incomplete");
-            fail("Build exception should have been thrown - Missing file2 attirbute");
-        } catch (BuildException ex) {
-            assertEquals("both file1 and file2 are required in filesmatch", ex.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("both file1 and file2 are required in filesmatch");
+        buildRule.executeTarget("filesmatch-incomplete");
     }
 
     @Test
@@ -252,22 +242,16 @@ public class ConditionTest {
 
     @Test
     public void testContainsIncomplete1() {
-        try {
-            buildRule.executeTarget("contains-incomplete1");
-            fail("BuildException should have been thrown - Missing contains attribute");
-        } catch (BuildException ex) {
-            assertEquals("both string and substring are required in contains", ex.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("both string and substring are required in contains");
+        buildRule.executeTarget("contains-incomplete1");
     }
 
     @Test
     public void testContainsIncomplete2() {
-        try {
-            buildRule.executeTarget("contains-incomplete2");
-            fail("BuildException should have been thrown - Missing contains attribute");
-        } catch (BuildException ex) {
-            assertEquals("both string and substring are required in contains", ex.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("both string and substring are required in contains");
+        buildRule.executeTarget("contains-incomplete2");
     }
 
     @Test
@@ -290,12 +274,9 @@ public class ConditionTest {
 
     @Test
     public void testIstrueIncomplete1() {
-        try {
-            buildRule.executeTarget("istrue-incomplete");
-            fail("BuildException should have been thrown - Missing attribute");
-        } catch (BuildException ex) {
-            assertEquals("Nothing to test for truth", ex.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("Nothing to test for truth");
+        buildRule.executeTarget("istrue-incomplete");
     }
 
     @Test
@@ -319,12 +300,9 @@ public class ConditionTest {
 
     @Test
     public void testIsfalseIncomplete1() {
-        try {
-            buildRule.executeTarget("isfalse-incomplete");
-            fail("BuildException should have been thrown - Missing attribute");
-        } catch (BuildException ex) {
-            assertEquals("Nothing to test for falsehood", ex.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("Nothing to test for falsehood");
+        buildRule.executeTarget("isfalse-incomplete");
     }
 
     @Test
@@ -332,14 +310,10 @@ public class ConditionTest {
         buildRule.executeTarget("testElse");
     }
 
-    @Test
+    @Test(expected = BuildException.class)
     public void testResourcesmatchError() {
-        try {
-            buildRule.executeTarget("resourcematch-error");
-            fail("BuildException should have been thrown - no resources specified");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("resourcematch-error");
+        // TODO assert value
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/CopydirTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/CopydirTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/CopydirTest.java
index 8ba8c4f..704a37d 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/CopydirTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/CopydirTest.java
@@ -26,7 +26,6 @@ import org.junit.Test;
 import java.io.File;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
 import static org.junit.Assert.assertTrue;
 
 
@@ -40,34 +39,31 @@ public class CopydirTest {
         buildRule.executeTarget("setUp");
     }
 
-    @Test
+    /**
+     * Expected failure due to required argument not specified
+     */
+    @Test(expected = BuildException.class)
     public void test1() {
-        try {
-            buildRule.executeTarget("test1");
-            fail("Required argument not specified");
-        } catch (BuildException ex) {
-            // TODO assert value
-        }
+        buildRule.executeTarget("test1");
+        // TODO Assert exception message
     }
 
-    @Test
+    /**
+     * Expected failure due to required argument not specified
+     */
+    @Test(expected = BuildException.class)
     public void test2() {
-        try {
-            buildRule.executeTarget("test2");
-            fail("Required argument not specified");
-        } catch (BuildException ex) {
-            // TODO assert value
-        }
+        buildRule.executeTarget("test2");
+        // TODO Assert exception message
     }
 
-    @Test
+    /**
+     * Expected failure due to required argument not specified
+     */
+    @Test(expected = BuildException.class)
     public void test3() {
-        try {
-            buildRule.executeTarget("test3");
-            fail("Required argument not specified");
-        } catch (BuildException ex) {
-            // TODO assert value
-        }
+        buildRule.executeTarget("test3");
+        // TODO Assert exception message
     }
 
     @Test
@@ -86,14 +82,13 @@ public class CopydirTest {
         // We keep this, so we have something to delete in later tests :-)
     }
 
-    @Test
+    /**
+     * expected failure because target is file
+     */
+    @Test(expected = BuildException.class)
     public void test6() {
-        try {
-            buildRule.executeTarget("test6");
-            fail("target is file");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test6");
+        // TODO Assert exception message
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/CopyfileTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/CopyfileTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/CopyfileTest.java
index a3d84ee..23f9f94 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/CopyfileTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/CopyfileTest.java
@@ -26,7 +26,7 @@ import org.junit.Test;
 import java.io.File;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertTrue;
 
 /**
  */
@@ -40,34 +40,22 @@ public class CopyfileTest {
         buildRule.executeTarget("setUp");
     }
 
-    @Test
+    @Test(expected = BuildException.class)
     public void test1() {
-        try {
-            buildRule.executeTarget("test1");
-            fail("Required argument not specified");
-        } catch (BuildException ex) {
-            // TODO assert value
-        }
+        buildRule.executeTarget("test1");
+        // TODO assert value
     }
 
-    @Test
+    @Test(expected = BuildException.class)
     public void test2() {
-        try {
-            buildRule.executeTarget("test2");
-            fail("Required argument not specified");
-        } catch (BuildException ex) {
-            // TODO assert value
-        }
+        buildRule.executeTarget("test2");
+        // TODO assert value
     }
 
-    @Test
+    @Test(expected = BuildException.class)
     public void test3() {
-        try {
-            buildRule.executeTarget("test3");
-            fail("Required argument not specified");
-        } catch (BuildException ex) {
-            // TODO assert value
-        }
+        buildRule.executeTarget("test3");
+        // TODO assert value
     }
 
     @Test
@@ -81,20 +69,13 @@ public class CopyfileTest {
     public void test5() {
         buildRule.executeTarget("test5");
         File f = new File(new File(buildRule.getProject().getProperty("output")), "copyfile.tmp");
-        if (f.exists()) {
-            f.delete();
-        } else {
-            fail("Copy failed");
-        }
+        assertTrue("Copy failed", f.exists());
+        f.delete();
     }
 
-    @Test
+    @Test(expected = BuildException.class)
     public void test6() {
-        try {
-            buildRule.executeTarget("test6");
-            fail("Required argument not specified");
-        } catch (BuildException ex) {
-            // TODO assert value
-        }
+        buildRule.executeTarget("test6");
+        // TODO assert value
     }
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/DeleteTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/DeleteTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/DeleteTest.java
index 4d34341..2c9b560 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/DeleteTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/DeleteTest.java
@@ -24,8 +24,6 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 
-import static org.junit.Assert.fail;
-
 /**
  */
 public class DeleteTest {
@@ -38,73 +36,86 @@ public class DeleteTest {
         buildRule.configureProject("src/etc/testcases/taskdefs/delete.xml");
     }
 
-    @Test
+    /**
+     * Expected failure due to required argument not specified
+     */
+    @Test(expected = BuildException.class)
     public void test1() {
-        try {
-            buildRule.executeTarget("test1");
-            fail("required argument not specified");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test1");
+        // TODO Assert exception message
     }
 
     @Test
     public void test2() {
         buildRule.executeTarget("test2");
     }
+
     //where oh where has my test case 3 gone?
     @Test
     public void test4() {
         buildRule.executeTarget("test4");
     }
+
     @Test
     public void test5() {
         buildRule.executeTarget("test5");
     }
+
     @Test
     public void test6() {
         buildRule.executeTarget("test6");
     }
+
     @Test
     public void test7() {
         buildRule.executeTarget("test7");
     }
+
     @Test
     public void test8() {
         buildRule.executeTarget("test8");
     }
+
     @Test
     public void test9() {
         buildRule.executeTarget("test9");
     }
+
     @Test
     public void test10() {
         buildRule.executeTarget("test10");
     }
+
     @Test
     public void test11() {
         buildRule.executeTarget("test11");
     }
+
     @Test
     public void test12() {
         buildRule.executeTarget("test12");
     }
+
     @Test
     public void test13() {
         buildRule.executeTarget("test13");
     }
+
     @Test
     public void test14() {
         buildRule.executeTarget("test14");
     }
+
     @Test
     public void test15() {
         buildRule.executeTarget("test15");
     }
+
     @Test
     public void test16() {
         buildRule.executeTarget("test16");
     }
+
     @Test
     public void test17() {
         buildRule.executeTarget("test17");

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/DeltreeTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/DeltreeTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/DeltreeTest.java
index b2dcc69..f6c617d 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/DeltreeTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/DeltreeTest.java
@@ -24,8 +24,6 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 
-import static org.junit.Assert.fail;
-
 public class DeltreeTest {
 
     @Rule
@@ -36,14 +34,13 @@ public class DeltreeTest {
         buildRule.configureProject("src/etc/testcases/taskdefs/deltree.xml");
     }
 
-    @Test
+    /**
+     * Expected failure due to missing required argument
+     */
+    @Test(expected = BuildException.class)
     public void test1() {
-        try {
-            buildRule.executeTarget("test1");
-            fail("required argument not specified");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test1");
+        // TODO Assert exception message
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/DirnameTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/DirnameTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/DirnameTest.java
index bc0d127..82d4bc9 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/DirnameTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/DirnameTest.java
@@ -19,7 +19,6 @@
 package org.apache.tools.ant.taskdefs;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
 import static org.junit.Assume.assumeFalse;
 
 import org.apache.tools.ant.BuildException;
@@ -28,6 +27,7 @@ import org.apache.tools.ant.taskdefs.condition.Os;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 
 import java.io.File;
 
@@ -36,6 +36,9 @@ import java.io.File;
 public class DirnameTest {
 
     @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
+    @Rule
     public BuildFileRule buildRule = new BuildFileRule();
 
     @Before
@@ -45,49 +48,38 @@ public class DirnameTest {
 
     @Test
     public void test1() {
-        try {
-            buildRule.executeTarget("test1");
-            fail("Build exception should have been thrown as property attribute is required");
-        } catch (BuildException ex) {
-            assertEquals("property attribute required", ex.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("property attribute required");
+        buildRule.executeTarget("test1");
     }
 
     @Test
     public void test2() {
-        try {
-            buildRule.executeTarget("test2");
-            fail("Build exception should have been thrown as file attribute is required");
-        } catch (BuildException ex) {
-            assertEquals("file attribute required", ex.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("file attribute required");
+        buildRule.executeTarget("test2");
     }
 
     @Test
     public void test3() {
-        try {
-            buildRule.executeTarget("test3");
-            fail("Build exception should have been thrown as property attribute is required");
-        } catch (BuildException ex) {
-            assertEquals("property attribute required", ex.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("property attribute required");
+        buildRule.executeTarget("test3");
     }
 
     @Test
     public void test4() {
         assumeFalse("Test not possible on DOS or Netware family OS", Os.isFamily("netware") || Os.isFamily("dos"));
         buildRule.executeTarget("test4");
-        String expected = File.separator + "usr" + File.separator + "local";
-        String checkprop = buildRule.getProject().getProperty("local.dir");
-        assertEquals("dirname failed", expected, checkprop);
+        assertEquals("dirname failed", File.separator + "usr" + File.separator + "local",
+                buildRule.getProject().getProperty("local.dir"));
     }
 
     @Test
     public void test5() {
         buildRule.executeTarget("test5");
-        String expected = buildRule.getProject().getProperty("basedir");
-        String checkprop = buildRule.getProject().getProperty("base.dir");
-        assertEquals("dirname failed", expected, checkprop);
+        assertEquals("dirname failed", buildRule.getProject().getProperty("basedir"),
+                buildRule.getProject().getProperty("base.dir"));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/FailTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/FailTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/FailTest.java
index 34299d5..41ad81c 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/FailTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/FailTest.java
@@ -23,17 +23,18 @@ import org.apache.tools.ant.BuildFileRule;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 
 import java.util.Arrays;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
 /**
  */
 public class FailTest {
 
     @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
+    @Rule
     public final BuildFileRule buildRule = new BuildFileRule();
 
     @Before
@@ -43,57 +44,42 @@ public class FailTest {
 
     @Test
     public void test1() {
-        try {
-            buildRule.executeTarget("test1");
-            fail("it is required to fail :-)");
-        } catch (BuildException ex) {
-            assertEquals("No message", ex.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("No message");
+        buildRule.executeTarget("test1");
     }
 
     @Test
     public void test2() {
-        try {
-            buildRule.executeTarget("test2");
-            fail("it is required to fail :-)");
-        } catch (BuildException ex) {
-            assertEquals("test2", ex.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("test2");
+        buildRule.executeTarget("test2");
     }
 
     @Test
     public void testText() {
-        try {
-            buildRule.executeTarget("testText");
-            fail("it is required to fail :-)");
-        } catch (BuildException ex) {
-            assertEquals("testText", ex.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("testText");
+        buildRule.executeTarget("testText");
     }
 
-    @Test
+    @Test(expected = BuildException.class)
     public void testIf() {
         buildRule.executeTarget("testIf");
         buildRule.getProject().setProperty("foo", "");
-        try {
-            buildRule.executeTarget("testIf");
-            fail("testIf must fail if foo has been set");
-        } catch (BuildException ex) {
-            //TODO assert result
-        }
+        buildRule.executeTarget("testIf");
+        // TODO assert result
     }
 
-    @Test
+    @Test(expected = BuildException.class)
     public void testUnless() {
         try {
             buildRule.executeTarget("testUnless");
-            fail("testUnless must fail unless foo has been set");
-        } catch (BuildException ex) {
             //TODO assert rules
+        } finally {
+            buildRule.getProject().setProperty("foo", "");
+            buildRule.executeTarget("testUnless");
         }
-        buildRule.getProject().setProperty("foo", "");
-        buildRule.executeTarget("testUnless");
-
     }
 
     /**
@@ -103,18 +89,18 @@ public class FailTest {
      */
     @Test
     public void testIfAndUnless() {
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("if=if and unless=unless");
         //neither
         buildRule.executeTarget("testIfAndUnless");
         buildRule.getProject().setProperty("if", "");
         try {
             buildRule.executeTarget("testIfAndUnless");
-            fail("expect fail on defined(if)");
-        } catch (BuildException ex) {
-            assertEquals("if=if and unless=unless", ex.getMessage());
+        } finally {
+            buildRule.getProject().setProperty("unless", "");
+            //this call should succeed as unless overrides if
+            buildRule.executeTarget("testIfAndUnless");
         }
-        buildRule.getProject().setProperty("unless", "");
-        //this call should succeed as unless overrides if
-        buildRule.executeTarget("testIfAndUnless");
     }
     /**
      * see that the different combinations work, and
@@ -129,12 +115,9 @@ public class FailTest {
 
     @Test
     public void testNested1() {
-        try {
-            buildRule.executeTarget("testNested1");
-            fail("it is required to fail :-)");
-        } catch (BuildException ex) {
-            assertEquals("condition satisfied", ex.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("condition satisfied");
+        buildRule.executeTarget("testNested1");
     }
 
     @Test
@@ -144,64 +127,46 @@ public class FailTest {
 
     @Test
     public void testNested3() {
-        try {
-            buildRule.executeTarget("testNested3");
-            fail("it is required to fail :-)");
-        } catch (BuildException ex) {
-            assertEquals("testNested3", ex.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("testNested3");
+        buildRule.executeTarget("testNested3");
     }
 
     @Test
     public void testNested4() {
-        String specificMessage = "Nested conditions "
-          + "not permitted in conjunction with if/unless attributes";
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("Nested conditions not permitted in conjunction with if/unless attributes");
 
         StringBuilder target = new StringBuilder("testNested4x");
         for (char ch : Arrays.asList('a', 'b', 'c')) {
             target.setCharAt(target.length() - 1, ch);
-            try {
-                buildRule.executeTarget(target.toString());
-                fail("it is required to fail :-)");
-            } catch (BuildException ex) {
-                assertEquals(specificMessage, ex.getMessage());
-            }
+            buildRule.executeTarget(target.toString());
         }
     }
 
     @Test
     public void testNested5() {
-        try {
-            buildRule.executeTarget("testNested5");
-            fail("it is required to fail :-)");
-        } catch (BuildException ex) {
-            assertEquals("Only one nested condition is allowed.", ex.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("Only one nested condition is allowed.");
+        buildRule.executeTarget("testNested5");
     }
 
     @Test
     public void testNested6() {
-        try {
-            buildRule.executeTarget("testNested6");
-            fail("it is required to fail :-)");
-        } catch (BuildException ex) {
-            assertEquals("testNested6\ntestNested6\ntestNested6", ex.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("testNested6\ntestNested6\ntestNested6");
+        buildRule.executeTarget("testNested6");
     }
 
     @Test
     public void testNested7() {
-        String specificMessage = "A single nested condition is required.";
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("A single nested condition is required.");
 
         StringBuilder target = new StringBuilder("testNested7x");
         for (char ch : Arrays.asList('a', 'b')) {
             target.setCharAt(target.length() - 1, ch);
-            try {
-                buildRule.executeTarget(target.toString());
-                fail("it is required to fail :-)");
-            } catch (BuildException ex) {
-                assertEquals(specificMessage, ex.getMessage());
-            }
+            buildRule.executeTarget(target.toString());
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/FilterTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/FilterTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/FilterTest.java
index 0e40ad8..1629f8b 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/FilterTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/FilterTest.java
@@ -32,8 +32,8 @@ import org.junit.Rule;
 import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 public class FilterTest {
 
@@ -50,34 +50,22 @@ public class FilterTest {
         buildRule.executeTarget("cleanup");
     }
 
-    @Test
+    @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
+    @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
+    @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
@@ -122,24 +110,15 @@ public class FilterTest {
     }
 
     private String getFilteredFile(String testNumber, String filteredFile) {
-
         String line = null;
         File f = new File(buildRule.getProject().getBaseDir(), filteredFile);
-        if (!f.exists()) {
-            fail("filter test" + testNumber + " failed");
-        } else {
-            BufferedReader in = null;
-            try {
-                in = new BufferedReader(new FileReader(f));
-            } catch (FileNotFoundException fnfe) {
-                fail("filter test" + testNumber + " failed, filtered file: " + f.toString() + " not found");
-            }
-            try {
-                line = in.readLine();
-                in.close();
-            } catch (IOException ioe) {
-                fail("filter test" + testNumber + " failed.  IOException while reading filtered file: " + ioe);
-            }
+        assertTrue("filter test" + testNumber + " failed", f.exists());
+
+        try (BufferedReader in = new BufferedReader(new FileReader(f))) {
+            line = in.readLine();
+        } catch (IOException ioe) {
+            assertNotNull("filter test" + testNumber
+                    + " failed.  IOException while reading filtered file: " + ioe, line);
         }
         f.delete();
         return line;

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/GUnzipTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/GUnzipTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/GUnzipTest.java
index a7aac5d..747ea8d 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/GUnzipTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/GUnzipTest.java
@@ -28,7 +28,6 @@ import org.junit.Rule;
 import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
 
 public class GUnzipTest {
 
@@ -45,24 +44,22 @@ public class GUnzipTest {
         buildRule.executeTarget("cleanup");
     }
 
-    @Test
+    /**
+     * Expected failure 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 exception message
     }
 
-    @Test
+    /**
+     * Expected failure due to invalid attribute
+     */
+    @Test(expected = BuildException.class)
     public void test2() {
-        try {
-            buildRule.executeTarget("test2");
-            fail("attribute src invalid");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test2");
+        // TODO Assert exception message
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/InputTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/InputTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/InputTest.java
index 4b6efaa..b1d1bab 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/InputTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/InputTest.java
@@ -29,26 +29,25 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
 
 public class InputTest {
 
     @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
+    @Rule
     public final BuildFileRule buildRule = new BuildFileRule();
 
     private InputStream originalStdIn;
 
-
     @Before
     public void setUp() {
         buildRule.configureProject("src/etc/testcases/taskdefs/input.xml");
-        System.getProperties()
-            .put(PropertyFileInputHandler.FILE_NAME_KEY,
-                 buildRule.getProject().resolveFile("input.properties")
-                 .getAbsolutePath());
+        System.getProperties().put(PropertyFileInputHandler.FILE_NAME_KEY,
+                buildRule.getProject().resolveFile("input.properties").getAbsolutePath());
         buildRule.getProject().setInputHandler(new PropertyFileInputHandler());
         originalStdIn = System.in;
     }
@@ -70,13 +69,9 @@ public class InputTest {
 
     @Test
     public void test3() {
-        try {
-            buildRule.executeTarget("test3");
-            fail("BuildException expected: invalid input");
-        } catch (BuildException ex) {
-             assertEquals("Found invalid input test for 'All data is going to be deleted from DB continue?'",
-                     ex.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("Found invalid input test for 'All data is going to be deleted from DB continue?'");
+        buildRule.executeTarget("test3");
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/MkdirTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/MkdirTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/MkdirTest.java
index 9864a4a..f503a7c 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/MkdirTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/MkdirTest.java
@@ -19,14 +19,14 @@ package org.apache.tools.ant.taskdefs;
 
 import java.io.File;
 
+import static org.junit.Assert.assertTrue;
+
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.BuildFileRule;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 
-import static org.junit.Assert.fail;
-
 /**
  */
 public class MkdirTest {
@@ -39,34 +39,27 @@ public class MkdirTest {
         buildRule.configureProject("src/etc/testcases/taskdefs/mkdir.xml");
     }
 
-    @Test
+    /**
+     * Expected failure due to required argument missing
+     */
+    @Test(expected = BuildException.class)
     public void test1() {
-        try {
-            buildRule.executeTarget("test1");
-            fail("BuildException expected: required argument missing");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test1");
     }
 
-    @Test
+    /**
+     * Expected failure due to directory already existing as a file
+     */
+    @Test(expected = BuildException.class)
     public void test2() {
-        try {
-            buildRule.executeTarget("test2");
-            fail("BuildException expected: directory already exists as a file");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test2");
     }
 
     @Test
     public void test3() {
         buildRule.executeTarget("test3");
         File f = new File(buildRule.getProject().getProperty("output"), "testdir.tmp");
-        if (!f.exists() || !f.isDirectory()) {
-            fail("mkdir failed");
-        } else {
-            f.delete();
-        }
+        assertTrue("mkdir failed", f.exists() && f.isDirectory());
+        f.delete();
     }
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/RenameTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/RenameTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/RenameTest.java
index ca37799..6324547 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/RenameTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/RenameTest.java
@@ -24,8 +24,6 @@ import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 
-import static org.junit.Assert.fail;
-
 public class RenameTest {
 
     @Rule
@@ -36,43 +34,37 @@ public class RenameTest {
         buildRule.configureProject("src/etc/testcases/taskdefs/rename.xml");
     }
 
-    @Test
+    /**
+     * Expected failure due to missing required argument
+     */
+    @Test(expected = BuildException.class)
     public void test1() {
-        try {
-            buildRule.executeTarget("test1");
-            fail("BuildException should have been thrown:  required argument missing");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test1");
     }
-    @Test
+
+    /**
+     * Expected failure due to missing required argument
+     */
+    @Test(expected = BuildException.class)
     public void test2() {
-        try {
-            buildRule.executeTarget("test2");
-            fail("BuildException should have been thrown: required argument missing");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test2");
     }
-    @Test
+
+    /**
+     * Expected failure due to missing required argument
+     */
+    @Test(expected = BuildException.class)
     public void test3() {
-        try {
-            buildRule.executeTarget("test3");
-            fail("BuildException should have been thrown: required argument missing");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test3");
     }
 
-    @Test
+    /**
+     * Expected failure due to source same as destination
+     */
     @Ignore("Previously commented out")
+    @Test
     public void test4() {
-        try {
-            buildRule.executeTarget("test4");
-            fail("BuildException should have been thrown: source and destination the same");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test4");
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/ReplaceTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ReplaceTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ReplaceTest.java
index 12da88d..6045f85 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/ReplaceTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ReplaceTest.java
@@ -24,8 +24,6 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 
-import junit.framework.AssertionFailedError;
-
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.BuildFileRule;
 import org.apache.tools.ant.util.FileUtils;
@@ -35,7 +33,6 @@ import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 import static org.junit.Assume.assumeTrue;
 
 /**
@@ -51,44 +48,40 @@ public class ReplaceTest {
         buildRule.executeTarget("setUp");
     }
 
-    @Test
+    /**
+     * Fail: required argument not specified
+     */
+    @Test(expected = BuildException.class)
     public void test1() {
-        try {
-            buildRule.executeTarget("test1");
-            fail("BuildException expected: required argument not specified");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test1");
+        // TODO assert value
     }
 
-    @Test
+    /**
+     * Fail: required argument not specified
+     */
+    @Test(expected = BuildException.class)
     public void test2() {
-        try {
-            buildRule.executeTarget("test2");
-            fail("BuildException expected: required argument not specified");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test2");
+        // TODO assert value
     }
 
-    @Test
+    /**
+     * Fail: required argument not specified
+     */
+    @Test(expected = BuildException.class)
     public void test3() {
-        try {
-            buildRule.executeTarget("test3");
-            fail("BuildException expected: required argument not specified");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test3");
+        // TODO assert value
     }
 
-    @Test
+    /**
+     * Fail: empty token not allowed
+     */
+    @Test(expected = BuildException.class)
     public void test4() {
-        try {
-            buildRule.executeTarget("test4");
-            fail("BuildException expected: empty token not allowed");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test4");
+        // TODO assert value
     }
 
     @Test
@@ -96,24 +89,22 @@ public class ReplaceTest {
         buildRule.executeTarget("test5");
     }
 
-    @Test
+    /**
+     * Fail: required argument not specified
+     */
+    @Test(expected = BuildException.class)
     public void test6() {
-        try {
-            buildRule.executeTarget("test6");
-            fail("BuildException expected: required argument not specified");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test6");
+        // TODO assert value
     }
 
-    @Test
+    /**
+     * Fail: empty token not allowed
+     */
+    @Test(expected = BuildException.class)
     public void test7() {
-        try {
-            buildRule.executeTarget("test7");
-            fail("BuildException expected: empty token not allowed");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test7");
+        // TODO assert value
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java
index 6a0a8ad..e8f54f8 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java
@@ -25,12 +25,12 @@ 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.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 import static org.junit.Assume.assumeFalse;
 
 /**
@@ -42,6 +42,9 @@ public class SignJarTest {
     @Rule
     public BuildFileRule buildRule = new BuildFileRule();
 
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
     @Before
     public void setUp() {
         buildRule.configureProject("src/etc/testcases/taskdefs/signjar.xml");
@@ -106,12 +109,9 @@ public class SignJarTest {
 
     @Test
     public void testTsaLocalhost() {
-        try {
-            buildRule.executeTarget("testTsaLocalhost");
-            fail("Should have thrown exception - no TSA at localhost:0");
-        } catch (BuildException ex) {
-            assertEquals("jarsigner returned: 1", ex.getMessage());
-        }
+         thrown.expect(BuildException.class);
+         thrown.expectMessage("jarsigner returned: 1");
+         buildRule.executeTarget("testTsaLocalhost");
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/SleepTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/SleepTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/SleepTest.java
index 3d6ce87..163d485 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/SleepTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/SleepTest.java
@@ -18,15 +18,14 @@
 
 package org.apache.tools.ant.taskdefs;
 
+import static org.junit.Assert.assertTrue;
+
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.BuildFileRule;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
 public class SleepTest {
 
     @Rule
@@ -72,14 +71,13 @@ public class SleepTest {
         assertTrue(timer.time() >= (2000 - ERROR_RANGE) && timer.time() < 60000);
     }
 
-    @Test
+    /**
+     * Expected failure: negative sleep periods are not supported
+     */
+    @Test(expected = BuildException.class)
     public void test5() {
-        try {
-            buildRule.executeTarget("test5");
-            fail("Negative sleep periods are not supported");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test5");
+        // TODO assert value
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/StyleTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/StyleTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/StyleTest.java
index cf3546e..e1bc594 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/StyleTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/StyleTest.java
@@ -27,13 +27,12 @@ import org.apache.tools.ant.FileUtilities;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 
 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;
 
 
 /**
@@ -46,21 +45,23 @@ public class StyleTest {
     @Rule
     public final BuildFileRule buildRule = new BuildFileRule();
 
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
     @Before
     public void setUp() {
         buildRule.configureProject("src/etc/testcases/taskdefs/style/build.xml");
     }
 
+    /**
+     * Expected failure: no stylesheet specified
+     */
     @Test
     public void testStyleIsSet() {
-
-        try {
-            buildRule.executeTarget("testStyleIsSet");
-            fail("Must throws a BuildException: no stylesheet specified");
-        } catch (BuildException ex) {
-            assertEquals("specify the stylesheet either as a filename in style attribute or as a nested resource",
-                    ex.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("specify the stylesheet either as a filename in style attribute or "
+                + "as a nested resource");
+        buildRule.executeTarget("testStyleIsSet");
     }
 
     @Test
@@ -145,15 +146,15 @@ public class StyleTest {
                    .exists());
     }
 
+    /**
+     * Expected failure: stylesheet specified twice
+     */
     @Test
     public void testWithStyleAttrAndResource() {
-        try {
-            buildRule.executeTarget("testWithStyleAttrAndResource");
-            fail("Must throws a BuildException");
-        } catch (BuildException ex) {
-            assertEquals("specify the stylesheet either as a filename in style attribute or as a "
-                    + "nested resource but not as both", ex.getMessage());
-        }
+        thrown.expect(BuildException.class);
+        thrown.expectMessage("specify the stylesheet either as a filename in style attribute or "
+                + "as a nested resource but not as both");
+        buildRule.executeTarget("testWithStyleAttrAndResource");
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/TarTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/TarTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/TarTest.java
index 6f69279..5b9815f 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/TarTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/TarTest.java
@@ -29,7 +29,6 @@ import org.junit.Rule;
 import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
 import static org.junit.Assert.assertTrue;
 
 public class TarTest {
@@ -43,44 +42,40 @@ public class TarTest {
         buildRule.executeTarget("setUp");
     }
 
-    @Test
+    /**
+     * Expected failure: required argument not specified
+     */
+    @Test(expected = BuildException.class)
     public void test1() {
-        try {
-            buildRule.executeTarget("test1");
-            fail("BuildException expected: required argument not specified");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test1");
+        // TODO assert value
     }
 
-    @Test
+    /**
+     * Expected failure: required argument not specified
+     */
+    @Test(expected = BuildException.class)
     public void test2() {
-        try {
-            buildRule.executeTarget("test2");
-            fail("BuildException expected: required argument not specified");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test2");
+        // TODO assert value
     }
 
-    @Test
+    /**
+     * Expected failure: required argument not specified
+     */
+    @Test(expected = BuildException.class)
     public void test3() {
-        try {
-            buildRule.executeTarget("test3");
-            fail("BuildException expected: required argument not specified");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test3");
+        // TODO assert value
     }
 
-    @Test
+    /**
+     * Expected failure: tar cannot include itself
+     */
+    @Test(expected = BuildException.class)
     public void test4() {
-        try {
-            buildRule.executeTarget("test4");
-            fail("BuildException expected: tar cannot include itself");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test4");
+        // TODO assert value
     }
 
     @Test
@@ -90,14 +85,13 @@ public class TarTest {
         assertTrue("Tarring a directory failed", f.exists());
     }
 
-    @Test
+    /**
+     * Expected failure due to invalid value specified for longfile attribute.
+     */
+    @Test(expected = BuildException.class)
     public void test6() {
-        try {
-            buildRule.executeTarget("test6");
-            fail("BuildException expected: Invalid value specified for longfile attribute.");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test6");
+        // TODO assert value
     }
 
     @Test
@@ -156,14 +150,13 @@ public class TarTest {
                 f1.exists());
     }
 
-    @Test
+    /**
+     * Expected failure due to invalid value specified for compression attribute.
+     */
+    @Test(expected = BuildException.class)
     public void test9() {
-        try {
-            buildRule.executeTarget("test9");
-            fail("BuildException expected: Invalid value specified for compression attribute.");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test9");
+        // TODO assert value
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ant/blob/ad98e27d/src/tests/junit/org/apache/tools/ant/taskdefs/TaskdefTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/TaskdefTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/TaskdefTest.java
index 0faf16a..55a2217 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/TaskdefTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/TaskdefTest.java
@@ -20,7 +20,6 @@ package org.apache.tools.ant.taskdefs;
 
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.BuildFileRule;
-import org.apache.tools.ant.Project;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -28,7 +27,6 @@ import org.junit.Test;
 import static org.hamcrest.Matchers.containsString;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
 
 /**
  */
@@ -42,54 +40,49 @@ public class TaskdefTest {
         buildRule.configureProject("src/etc/testcases/taskdefs/taskdef.xml");
     }
 
-    @Test
+    /**
+     * Expected failure due lacking a required argument
+     */
+    @Test(expected = BuildException.class)
     public void test1() {
-        try {
-            buildRule.executeTarget("test1");
-            fail("BuildException expected: required argument not specified");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test1");
+        // TODO Assert exception message
     }
 
-    @Test
+    /**
+     * Expected failure due lacking a required argument
+     */
+    @Test(expected = BuildException.class)
     public void test2() {
-        try {
-            buildRule.executeTarget("test2");
-            fail("BuildException expected: required argument not specified");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test2");
+        // TODO Assert exception message
     }
 
-    @Test
+    /**
+     * Expected failure due lacking a required argument
+     */
+    @Test(expected = BuildException.class)
     public void test3() {
-        try {
-            buildRule.executeTarget("test3");
-            fail("BuildException expected: required argument not specified");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test3");
+        // TODO Assert exception message
     }
 
-    @Test
+    /**
+     * Expected failure due to nonexistent class specified
+     */
+    @Test(expected = BuildException.class)
     public void test4() {
-        try {
-            buildRule.executeTarget("test4");
-            fail("BuildException expected: classname specified doesn't exist");
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test4");
+        // TODO Assert exception message
     }
 
-    @Test
+    /**
+     * Expected failure due to non-public execute() method
+     */
+    @Test(expected = BuildException.class)
     public void test5() {
-        try {
-            buildRule.executeTarget("test5");
-            fail("BuildException expected: No public execute() in " + Project.class);
-        } catch (BuildException ex) {
-            //TODO assert value
-        }
+        buildRule.executeTarget("test5");
+        // TODO Assert exception message
     }
 
     @Test