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);
     }
 
     /**

Reply via email to