You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by mc...@apache.org on 2014/04/18 23:00:43 UTC

svn commit: r1588563 [2/16] - in /ant/core/trunk: ./ manual/ manual/Types/ src/etc/testcases/taskdefs/ src/etc/testcases/taskdefs/optional/ src/etc/testcases/taskdefs/optional/antlr/ src/etc/testcases/taskdefs/optional/depend/ src/etc/testcases/taskdef...

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java Fri Apr 18 21:00:38 2014
@@ -18,9 +18,11 @@
 
 package org.apache.tools.ant;
 
-import org.apache.tools.ant.taskdefs.condition.Os;
-import org.apache.tools.ant.types.selectors.TokenizedPath;
-import org.apache.tools.ant.util.SymbolicLinkUtils;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeTrue;
+import static org.junit.Assume.assumeFalse;
 
 import java.io.File;
 import java.io.IOException;
@@ -30,34 +32,43 @@ import java.util.List;
 import java.util.Set;
 import java.util.TreeSet;
 
+import org.apache.tools.ant.taskdefs.condition.Os;
+import org.apache.tools.ant.types.selectors.TokenizedPath;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
 /**
- * JUnit 3 testcases for org.apache.tools.ant.DirectoryScanner
+ * JUnit testcases for org.apache.tools.ant.DirectoryScanner
  *
  */
-public class DirectoryScannerTest extends BuildFileTest {
-
-    public DirectoryScannerTest(String name) {super(name);}
+public class DirectoryScannerTest {
 
+	@Rule
+	public BuildFileRule buildRule = new BuildFileRule();
+	
     // keep track of what operating systems are supported here.
     private boolean supportsSymlinks = Os.isFamily("unix");
 
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/core/directoryscanner.xml");
-        getProject().executeTarget("setUp");
+        buildRule.configureProject("src/etc/testcases/core/directoryscanner.xml");
+        buildRule.getProject().executeTarget("setUp");
     }
 
-
+    @Test
     public void test1() {
         DirectoryScanner ds = new DirectoryScanner();
-        ds.setBasedir(new File(getProject().getProperty("output")));
+        ds.setBasedir(new File(buildRule.getProject().getProperty("output")));
         ds.setIncludes(new String[] {"alpha"});
         ds.scan();
         compareFiles(ds, new String[] {} ,new String[] {"alpha"});
     }
 
+    @Test
     public void test2() {
         DirectoryScanner ds = new DirectoryScanner();
-        ds.setBasedir(new File(getProject().getProperty("output")));
+        ds.setBasedir(new File(buildRule.getProject().getProperty("output")));
         ds.setIncludes(new String[] {"alpha/"});
         ds.scan();
         compareFiles(ds, new String[] {"alpha/beta/beta.xml",
@@ -65,9 +76,10 @@ public class DirectoryScannerTest extend
                      new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"});
     }
 
+    @Test
     public void test3() {
         DirectoryScanner ds = new DirectoryScanner();
-        ds.setBasedir(new File(getProject().getProperty("output")));
+        ds.setBasedir(new File(buildRule.getProject().getProperty("output")));
         ds.scan();
         compareFiles(ds, new String[] {"alpha/beta/beta.xml",
                                        "alpha/beta/gamma/gamma.xml"},
@@ -75,27 +87,30 @@ public class DirectoryScannerTest extend
                                    "alpha/beta/gamma"});
     }
 
+    @Test
     public void testFullPathMatchesCaseSensitive() {
         DirectoryScanner ds = new DirectoryScanner();
-        ds.setBasedir(new File(getProject().getProperty("output")));
+        ds.setBasedir(new File(buildRule.getProject().getProperty("output")));
         ds.setIncludes(new String[] {"alpha/beta/gamma/GAMMA.XML"});
         ds.scan();
         compareFiles(ds, new String[] {}, new String[] {});
     }
 
+    @Test
     public void testFullPathMatchesCaseInsensitive() {
         DirectoryScanner ds = new DirectoryScanner();
         ds.setCaseSensitive(false);
-        ds.setBasedir(new File(getProject().getProperty("output")));
+        ds.setBasedir(new File(buildRule.getProject().getProperty("output")));
         ds.setIncludes(new String[] {"alpha/beta/gamma/GAMMA.XML"});
         ds.scan();
         compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"},
             new String[] {});
     }
 
+    @Test
     public void test2ButCaseInsensitive() {
         DirectoryScanner ds = new DirectoryScanner();
-        ds.setBasedir(new File(getProject().getProperty("output")));
+        ds.setBasedir(new File(buildRule.getProject().getProperty("output")));
         ds.setIncludes(new String[] {"ALPHA/"});
         ds.setCaseSensitive(false);
         ds.scan();
@@ -104,28 +119,28 @@ public class DirectoryScannerTest extend
                      new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"});
     }
 
+    @Test
     public void testAllowSymlinks() {
-        if (!supportsSymlinks) {
-            return;
-        }
+        
+    	assumeTrue("Current system does not support Symlinks", supportsSymlinks);
 
-        getProject().executeTarget("symlink-setup");
+        buildRule.getProject().executeTarget("symlink-setup");
         DirectoryScanner ds = new DirectoryScanner();
-        ds.setBasedir(new File(getProject().getProperty("output")));
+        ds.setBasedir(new File(buildRule.getProject().getProperty("output")));
         ds.setIncludes(new String[] {"alpha/beta/gamma/"});
         ds.scan();
         compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"},
                      new String[] {"alpha/beta/gamma"});
     }
 
+    @Test
     public void testProhibitSymlinks() {
-        if (!supportsSymlinks) {
-            return;
-        }
+    	assumeTrue("Current system does not support Symlinks", supportsSymlinks);
+
 
-        getProject().executeTarget("symlink-setup");
+        buildRule.getProject().executeTarget("symlink-setup");
         DirectoryScanner ds = new DirectoryScanner();
-        ds.setBasedir(new File(getProject().getProperty("output")));
+        ds.setBasedir(new File(buildRule.getProject().getProperty("output")));
         ds.setIncludes(new String[] {"alpha/beta/gamma/"});
         ds.setFollowSymlinks(false);
         ds.scan();
@@ -133,26 +148,28 @@ public class DirectoryScannerTest extend
     }
 
     // father and child pattern test
+    @Test
     public void testOrderOfIncludePatternsIrrelevant() {
         String [] expectedFiles = {"alpha/beta/beta.xml",
                                    "alpha/beta/gamma/gamma.xml"};
         String [] expectedDirectories = {"alpha/beta", "alpha/beta/gamma" };
         DirectoryScanner ds = new DirectoryScanner();
-        ds.setBasedir(new File(getProject().getProperty("output")));
+        ds.setBasedir(new File(buildRule.getProject().getProperty("output")));
         ds.setIncludes(new String[] {"alpha/be?a/**", "alpha/beta/gamma/"});
         ds.scan();
         compareFiles(ds, expectedFiles, expectedDirectories);
         // redo the test, but the 2 include patterns are inverted
         ds = new DirectoryScanner();
-        ds.setBasedir(new File(getProject().getProperty("output")));
+        ds.setBasedir(new File(buildRule.getProject().getProperty("output")));
         ds.setIncludes(new String[] {"alpha/beta/gamma/", "alpha/be?a/**"});
         ds.scan();
         compareFiles(ds, expectedFiles, expectedDirectories);
     }
 
+    @Test
     public void testPatternsDifferInCaseScanningSensitive() {
         DirectoryScanner ds = new DirectoryScanner();
-        ds.setBasedir(new File(getProject().getProperty("output")));
+        ds.setBasedir(new File(buildRule.getProject().getProperty("output")));
         ds.setIncludes(new String[] {"alpha/", "ALPHA/"});
         ds.scan();
         compareFiles(ds, new String[] {"alpha/beta/beta.xml",
@@ -160,9 +177,10 @@ public class DirectoryScannerTest extend
                      new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"});
     }
 
+    @Test
     public void testPatternsDifferInCaseScanningInsensitive() {
         DirectoryScanner ds = new DirectoryScanner();
-        ds.setBasedir(new File(getProject().getProperty("output")));
+        ds.setBasedir(new File(buildRule.getProject().getProperty("output")));
         ds.setIncludes(new String[] {"alpha/", "ALPHA/"});
         ds.setCaseSensitive(false);
         ds.scan();
@@ -171,9 +189,10 @@ public class DirectoryScannerTest extend
                      new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"});
     }
 
+    @Test
     public void testFullpathDiffersInCaseScanningSensitive() {
         DirectoryScanner ds = new DirectoryScanner();
-        ds.setBasedir(new File(getProject().getProperty("output")));
+        ds.setBasedir(new File(buildRule.getProject().getProperty("output")));
         ds.setIncludes(new String[] {
             "alpha/beta/gamma/gamma.xml",
             "alpha/beta/gamma/GAMMA.XML"
@@ -183,9 +202,10 @@ public class DirectoryScannerTest extend
                      new String[] {});
     }
 
+    @Test
     public void testFullpathDiffersInCaseScanningInsensitive() {
         DirectoryScanner ds = new DirectoryScanner();
-        ds.setBasedir(new File(getProject().getProperty("output")));
+        ds.setBasedir(new File(buildRule.getProject().getProperty("output")));
         ds.setIncludes(new String[] {
             "alpha/beta/gamma/gamma.xml",
             "alpha/beta/gamma/GAMMA.XML"
@@ -196,9 +216,10 @@ public class DirectoryScannerTest extend
                      new String[] {});
     }
 
+    @Test
     public void testParentDiffersInCaseScanningSensitive() {
         DirectoryScanner ds = new DirectoryScanner();
-        ds.setBasedir(new File(getProject().getProperty("output")));
+        ds.setBasedir(new File(buildRule.getProject().getProperty("output")));
         ds.setIncludes(new String[] {"alpha/", "ALPHA/beta/"});
         ds.scan();
         compareFiles(ds, new String[] {"alpha/beta/beta.xml",
@@ -206,9 +227,10 @@ public class DirectoryScannerTest extend
                      new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"});
     }
 
+    @Test
     public void testParentDiffersInCaseScanningInsensitive() {
         DirectoryScanner ds = new DirectoryScanner();
-        ds.setBasedir(new File(getProject().getProperty("output")));
+        ds.setBasedir(new File(buildRule.getProject().getProperty("output")));
         ds.setIncludes(new String[] {"alpha/", "ALPHA/beta/"});
         ds.setCaseSensitive(false);
         ds.scan();
@@ -222,8 +244,10 @@ public class DirectoryScannerTest extend
      * Only supports test on Linux at the moment because Java has
      * no real notion of symlinks built in, so an os-specfic call
      * to Runtime.exec() must be made to create a link to test against.
+     * @throws InterruptedException 
      */
-    public void testSetFollowLinks() throws IOException {
+    @Test
+    public void testSetFollowLinks() throws IOException, InterruptedException {
         if (supportsSymlinks) {
             File linkFile = new File(System.getProperty("root"), "src/main/org/apache/tools/ThisIsALink");
             System.err.println("link exists pre-test? " + linkFile.exists());
@@ -233,20 +257,11 @@ public class DirectoryScannerTest extend
                 String[] command = new String[] {
                     "ln", "-s", "ant", linkFile.getAbsolutePath()
                 };
-                try {
-                    Runtime.getRuntime().exec(command);
-                    // give ourselves some time for the system call
-                    // to execute... tweak if you have a really over
-                    // loaded system.
-                    Thread.sleep(1000);
-                } catch (IOException ioe) {
-                    fail("IOException making link "+ioe);
-                } catch (InterruptedException ie) {
-                }
+                Process process = Runtime.getRuntime().exec(command);
+                assertEquals("0 return code expected for external process", 0, process.waitFor());
+
 
                 File dir = new File(System.getProperty("root"), "src/main/org/apache/tools");
-                System.err.println("link exists after exec? " + linkFile.exists());
-                System.err.println("Ant knows it is a link? " + SymbolicLinkUtils.getSymbolicLinkUtils().isSymbolicLink(dir, "ThisIsALink"));
 
                 DirectoryScanner ds = new DirectoryScanner();
 
@@ -304,18 +319,19 @@ public class DirectoryScannerTest extend
                            !haveTaskdefsPackage);
 
             } finally {
-                System.err.println("link exists pre-delete? " + linkFile.exists());
                 if (!linkFile.delete()) {
-                    throw new RuntimeException("Failed to delete " + linkFile);
+                    //TODO log this?
+                    //throw new RuntimeException("Failed to delete " + linkFile);
                 }
-                System.err.println("link exists post-delete? " + linkFile.exists());
+
             }
         }
     }
 
+    @Test
     public void testExcludeOneFile() {
         DirectoryScanner ds = new DirectoryScanner();
-        ds.setBasedir(new File(getProject().getProperty("output")));
+        ds.setBasedir(new File(buildRule.getProject().getProperty("output")));
         ds.setIncludes(new String[] {
             "**/*.xml"
         });
@@ -327,9 +343,10 @@ public class DirectoryScannerTest extend
                      new String[] {});
     }
 
+    @Test
     public void testExcludeHasPrecedence() {
         DirectoryScanner ds = new DirectoryScanner();
-        ds.setBasedir(new File(getProject().getProperty("output")));
+        ds.setBasedir(new File(buildRule.getProject().getProperty("output")));
         ds.setIncludes(new String[] {
             "alpha/**"
         });
@@ -342,9 +359,10 @@ public class DirectoryScannerTest extend
 
     }
 
+    @Test
     public void testAlternateIncludeExclude() {
         DirectoryScanner ds = new DirectoryScanner();
-        ds.setBasedir(new File(getProject().getProperty("output")));
+        ds.setBasedir(new File(buildRule.getProject().getProperty("output")));
         ds.setIncludes(new String[] {
             "alpha/**",
             "alpha/beta/gamma/**"
@@ -358,9 +376,10 @@ public class DirectoryScannerTest extend
 
     }
 
+    @Test
     public void testAlternateExcludeInclude() {
         DirectoryScanner ds = new DirectoryScanner();
-        ds.setBasedir(new File(getProject().getProperty("output")));
+        ds.setBasedir(new File(buildRule.getProject().getProperty("output")));
         ds.setExcludes(new String[] {
             "alpha/**",
             "alpha/beta/gamma/**"
@@ -377,10 +396,11 @@ public class DirectoryScannerTest extend
     /**
      * Test inspired by Bug#1415.
      */
+    @Test
     public void testChildrenOfExcludedDirectory() {
-        getProject().executeTarget("children-of-excluded-dir-setup");
+        buildRule.getProject().executeTarget("children-of-excluded-dir-setup");
         DirectoryScanner ds = new DirectoryScanner();
-        ds.setBasedir(new File(getProject().getProperty("output")));
+        ds.setBasedir(new File(buildRule.getProject().getProperty("output")));
         ds.setExcludes(new String[] {"alpha/**"});
         ds.setFollowSymlinks(false);
         ds.scan();
@@ -388,7 +408,7 @@ public class DirectoryScannerTest extend
                     new String[] {"", "delta"});
 
         ds = new DirectoryScanner();
-        ds.setBasedir(new File(getProject().getProperty("output")));
+        ds.setBasedir(new File(buildRule.getProject().getProperty("output")));
         ds.setExcludes(new String[] {"alpha"});
         ds.setFollowSymlinks(false);
         ds.scan();
@@ -399,35 +419,35 @@ public class DirectoryScannerTest extend
 
     }
 
+    @Test
     public void testIsExcludedDirectoryScanned() {
-        String shareclassloader = getProject().getProperty("tests.and.ant.share.classloader");
+        String shareclassloader = buildRule.getProject().getProperty("tests.and.ant.share.classloader");
         // when the test is started by the build.xml of ant
         // if the property tests.and.ant.share.classloader is not set in the build.xml
         // a sysproperty with name tests.and.ant.share.classloader and value
         // ${tests.and.ant.share.classloader} will be set
         // we are trying to catch this here.
-        if (shareclassloader == null
-                || (shareclassloader != null && shareclassloader.startsWith("${"))) {
-            System.out.println("cannot execute testIsExcludedDirectoryScanned when tests are forked, " +
-                    "package private method called");
-            return;
-        }
-        getProject().executeTarget("children-of-excluded-dir-setup");
+        assumeFalse("cannot execute testIsExcludedDirectoryScanned when tests are forked, " +
+                "package private method called", shareclassloader == null
+                || (shareclassloader != null && shareclassloader.indexOf("${") == 0));
+        buildRule.getProject().executeTarget("children-of-excluded-dir-setup");
         DirectoryScanner ds = new DirectoryScanner();
-        ds.setBasedir(new File(getProject().getProperty("output")));
+        ds.setBasedir(new File(buildRule.getProject().getProperty("output")));
+
         ds.setExcludes(new String[] {"**/gamma/**"});
         ds.setFollowSymlinks(false);
         ds.scan();
-        Set set = ds.getScannedDirs();
+        Set<String> set = ds.getScannedDirs();
         assertFalse("empty set", set.isEmpty());
         String s = "alpha/beta/gamma/".replace('/', File.separatorChar);
         assertFalse("scanned " + s, set.contains(s));
     }
 
+    @Test
     public void testAbsolute1() {
-        getProject().executeTarget("extended-setup");
+        buildRule.getProject().executeTarget("extended-setup");
         DirectoryScanner ds = new DirectoryScanner();
-        String tmpdir = getProject().getProperty("output").replace(
+        String tmpdir = buildRule.getProject().getProperty("output").replace(
                 File.separatorChar, '/');
         ds.setIncludes(new String[] {tmpdir + "/**/*"});
         ds.scan();
@@ -440,6 +460,7 @@ public class DirectoryScannerTest extend
                                    tmpdir + "/delta"});
     }
 
+    @Test
     public void testAbsolute2() {
         DirectoryScanner ds = new DirectoryScanner();
         ds.setIncludes(new String[] {"alpha/**", "alpha/beta/gamma/**"});
@@ -448,10 +469,11 @@ public class DirectoryScannerTest extend
         compareFiles(ds, mt, mt);
     }
 
+    @Test
     public void testAbsolute3() {
-        getProject().executeTarget("extended-setup");
+        buildRule.getProject().executeTarget("extended-setup");
         DirectoryScanner ds = new DirectoryScanner();
-        String tmpdir = getProject().getProperty("output").replace(
+        String tmpdir = buildRule.getProject().getProperty("output").replace(
                 File.separatorChar, '/');
         ds.setIncludes(new String[] {tmpdir + "/**/*"});
         ds.setExcludes(new String[] {"**/alpha",
@@ -464,11 +486,12 @@ public class DirectoryScannerTest extend
                                    tmpdir + "/delta"});
     }
 
+    @Test
     public void testAbsolute4() {
-        getProject().executeTarget("extended-setup");
+        buildRule.getProject().executeTarget("extended-setup");
         DirectoryScanner ds = new DirectoryScanner();
-        String tmpdir = getProject().getProperty("output").replace(
-            File.separatorChar, '/') ;
+        String tmpdir = buildRule.getProject().getProperty("output").replace(
+                File.separatorChar, '/') ;
         ds.setIncludes(new String[] {tmpdir + "/alpha/beta/**/*",
                                      tmpdir + "/delta/*"});
         ds.setExcludes(new String[] {"**/beta.xml"});
@@ -478,11 +501,10 @@ public class DirectoryScannerTest extend
                      new String[] {tmpdir + "/alpha/beta/gamma"});
     }
 
+    @Test
     public void testAbsolute5() {
         //testing drive letter search from root:
-        if (!(Os.isFamily("dos") || Os.isFamily("netware"))) {
-            return;
-        }
+        assumeTrue("Can't use drive letters on non DOS or Netware systems", (Os.isFamily("dos") || Os.isFamily("netware")));
         DirectoryScanner ds = new DirectoryScanner();
         String pattern = new File(File.separator).getAbsolutePath().toUpperCase() + "*";
         ds.setIncludes(new String[] {pattern});
@@ -501,18 +523,18 @@ public class DirectoryScannerTest extend
         assertEquals("directories present: ", expectedDirectories.length,
                      includedDirectories.length);
 
-        TreeSet files = new TreeSet();
+        TreeSet<String> files = new TreeSet<String>();
         for (int counter = 0; counter < includedFiles.length; counter++) {
             files.add(includedFiles[counter].replace(File.separatorChar, '/'));
         }
-        TreeSet directories = new TreeSet();
+        TreeSet<String> directories = new TreeSet<String>();
         for (int counter = 0; counter < includedDirectories.length; counter++) {
             directories.add(includedDirectories[counter]
                             .replace(File.separatorChar, '/'));
         }
 
         String currentfile;
-        Iterator i = files.iterator();
+        Iterator<String> i = files.iterator();
         int counter = 0;
         while (i.hasNext()) {
             currentfile = (String) i.next();
@@ -520,7 +542,7 @@ public class DirectoryScannerTest extend
             counter++;
         }
         String currentdirectory;
-        Iterator dirit = directories.iterator();
+        Iterator<String> dirit = directories.iterator();
         counter = 0;
         while (dirit.hasNext()) {
             currentdirectory = (String) dirit.next();
@@ -529,19 +551,20 @@ public class DirectoryScannerTest extend
         }
     }
 
+    @Test
     public void testRecursiveExcludes() throws Exception {
         DirectoryScanner ds = new DirectoryScanner();
-        ds.setBasedir(new File(getProject().getProperty("output")));
+        ds.setBasedir(new File(buildRule.getProject().getProperty("output")));
         ds.setExcludes(new String[] {"**/beta/**"});
         ds.scan();
-        List dirs = Arrays.asList(ds.getExcludedDirectories());
+        List<String> dirs = Arrays.asList(ds.getExcludedDirectories());
         assertEquals(2, dirs.size());
         assertTrue("beta is excluded",
                    dirs.contains("alpha/beta".replace('/', File.separatorChar)));
         assertTrue("gamma is excluded",
                    dirs.contains("alpha/beta/gamma".replace('/',
                                                             File.separatorChar)));
-        List files = Arrays.asList(ds.getExcludedFiles());
+        List<String> files = Arrays.asList(ds.getExcludedFiles());
         assertEquals(2, files.size());
         assertTrue("beta.xml is excluded",
                    files.contains("alpha/beta/beta.xml"
@@ -551,6 +574,7 @@ public class DirectoryScannerTest extend
                                   .replace('/', File.separatorChar)));
     }
 
+    @Test
     public void testContentsExcluded() {
         DirectoryScanner ds = new DirectoryScanner();
         ds.setBasedir(new File("."));

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/DispatchTaskTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/DispatchTaskTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/DispatchTaskTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/DispatchTaskTest.java Fri Apr 18 21:00:38 2014
@@ -18,19 +18,29 @@
 
 package org.apache.tools.ant;
 
-import org.apache.tools.ant.BuildFileTest;
+import static org.junit.Assert.fail;
 
-public class DispatchTaskTest extends BuildFileTest {
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
 
-    public DispatchTaskTest(String name) {
-        super(name);
-    }
+public class DispatchTaskTest {
+
+	@Rule
+	public BuildFileRule buildRule = new BuildFileRule();
 
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/core/dispatch/dispatch.xml");
+        buildRule.configureProject("src/etc/testcases/core/dispatch/dispatch.xml");
     }
 
+    @Test
     public void testDisp() {
-        expectBuildException("disp", "list");
+        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
+        }
     }
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/ExecutorTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/ExecutorTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/ExecutorTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/ExecutorTest.java Fri Apr 18 21:00:38 2014
@@ -18,23 +18,35 @@
 
 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;
+
 /**
  * Executor tests
  */
-public class ExecutorTest extends BuildFileTest implements BuildListener {
-    private static final String SINGLE_CHECK
+public class ExecutorTest implements BuildListener  {
+    
+	private static final String SINGLE_CHECK
         = "org.apache.tools.ant.helper.SingleCheckExecutor";
     private static final String IGNORE_DEPS
         = "org.apache.tools.ant.helper.IgnoreDependenciesExecutor";
-    private static final Vector TARGET_NAMES;
+    
+    private static final Vector<String> TARGET_NAMES;
     static {
-        TARGET_NAMES = new Vector();
+        TARGET_NAMES = new Vector<String>();
         TARGET_NAMES.add("a");
         TARGET_NAMES.add("b");
     }
-
+    
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
+    
     private int targetCount;
 
     /* BuildListener stuff */
@@ -48,14 +60,11 @@ public class ExecutorTest extends BuildF
     public void taskFinished(BuildEvent event) {}
     public void messageLogged(BuildEvent event) {}
 
-    public ExecutorTest(String name) {
-        super(name);
-    }
-
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/core/executor.xml");
+        buildRule.configureProject("src/etc/testcases/core/executor.xml");
         targetCount = 0;
-        getProject().addBuildListener(this);
+        buildRule.getProject().addBuildListener(this);
     }
 
     private Project getProject(String e) {
@@ -67,7 +76,7 @@ public class ExecutorTest extends BuildF
     }
 
     private Project getProject(String e, boolean f, boolean k) {
-        Project p = getProject();
+        Project p = buildRule.getProject();
         p.setNewProperty("ant.executor.class", e);
         p.setKeepGoingMode(k);
         if (f) {
@@ -76,75 +85,84 @@ public class ExecutorTest extends BuildF
         return p;
     }
 
+    @Test
     public void testDefaultExecutor() {
-        getProject().executeTargets(TARGET_NAMES);
+        buildRule.getProject().executeTargets(TARGET_NAMES);
         assertEquals(4, targetCount);
     }
 
+    @Test
     public void testSingleCheckExecutor() {
         getProject(SINGLE_CHECK).executeTargets(TARGET_NAMES);
         assertEquals(3, targetCount);
     }
 
+    @Test
     public void testIgnoreDependenciesExecutor() {
         getProject(IGNORE_DEPS).executeTargets(TARGET_NAMES);
         assertEquals(2, targetCount);
     }
 
+    @Test
     public void testDefaultFailure() {
         try {
             getProject(null, true).executeTargets(TARGET_NAMES);
             fail("should fail");
         } catch (BuildException e) {
-            assertTrue(e.getMessage().equals("failfoo"));
+            assertEquals("failfoo", e.getMessage());
             assertEquals(1, targetCount);
         }
     }
 
+    @Test
     public void testSingleCheckFailure() {
         try {
             getProject(SINGLE_CHECK, true).executeTargets(TARGET_NAMES);
             fail("should fail");
         } catch (BuildException e) {
-            assertTrue(e.getMessage().equals("failfoo"));
+            assertEquals("failfoo", e.getMessage());
             assertEquals(1, targetCount);
         }
     }
 
+    @Test
     public void testIgnoreDependenciesFailure() {
         //no foo failure; foo is never executed as dependencies are ignored!
         getProject(IGNORE_DEPS, true).executeTargets(TARGET_NAMES);
     }
 
+    @Test
     public void testKeepGoingDefault() {
         try {
             getProject(null, true, true).executeTargets(TARGET_NAMES);
             fail("should fail");
         } catch (BuildException e) {
-            assertTrue(e.getMessage().equals("failfoo"));
+            assertEquals("failfoo", e.getMessage());
             assertEquals(2, targetCount);
         }
     }
 
+    @Test
     public void testKeepGoingSingleCheck() {
         try {
             getProject(SINGLE_CHECK, true, true).executeTargets(TARGET_NAMES);
             fail("should fail");
         } catch (BuildException e) {
-            assertTrue(e.getMessage().equals("failfoo"));
+            assertEquals("failfoo", e.getMessage());
             assertEquals(1, targetCount);
         }
     }
 
+    @Test
     public void testKeepGoingIgnoreDependencies() {
         try {
             //explicitly add foo for failure
-            Vector targetNames = new Vector(TARGET_NAMES);
+            Vector<String> targetNames = new Vector<String>(TARGET_NAMES);
             targetNames.add(0, "foo");
             getProject(IGNORE_DEPS, true, true).executeTargets(targetNames);
             fail("should fail");
         } catch (BuildException e) {
-            assertTrue(e.getMessage().equals("failfoo"));
+            assertEquals("failfoo", e.getMessage());
             assertEquals(3, targetCount);
         }
     }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/ExtendedTaskdefTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/ExtendedTaskdefTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/ExtendedTaskdefTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/ExtendedTaskdefTest.java Fri Apr 18 21:00:38 2014
@@ -17,49 +17,52 @@
  */
 package org.apache.tools.ant;
 
+import static org.junit.Assert.fail;
+
+import static org.apache.tools.ant.AntAssert.assertContains;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
 /**
  * created 16-Mar-2006 12:25:12
  */
 
-public class ExtendedTaskdefTest extends BuildFileTest {
-
-    /**
-     * Constructor for the BuildFileTest object.
-     *
-     * @param name string to pass up to TestCase constructor
-     */
-    public ExtendedTaskdefTest(String name) {
-        super(name);
-    }
+public class ExtendedTaskdefTest {
 
+	@Rule
+	public BuildFileRule buildRule = new BuildFileRule();
+	
+	@Before
     public void setUp() {
-        configureProject("src/etc/testcases/core/extended-taskdef.xml");
+        buildRule.configureProject("src/etc/testcases/core/extended-taskdef.xml");
     }
 
-    /**
-     * Automatically calls the target called "tearDown"
-     * from the build file tested if it exits.
-     * <p/>
-     * This allows to use Ant tasks directly in the build file
-     * to clean up after each test. Note that no "setUp" target
-     * is automatically called, since it's trivial to have a
-     * test target depend on it.
-     */
-    protected void tearDown() throws Exception {
-        super.tearDown();
-        executeTarget("teardown");
+    @After
+    public void tearDown() throws Exception {
+        buildRule.executeTarget("teardown");
     }
 
+    @Test
     public void testRun() throws Exception {
-        expectBuildExceptionContaining("testRun",
-                "exception thrown by the subclass",
-                "executing the Foo task");
+    	try {
+    		buildRule.executeTarget("testRun");
+    		fail("BuildException should have been thrown");
+    	} catch(BuildException ex) {
+    		assertContains("exception thrown by the subclass", "executing the Foo task", ex.getMessage());
+    	}
     }
 
+    @Test
     public void testRun2() throws Exception {
-        expectBuildExceptionContaining("testRun2",
-                "exception thrown by the subclass",
-                "executing the Foo task");
+    	try {
+    		buildRule.executeTarget("testRun2");
+    		fail("BuildException should have been thrown");
+    	} catch(BuildException ex) {
+    		assertContains("exception thrown by the subclass", "executing the Foo task", ex.getMessage());
+    	}
     }
 
 }

Added: ant/core/trunk/src/tests/junit/org/apache/tools/ant/FileUtilities.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/FileUtilities.java?rev=1588563&view=auto
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/FileUtilities.java (added)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/FileUtilities.java Fri Apr 18 21:00:38 2014
@@ -0,0 +1,88 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.tools.ant;
+
+
+import org.apache.tools.ant.util.FileUtils;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+
+import static org.junit.Assume.assumeTrue;
+
+public class FileUtilities {
+
+    /**
+     * Reads the contents of a file into a String.
+     * @param project the project containing the base directory the file is in.
+     * @param fileName the path to the file from the base directory.
+     * @return the contents of the given file as a string.
+     * @throws IOException on error reading the file (not existing, not readable etc)
+     */
+    public static String getFileContents(Project project, String fileName) throws IOException {
+        return getFileContents(new File(project.getBaseDir(), fileName));
+    }
+
+    /**
+     * Reads the contents of a file into a String.
+     * @param file the file to read.
+     * @return the contents of the given file as a string.
+     * @throws IOException on error reading the file (not existing, not readable etc)
+     */
+    public static String getFileContents(File file) throws IOException {
+            FileReader rdr = null;
+            try {
+                rdr = new FileReader(file);
+                return FileUtils.readFully(rdr);
+            }
+            finally {
+                if (rdr != null) {
+                rdr.close();
+            }
+        }
+    }
+
+
+    /**
+     * Modified the timestamp on a file so it's <tt>seconds</tt> earlier than it was before. Where <tt>file</tt>
+     * is a directory, this function recurses into all child files (and directories) and reduces their modified
+     * timestamps by the same range, rather than set all timestamps to the same time.
+     * @param file the file to change, or the directory to change then recurse into
+     * @param seconds how many seconds to roll the timestamp back by
+     */
+    public static void rollbackTimetamps(File file, long seconds) {
+        if (null == file || !file.exists()) {
+            return;
+        }
+
+        assumeTrue(file.setLastModified(file.lastModified() - (seconds * 1000)));
+
+        if (file.isDirectory()) {
+            File[] children = file.listFiles();
+            // only possible if exception occurs, or abstract path was not valid
+            if (children == null) {
+                return;
+            }
+            for (File child : children) {
+                rollbackTimetamps(child, seconds);
+            }
+        }
+    }
+
+}

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/ImmutableTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/ImmutableTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/ImmutableTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/ImmutableTest.java Fri Apr 18 21:00:38 2014
@@ -18,61 +18,73 @@
 
 package org.apache.tools.ant;
 
-import org.apache.tools.ant.BuildFileTest;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertEquals;
 
 /**
  */
-public class ImmutableTest extends BuildFileTest {
+public class ImmutableTest {
 
-    public ImmutableTest(String name) {
-        super(name);
-    }
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/core/immutable.xml");
+        buildRule.configureProject("src/etc/testcases/core/immutable.xml");
     }
 
     // override allowed on <available>
+    @Test
     public void test1() {
-        executeTarget("test1");
-        assertEquals("override", project.getProperty("test"));
+        buildRule.executeTarget("test1");
+        assertEquals("override",buildRule.getProject().getProperty("test"));
     }
 
     // ensure <tstamp>'s new prefix attribute is working
+    @Test
     public void test2() {
-        executeTarget("test2");
-        assertNotNull(project.getProperty("DSTAMP"));
-        assertNotNull(project.getProperty("start.DSTAMP"));
+        buildRule.executeTarget("test2");
+        assertNotNull(buildRule.getProject().getProperty("DSTAMP"));
+        assertNotNull(buildRule.getProject().getProperty("start.DSTAMP"));
     }
 
     // ensure <tstamp> follows the immutability rule
+    @Test
     public void test3() {
-        executeTarget("test3");
-        assertEquals("original", project.getProperty("DSTAMP"));
+        buildRule.executeTarget("test3");
+        assertEquals("original", buildRule.getProject().getProperty("DSTAMP"));
     }
 
     // ensure <condition> follows the immutability rule
+    @Test
     public void test4() {
-        executeTarget("test4");
-        assertEquals("original", project.getProperty("test"));
+        buildRule.executeTarget("test4");
+        assertEquals("original", buildRule.getProject().getProperty("test"));
     }
     // ensure <checksum> follows the immutability rule
+    @Test
     public void test5() {
-        executeTarget("test5");
-        assertEquals("original", project.getProperty("test"));
+        buildRule.executeTarget("test5");
+        assertEquals("original", buildRule.getProject().getProperty("test"));
     }
 
     // ensure <exec> follows the immutability rule
+    @Test
     public void test6() {
-        executeTarget("test6");
-        assertEquals("original", project.getProperty("test1"));
-        assertEquals("original", project.getProperty("test2"));
+        buildRule.executeTarget("test6");
+        assertEquals("original", buildRule.getProject().getProperty("test1"));
+        assertEquals("original", buildRule.getProject().getProperty("test2"));
     }
 
     // ensure <pathconvert> follows the immutability rule
+    @Test
     public void test7() {
-        executeTarget("test7");
-        assertEquals("original", project.getProperty("test"));
+        buildRule.executeTarget("test7");
+        assertEquals("original", buildRule.getProject().getProperty("test"));
     }
 }
 

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/IncludeTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/IncludeTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/IncludeTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/IncludeTest.java Fri Apr 18 21:00:38 2014
@@ -18,60 +18,75 @@
 
 package org.apache.tools.ant;
 
-import junit.framework.AssertionFailedError;
+import static org.apache.tools.ant.AntAssert.assertContains;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
-import org.apache.tools.ant.BuildFileTest;
+import org.junit.Rule;
+import org.junit.Test;
 
 /**
  * Test the build file inclusion using XML entities.
  *
  */
-public class IncludeTest extends BuildFileTest {
-
-    public IncludeTest(String name) {
-        super(name);
-    }
+public class IncludeTest {
+	
+	@Rule
+	public BuildFileRule buildRule = new BuildFileRule();
 
+    @Test
     public void test1() {
-        configureProject("src/etc/testcases/core/include/basic/include.xml");
-        expectLog("test1", "from included entity");
+        buildRule.configureProject("src/etc/testcases/core/include/basic/include.xml");
+        buildRule.executeTarget("test1");
+        assertEquals("from included entity", buildRule.getLog());
     }
 
+    @Test
     public void test2() {
-        configureProject("src/etc/testcases/core/include/frag#ment/include.xml");
-        expectLog("test1", "from included entity");
+        buildRule.configureProject("src/etc/testcases/core/include/frag#ment/include.xml");
+        buildRule.executeTarget("test1");
+        assertEquals("from included entity", buildRule.getLog());
     }
 
+    @Test
     public void test3() {
-        configureProject("src/etc/testcases/core/include/frag#ment/simple.xml");
-        expectLog("test1", "from simple buildfile");
+        buildRule.configureProject("src/etc/testcases/core/include/frag#ment/simple.xml");
+        buildRule.executeTarget("test1");
+        assertEquals("from simple buildfile", buildRule.getLog());
     }
 
+    @Test
     public void test4() {
-        configureProject("src/etc/testcases/core/include/basic/relative.xml");
-        expectLog("test1", "from included entity");
+        buildRule.configureProject("src/etc/testcases/core/include/basic/relative.xml");
+        buildRule.executeTarget("test1");
+        assertEquals("from included entity", buildRule.getLog());
     }
 
+    @Test
     public void test5() {
-        configureProject("src/etc/testcases/core/include/frag#ment/relative.xml");
-        expectLog("test1", "from included entity");
+        buildRule.configureProject("src/etc/testcases/core/include/frag#ment/relative.xml");
+        buildRule.executeTarget("test1");
+        assertEquals("from included entity", buildRule.getLog());
     }
 
+    @Test
     public void testParseErrorInIncluding() {
         try {
-            configureProject("src/etc/testcases/core/include/including_file_parse_error/build.xml");
+            buildRule.configureProject("src/etc/testcases/core/include/including_file_parse_error/build.xml");
             fail("should have caused a parser exception");
         } catch (BuildException e) {
-            assertTrue(e.getLocation().toString()
+            assertContains(e.getLocation().toString()
                        + " should refer to build.xml",
-                       e.getLocation().toString().indexOf("build.xml:") > -1);
+                       "build.xml:", e.getLocation().toString());
         }
     }
 
+    @Test
     public void testTaskErrorInIncluding() {
-        configureProject("src/etc/testcases/core/include/including_file_task_error/build.xml");
+        buildRule.configureProject("src/etc/testcases/core/include/including_file_task_error/build.xml");
         try {
-            executeTarget("test");
+            buildRule.executeTarget("test");
             fail("should have cause a build failure");
         } catch (BuildException e) {
             assertTrue(e.getMessage()
@@ -83,22 +98,24 @@ public class IncludeTest extends BuildFi
         }
     }
 
+    @Test
     public void testParseErrorInIncluded() {
         try {
-            configureProject("src/etc/testcases/core/include/included_file_parse_error/build.xml");
+            buildRule.configureProject("src/etc/testcases/core/include/included_file_parse_error/build.xml");
             fail("should have caused a parser exception");
         } catch (BuildException e) {
-            assertTrue(e.getLocation().toString()
+            assertContains(e.getLocation().toString()
                        + " should refer to included_file.xml",
-                       e.getLocation().toString()
-                       .indexOf("included_file.xml:") > -1);
+                       "included_file.xml:",
+                       e.getLocation().toString());
         }
     }
 
+    @Test
     public void testTaskErrorInIncluded() {
-        configureProject("src/etc/testcases/core/include/included_file_task_error/build.xml");
+        buildRule.configureProject("src/etc/testcases/core/include/included_file_task_error/build.xml");
         try {
-            executeTarget("test");
+            buildRule.executeTarget("test");
             fail("should have cause a build failure");
         } catch (BuildException e) {
             assertTrue(e.getMessage()
@@ -110,24 +127,25 @@ public class IncludeTest extends BuildFi
         }
     }
 
+    @Test
     public void testWithSpaceInclude() {
-        configureProject("src/etc/testcases/core/include/with space/include.xml");
-        try {
-            expectLog("test1", "from included entity in 'with space'");
-        } catch (Throwable t) {
-            throw new AssertionFailedError(
-                t.toString() + "; log=\n" + getFullLog());
-        }
+        buildRule.configureProject("src/etc/testcases/core/include/with space/include.xml");
+        buildRule.executeTarget("test1");
+        assertEquals("from included entity in 'with space'", buildRule.getLog());
     }
 
+    @Test
     public void testWithSpaceSimple() {
-        configureProject("src/etc/testcases/core/include/with space/simple.xml");
-        expectLog("test1", "from simple buildfile in 'with space'");
+        buildRule.configureProject("src/etc/testcases/core/include/with space/simple.xml");
+        buildRule.executeTarget("test1");
+        assertEquals("from simple buildfile in 'with space'", buildRule.getLog());
     }
 
+    @Test
     public void testWithSpaceRelative() {
-        configureProject("src/etc/testcases/core/include/with space/relative.xml");
-        expectLog("test1", "from included entity in 'with space'");
+        buildRule.configureProject("src/etc/testcases/core/include/with space/relative.xml");
+        buildRule.executeTarget("test1");
+        assertEquals("from included entity in 'with space'", buildRule.getLog());
     }
 
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java Fri Apr 18 21:00:38 2014
@@ -18,8 +18,6 @@
 
 package org.apache.tools.ant;
 
-import junit.framework.TestCase;
-import junit.framework.AssertionFailedError;
 import java.io.File;
 import java.lang.reflect.Method;
 import java.lang.reflect.InvocationTargetException;
@@ -31,43 +29,53 @@ import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import org.apache.tools.ant.taskdefs.condition.Os;
+import org.junit.Before;
+import org.junit.ComparisonFailure;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 /**
- * JUnit 3 testcases for org.apache.tools.ant.IntrospectionHelper.
+ * JUnit testcases for org.apache.tools.ant.IntrospectionHelper.
  *
  */
 
-public class IntrospectionHelperTest extends TestCase {
+public class IntrospectionHelperTest {
 
     private Project p;
     private IntrospectionHelper ih;
     private static final String projectBasedir = File.separator;
 
-    public IntrospectionHelperTest(String name) {
-        super(name);
-    }
-
+    @Before
     public void setUp() {
         p = new Project();
         p.setBasedir(projectBasedir);
         ih = IntrospectionHelper.getHelper(getClass());
     }
 
+    @Test
     public void testIsDynamic() {
-        assertTrue("Not dynamic", false == ih.isDynamic());
+        assertFalse("Not dynamic", ih.isDynamic());
     }
 
+    @Test
     public void testIsContainer() {
-        assertTrue("Not a container", false == ih.isContainer());
+        assertFalse("Not a container", ih.isContainer());
     }
 
+    @Test
     public void testAddText() throws BuildException {
         ih.addText(p, this, "test");
         try {
             ih.addText(p, this, "test2");
             fail("test2 shouldn\'t be equal to test");
         } catch (BuildException be) {
-            assertTrue(be.getCause() instanceof AssertionFailedError);
+            assertTrue(be.getCause() instanceof ComparisonFailure);
         }
 
         ih = IntrospectionHelper.getHelper(String.class);
@@ -75,9 +83,12 @@ public class IntrospectionHelperTest ext
             ih.addText(p, "", "test");
             fail("String doesn\'t support addText");
         } catch (BuildException be) {
+            //TODO the value should be asserted
         }
     }
 
+    @Test
+    @Ignore("This silently ignores a build exception")
     public void testGetAddTextMethod() {
         Method m = ih.getAddTextMethod();
         assertMethod(m, "addText", String.class, "test", "bing!");
@@ -88,6 +99,7 @@ public class IntrospectionHelperTest ext
         } catch (BuildException e) {}
     }
 
+    @Test
     public void testSupportsCharacters() {
         assertTrue("IntrospectionHelperTest supports addText",
                    ih.supportsCharacters());
@@ -100,31 +112,37 @@ public class IntrospectionHelperTest ext
         assertEquals("test", text);
     }
 
+    @Test
     public void testElementCreators() throws BuildException {
         try {
             ih.getElementType("one");
             fail("don't have element type one");
         } catch (BuildException be) {
+            //TODO we should be asserting a value in here
         }
         try {
             ih.getElementType("two");
             fail("createTwo takes arguments");
         } catch (BuildException be) {
+            //TODO we should be asserting a value in here
         }
         try {
             ih.getElementType("three");
             fail("createThree returns void");
         } catch (BuildException be) {
+            //TODO we should be asserting a value in here
         }
         try {
             ih.getElementType("four");
             fail("createFour returns array");
         } catch (BuildException be) {
+            //TODO we should be asserting a value in here
         }
         try {
             ih.getElementType("five");
             fail("createFive returns primitive type");
         } catch (BuildException be) {
+            //TODO we should be asserting a value in here
         }
         assertEquals(String.class, ih.getElementType("six"));
         assertEquals("test", ih.createElement(p, this, "six"));
@@ -133,31 +151,37 @@ public class IntrospectionHelperTest ext
             ih.getElementType("seven");
             fail("addSeven takes two arguments");
         } catch (BuildException be) {
+            //TODO we should be asserting a value in here
         }
         try {
             ih.getElementType("eight");
             fail("addEight takes no arguments");
         } catch (BuildException be) {
+            //TODO we should be asserting a value in here
         }
         try {
             ih.getElementType("nine");
             fail("nine return non void");
         } catch (BuildException be) {
+            //TODO we should be asserting a value in here
         }
         try {
             ih.getElementType("ten");
             fail("addTen takes array argument");
         } catch (BuildException be) {
+            //TODO we should be asserting a value in here
         }
         try {
             ih.getElementType("eleven");
             fail("addEleven takes primitive argument");
         } catch (BuildException be) {
+            //TODO we should be asserting a value in here
         }
         try {
             ih.getElementType("twelve");
             fail("no primitive constructor for java.lang.Class");
         } catch (BuildException be) {
+            //TODO we should be asserting a value in here
         }
         assertEquals(StringBuffer.class, ih.getElementType("thirteen"));
         assertEquals("test", ih.createElement(p, this, "thirteen").toString());
@@ -186,6 +210,7 @@ public class IntrospectionHelperTest ext
         return elemMap;
     }
 
+    @Test
     public void testGetNestedElements() {
         Map elemMap = getExpectedNestedElements();
         Enumeration e = ih.getNestedElements();
@@ -200,6 +225,7 @@ public class IntrospectionHelperTest ext
         assertTrue("Found all", elemMap.isEmpty());
     }
 
+    @Test
     public void testGetNestedElementMap() {
         Map elemMap = getExpectedNestedElements();
         Map actualMap = ih.getNestedElementMap();
@@ -217,9 +243,11 @@ public class IntrospectionHelperTest ext
         // Check it's a read-only map.
         try {
             actualMap.clear();
+            //TODO we should be asserting a value somewhere in here
         } catch (UnsupportedOperationException e) {}
     }
 
+    @Test
     public void testGetElementMethod() {
         assertElemMethod("six", "createSix", String.class, null);
         assertElemMethod("thirteen", "addThirteen", null, StringBuffer.class);
@@ -286,85 +314,92 @@ public class IntrospectionHelperTest ext
         throw new NullPointerException();
     }
 
+    @Test
     public void testAttributeSetters() throws BuildException {
         try {
             ih.setAttribute(p, this, "one", "test");
             fail("setOne doesn't exist");
         } catch (BuildException be) {
+            //TODO we should be asserting a value in here
         }
         try {
             ih.setAttribute(p, this, "two", "test");
             fail("setTwo returns non void");
         } catch (BuildException be) {
+            //TODO we should be asserting a value in here
         }
         try {
             ih.setAttribute(p, this, "three", "test");
             fail("setThree takes no args");
         } catch (BuildException be) {
+            //TODO we should be asserting a value in here
         }
         try {
             ih.setAttribute(p, this, "four", "test");
             fail("setFour takes two args");
         } catch (BuildException be) {
+            //TODO we should be asserting a value in here
         }
         try {
             ih.setAttribute(p, this, "five", "test");
             fail("setFive takes array arg");
         } catch (BuildException be) {
+            //TODO we should be asserting a value in here
         }
         try {
             ih.setAttribute(p, this, "six", "test");
             fail("Project doesn't have a String constructor");
         } catch (BuildException be) {
+            //TODO we should be asserting a value in here
         }
         ih.setAttribute(p, this, "seven", "2");
         try {
             ih.setAttribute(p, this, "seven", "3");
             fail("2 shouldn't be equals to three");
         } catch (BuildException be) {
-            assertTrue(be.getCause() instanceof AssertionFailedError);
+            assertTrue(be.getCause() instanceof ComparisonFailure);
         }
         ih.setAttribute(p, this, "eight", "2");
         try {
             ih.setAttribute(p, this, "eight", "3");
             fail("2 shouldn't be equals to three - as int");
         } catch (BuildException be) {
-            assertTrue(be.getCause() instanceof AssertionFailedError);
+            assertTrue("Cause of error: " + be.toString(), be.getCause() instanceof AssertionError);
         }
         ih.setAttribute(p, this, "nine", "2");
         try {
             ih.setAttribute(p, this, "nine", "3");
             fail("2 shouldn't be equals to three - as Integer");
         } catch (BuildException be) {
-            assertTrue(be.getCause() instanceof AssertionFailedError);
+            assertTrue(be.getCause() instanceof AssertionError);
         }
         ih.setAttribute(p, this, "ten", "2");
         try {
             ih.setAttribute(p, this, "ten", "3");
             fail(projectBasedir+"2 shouldn't be equals to "+projectBasedir+"3");
         } catch (BuildException be) {
-            assertTrue(be.getCause() instanceof AssertionFailedError);
+            assertTrue(be.getCause() instanceof AssertionError);
         }
         ih.setAttribute(p, this, "eleven", "2");
         try {
             ih.setAttribute(p, this, "eleven", "on");
             fail("on shouldn't be false");
         } catch (BuildException be) {
-            assertTrue(be.getCause() instanceof AssertionFailedError);
+            assertTrue(be.getCause() instanceof AssertionError);
         }
         ih.setAttribute(p, this, "twelve", "2");
         try {
             ih.setAttribute(p, this, "twelve", "on");
             fail("on shouldn't be false");
         } catch (BuildException be) {
-            assertTrue(be.getCause() instanceof AssertionFailedError);
+            assertTrue(be.getCause() instanceof AssertionError);
         }
         ih.setAttribute(p, this, "thirteen", "org.apache.tools.ant.Project");
         try {
             ih.setAttribute(p, this, "thirteen", "org.apache.tools.ant.ProjectHelper");
             fail("org.apache.tools.ant.Project shouldn't be equal to org.apache.tools.ant.ProjectHelper");
         } catch (BuildException be) {
-            assertTrue(be.getCause() instanceof AssertionFailedError);
+            assertTrue(be.getCause() instanceof AssertionError);
         }
         try {
             ih.setAttribute(p, this, "thirteen", "org.apache.tools.ant.Project2");
@@ -377,42 +412,42 @@ public class IntrospectionHelperTest ext
             ih.setAttribute(p, this, "fourteen", "on");
             fail("2 shouldn't be equals to three - as StringBuffer");
         } catch (BuildException be) {
-            assertTrue(be.getCause() instanceof AssertionFailedError);
+            assertTrue(be.getCause() instanceof ComparisonFailure);
         }
         ih.setAttribute(p, this, "fifteen", "abcd");
         try {
             ih.setAttribute(p, this, "fifteen", "on");
             fail("o shouldn't be equal to a");
         } catch (BuildException be) {
-            assertTrue(be.getCause() instanceof AssertionFailedError);
+            assertTrue(be.getCause() instanceof AssertionError);
         }
         ih.setAttribute(p, this, "sixteen", "abcd");
         try {
             ih.setAttribute(p, this, "sixteen", "on");
             fail("o shouldn't be equal to a");
         } catch (BuildException be) {
-            assertTrue(be.getCause() instanceof AssertionFailedError);
+            assertTrue(be.getCause() instanceof AssertionError);
         }
         ih.setAttribute(p, this, "seventeen", "17");
         try {
             ih.setAttribute(p, this, "seventeen", "3");
             fail("17 shouldn't be equals to three");
         } catch (BuildException be) {
-            assertTrue(be.getCause() instanceof AssertionFailedError);
+            assertTrue(be.getCause() instanceof AssertionError);
         }
         ih.setAttribute(p, this, "eightteen", "18");
         try {
             ih.setAttribute(p, this, "eightteen", "3");
             fail("18 shouldn't be equals to three");
         } catch (BuildException be) {
-            assertTrue(be.getCause() instanceof AssertionFailedError);
+            assertTrue(be.getCause() instanceof AssertionError);
         }
         ih.setAttribute(p, this, "nineteen", "19");
         try {
             ih.setAttribute(p, this, "nineteen", "3");
             fail("19 shouldn't be equals to three");
         } catch (BuildException be) {
-            assertTrue(be.getCause() instanceof AssertionFailedError);
+            assertTrue(be.getCause() instanceof AssertionError);
         }
     }
 
@@ -444,6 +479,7 @@ public class IntrospectionHelperTest ext
         return attrMap;
     }
 
+    @Test
     public void testGetAttributes() {
         Map attrMap = getExpectedAttributes();
         Enumeration e = ih.getAttributes();
@@ -459,6 +495,7 @@ public class IntrospectionHelperTest ext
         assertTrue("Found all", attrMap.isEmpty());
     }
 
+    @Test
     public void testGetAttributeMap() {
         Map attrMap = getExpectedAttributes();
         Map actualMap = ih.getAttributeMap();
@@ -477,9 +514,11 @@ public class IntrospectionHelperTest ext
         // Check it's a read-only map.
         try {
             actualMap.clear();
+            //TODO we should be asserting a value somewhere in here
         } catch (UnsupportedOperationException e) {}
     }
 
+    @Test
     public void testGetAttributeMethod() {
         assertAttrMethod("seven", "setSeven", String.class,
                          "2", "3");
@@ -511,7 +550,9 @@ public class IntrospectionHelperTest ext
         try {
             assertAttrMethod("onehundred", null, null, null, null);
             fail("Should have raised a BuildException!");
-        } catch (BuildException e) {}
+        } catch (BuildException e) {
+            //TODO we should be asserting a value in here
+        }
     }
 
     private void assertAttrMethod(String attrName, String methodName,
@@ -593,6 +634,7 @@ public class IntrospectionHelperTest ext
         assertTrue("Expected 19, received " + d, diff > -1e-6 && diff < 1e-6);
     }
 
+    @Test
     public void testGetExtensionPoints() {
         List extensions = ih.getExtensionPoints();
         final int adders = 2;
@@ -645,7 +687,7 @@ public class IntrospectionHelperTest ext
             throw new BuildException(e);
         } catch (InvocationTargetException e) {
             Throwable t = e.getTargetException();
-            assertTrue(t instanceof junit.framework.AssertionFailedError);
+            assertTrue(t.toString(), t instanceof AssertionError);
         }
     }
 

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/LoaderRefTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/LoaderRefTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/LoaderRefTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/LoaderRefTest.java Fri Apr 18 21:00:38 2014
@@ -18,25 +18,35 @@
 
 package org.apache.tools.ant;
 
-import org.apache.tools.ant.BuildFileTest;
+import static org.apache.tools.ant.AntAssert.assertContains;
+import static org.junit.Assert.fail;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
 
 /**
  */
-public class LoaderRefTest extends BuildFileTest {
-
-    public LoaderRefTest(String name) {
-        super(name);
-    }
+public class LoaderRefTest {
 
+	@Rule
+	public BuildFileRule buildRule = new BuildFileRule();
+	
+	@Before
     public void setUp() {
-        configureProject("src/etc/testcases/core/loaderref/loaderref.xml");
-        executeTarget("setUp");
+        buildRule.configureProject("src/etc/testcases/core/loaderref/loaderref.xml");
+        buildRule.executeTarget("setUp");
     }
 
     // override allowed on <available>
-    public void testBadRef() {
-        expectBuildExceptionContaining("testbadref", "Should fail due to ref "
-            + "not being a class loader", "does not reference a class loader");
+    @Test
+	public void testBadRef() {
+    	try {
+    		buildRule.executeTarget("testbadref");
+    		fail("BuildRule should have thrown an exception due to a bad classloader being specified");
+    	} catch (BuildException ex) {
+    		assertContains("Should fail due to ref not being a class loader", "does not reference a class loader", ex.getMessage());
+    	}
     }
 }
 

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/LocationTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/LocationTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/LocationTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/LocationTest.java Fri Apr 18 21:00:38 2014
@@ -21,49 +21,65 @@ package org.apache.tools.ant;
 import org.apache.tools.ant.taskdefs.ConditionTask;
 import org.apache.tools.ant.taskdefs.Echo;
 import org.apache.tools.ant.types.FileSet;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
 
-public class LocationTest extends BuildFileTest {
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
+public class LocationTest {
+
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
+
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/core/location.xml");
+        buildRule.configureProject("src/etc/testcases/core/location.xml");
     }
 
+    @Test
     public void testPlainTask() {
-        executeTarget("testPlainTask");
-        Echo e = (Echo) getProject().getReference("echo");
+        buildRule.executeTarget("testPlainTask");
+        Echo e = (Echo) buildRule.getProject().getReference("echo");
         assertFalse(e.getLocation() == Location.UNKNOWN_LOCATION);
         assertFalse(e.getLocation().getLineNumber() == 0);
     }
 
+    @Test
     public void testStandaloneType() {
-        executeTarget("testStandaloneType");
-        Echo e = (Echo) getProject().getReference("echo2");
-        FileSet f = (FileSet) getProject().getReference("fs");
+        buildRule.executeTarget("testStandaloneType");
+        Echo e = (Echo) buildRule.getProject().getReference("echo2");
+        FileSet f = (FileSet) buildRule.getProject().getReference("fs");
         assertFalse(f.getLocation() == Location.UNKNOWN_LOCATION);
         assertEquals(e.getLocation().getLineNumber() + 1,
                      f.getLocation().getLineNumber());
     }
 
+    @Test
     public void testConditionTask() {
-        executeTarget("testConditionTask");
-        TaskAdapter ta = (TaskAdapter) getProject().getReference("cond");
+        buildRule.executeTarget("testConditionTask");
+        TaskAdapter ta = (TaskAdapter) buildRule.getProject().getReference("cond");
         ConditionTask c = (ConditionTask) ta.getProxy();
         assertFalse(c.getLocation() == Location.UNKNOWN_LOCATION);
         assertFalse(c.getLocation().getLineNumber() == 0);
     }
 
+    @Test
     public void testMacrodefWrappedTask() {
-        executeTarget("testMacrodefWrappedTask");
-        Echo e = (Echo) getProject().getReference("echo3");
-        assertTrue(getLog().indexOf("Line: " 
+        buildRule.executeTarget("testMacrodefWrappedTask");
+        Echo e = (Echo) buildRule.getProject().getReference("echo3");
+        assertTrue(buildRule.getLog().indexOf("Line: "
                                     + (e.getLocation().getLineNumber() + 1))
                    > -1);
     }
 
+    @Test
     public void testPresetdefWrappedTask() {
-        executeTarget("testPresetdefWrappedTask");
-        Echo e = (Echo) getProject().getReference("echo4");
-        assertTrue(getLog().indexOf("Line: " 
+        buildRule.executeTarget("testPresetdefWrappedTask");
+        Echo e = (Echo) buildRule.getProject().getReference("echo4");
+        assertTrue(buildRule.getLog().indexOf("Line: "
                                     + (e.getLocation().getLineNumber() + 1))
                    > -1);
     }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/MockBuildListener.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/MockBuildListener.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/MockBuildListener.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/MockBuildListener.java Fri Apr 18 21:00:38 2014
@@ -18,13 +18,14 @@
 
 package org.apache.tools.ant;
 
-import java.util.Vector;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
 
-import junit.framework.Assert;
+import java.util.Vector;
 
-public class MockBuildListener extends Assert implements BuildListener {
+public class MockBuildListener implements BuildListener {
 
-    private final Vector buffer = new Vector();
+    private final Vector<BuildEvent> buffer = new Vector<BuildEvent>();
     private final Project project;
 
     public MockBuildListener(final Project project) {

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/ProjectComponentTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/ProjectComponentTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/ProjectComponentTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/ProjectComponentTest.java Fri Apr 18 21:00:38 2014
@@ -18,14 +18,14 @@
 
 package org.apache.tools.ant;
 
-import junit.framework.TestCase;
+import org.junit.Test;
 
-public class ProjectComponentTest extends TestCase {
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertSame;
 
-    public ProjectComponentTest(String name) {
-        super(name);
-    }
+public class ProjectComponentTest {
 
+    @Test
     public void testClone() throws CloneNotSupportedException {
         Project expectedProject = new Project();
         Location expectedLocation = new Location("foo");

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/ProjectHelperRepositoryTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/ProjectHelperRepositoryTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/ProjectHelperRepositoryTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/ProjectHelperRepositoryTest.java Fri Apr 18 21:00:38 2014
@@ -19,17 +19,19 @@ package org.apache.tools.ant;
 
 import java.io.File;
 
-import junit.framework.TestCase;
-
 import org.apache.tools.ant.helper.ProjectHelper2;
 import org.apache.tools.ant.types.Resource;
 import org.apache.tools.ant.types.resources.FileResource;
 import org.apache.tools.ant.types.resources.StringResource;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 /**
  * Testing around the management of the project helpers
  */
-public class ProjectHelperRepositoryTest extends TestCase {
+public class ProjectHelperRepositoryTest {
 
     public static class SomeHelper extends ProjectHelper {
         public boolean canParseBuildFile(Resource buildFile) {
@@ -42,6 +44,7 @@ public class ProjectHelperRepositoryTest
         }
     }
 
+    @Test
     public void testFind() throws Exception {
         ProjectHelperRepository repo = ProjectHelperRepository.getInstance();
         repo.registerProjectHelper(SomeHelper.class);
@@ -71,7 +74,9 @@ public class ProjectHelperRepositoryTest
         assertTrue(helper instanceof ProjectHelper2);
     }
 
-    public void testNoDefaultConstructor() throws Exception {
+    @Test
+    public void testNoDefaultContructor() throws Exception {
+
         class IncrrectHelper extends ProjectHelper {
             // the default constructor is not visible to ant here 
         }
@@ -82,9 +87,11 @@ public class ProjectHelperRepositoryTest
             fail("Registring an helper with no default constructor should fail");
         } catch (BuildException e) {
             // ok
+            //TODO we should be asserting a value in here
         }
     }
 
+    @Test
     public void testUnkwnowHelper() throws Exception {
         ProjectHelperRepository repo = ProjectHelperRepository.getInstance();
         try {
@@ -92,6 +99,7 @@ public class ProjectHelperRepositoryTest
             fail("Registring an unknwon helper should fail");
         } catch (BuildException e) {
             // ok
+            //TODO we should be asserting a value in here
         }
     }
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/ProjectTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/ProjectTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/ProjectTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/ProjectTest.java Fri Apr 18 21:00:38 2014
@@ -22,26 +22,39 @@ import org.apache.tools.ant.input.Defaul
 import org.apache.tools.ant.input.InputHandler;
 import org.apache.tools.ant.input.PropertyFileInputHandler;
 import org.apache.tools.ant.taskdefs.condition.Os;
-import org.apache.tools.ant.types.*;
 
 import java.io.File;
-import junit.framework.TestCase;
+
+import org.apache.tools.ant.types.FileSet;
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.PatternSet;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.apache.tools.ant.AntAssert.assertContains;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 
 /**
  * Very limited test class for Project. Waiting to be extended.
  *
  */
-public class ProjectTest extends TestCase {
+public class ProjectTest {
+
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
     private Project p;
     private String root;
     private MockBuildListener mbl;
 
-    public ProjectTest(String name) {
-        super(name);
-    }
-
+    @Before
     public void setUp() {
         p = new Project();
         p.init();
@@ -49,6 +62,7 @@ public class ProjectTest extends TestCas
         mbl = new MockBuildListener(p);
     }
 
+    @Test
     public void testDataTypes() throws BuildException {
         assertNull("dummy is not a known data type",
                    p.createDataType("dummy"));
@@ -63,6 +77,7 @@ public class ProjectTest extends TestCas
     /**
      * This test has been a starting point for moving the code to FileUtils.
      */
+    @Test
     public void testResolveFile() {
         if (Os.isFamily("netware") || Os.isFamily("dos")) {
             assertEqualsIgnoreDriveCase(localize(File.separator),
@@ -178,6 +193,7 @@ public class ProjectTest extends TestCas
         }
     }
 
+    @Test
     public void testAddTaskDefinition() {
         p.addBuildListener(mbl);
 
@@ -209,6 +225,7 @@ public class ProjectTest extends TestCas
         assertEquals(DummyTaskWithNonVoidExecute.class, p.getTaskDefinitions().get("NonVoidExecute"));
     }
 
+    @Test
     public void testInputHandler() {
         InputHandler ih = p.getInputHandler();
         assertNotNull(ih);
@@ -218,33 +235,38 @@ public class ProjectTest extends TestCas
         assertSame(pfih, p.getInputHandler());
     }
 
+    @Test
     public void testTaskDefinitionContainsKey() {
         assertTrue(p.getTaskDefinitions().containsKey("echo"));
     }
 
+    @Test
     public void testTaskDefinitionContains() {
         assertTrue(p.getTaskDefinitions().contains(org.apache.tools.ant.taskdefs.Echo.class));
     }
 
+    @Test
     public void testDuplicateTargets() {
         // fail, because buildfile contains two targets with the same name
         try {
-            BFT bft = new BFT("", "core/duplicate-target.xml");
+            buildRule.configureProject("src/etc/testcases/core/duplicate-target.xml");
+            fail("Should throw BuildException about duplicate target");
         } catch (BuildException ex) {
             assertEquals("specific message",
                          "Duplicate target 'twice'",
                          ex.getMessage());
-            return;
         }
-        fail("Should throw BuildException about duplicate target");
     }
 
+    @Test
     public void testDuplicateTargetsImport() {
         // overriding target from imported buildfile is allowed
-        BFT bft = new BFT("", "core/duplicate-target2.xml");
-        bft.expectLog("once", "once from buildfile");
+        buildRule.configureProject("src/etc/testcases/core/duplicate-target2.xml");
+        buildRule.executeTarget("once");
+        assertContains("once from buildfile", buildRule.getLog());
     }
 
+    @Test
     public void testOutputDuringMessageLoggedIsSwallowed()
         throws InterruptedException {
         final String FOO = "foo", BAR = "bar";
@@ -277,8 +299,10 @@ public class ProjectTest extends TestCas
     }
 
     /**
-     * @see https://issues.apache.org/bugzilla/show_bug.cgi?id=47623
+     * @see <a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=47623">
+     *     https://issues.apache.org/bugzilla/show_bug.cgi?id=47623</a>
      */
+    @Test
     public void testNullThrowableMessageLog() {
         p.log(new Task() {}, null, new Throwable(), Project.MSG_ERR);
         // be content if no exception has been thrown
@@ -294,42 +318,10 @@ public class ProjectTest extends TestCas
         public void execute() {}
     }
 
-    private class BFT extends org.apache.tools.ant.BuildFileTest {
-        BFT(String name, String buildfile) {
-            super(name);
-            this.buildfile = buildfile;
-            setUp();
-        }
-
-        // avoid multiple configurations
-        boolean isConfigured = false;
-
-        // the buildfile to use
-        String buildfile = "";
-
-        public void setUp() {
-            if (!isConfigured) {
-                configureProject("src/etc/testcases/"+buildfile);
-                isConfigured = true;
-            }
-        }
-
-        public void tearDown() { }
-
-        // call a target
-        public void doTarget(String target) {
-            if (!isConfigured) setUp();
-            executeTarget(target);
-        }
 
-        public org.apache.tools.ant.Project getProject() {
-            return super.getProject();
-        }
-    }//class-BFT
-
-}
+    class DummyTaskPackage extends Task {
+        public DummyTaskPackage() {}
+        public void execute() {}
+    }
 
-class DummyTaskPackage extends Task {
-    public DummyTaskPackage() {}
-    public void execute() {}
-}
+}
\ No newline at end of file

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/PropertyExpansionTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/PropertyExpansionTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/PropertyExpansionTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/PropertyExpansionTest.java Fri Apr 18 21:00:38 2014
@@ -19,33 +19,39 @@
 
 package org.apache.tools.ant;
 
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
 /**
  * class to look at how we expand properties
  */
-public class PropertyExpansionTest extends BuildFileTest {
-
-
-    public PropertyExpansionTest(String name) {
-        super(name);
-    }
+public class PropertyExpansionTest {
 
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
     /**
      * we bind to an existing test file because we are too lazy to write our
      * own, and we don't really care what it is
      */
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/core/immutable.xml");
+        buildRule.configureProject("src/etc/testcases/core/immutable.xml");
     }
 
     /**
      * run through the test cases of expansion
      */
+    @Test
     public void testPropertyExpansion() {
         assertExpandsTo("","");
         assertExpandsTo("$","$");
         assertExpandsTo("$$-","$-");
         assertExpandsTo("$$","$");
-        project.setProperty("expanded","EXPANDED");
+        buildRule.getProject().setProperty("expanded","EXPANDED");
         assertExpandsTo("a${expanded}b","aEXPANDEDb");
         assertExpandsTo("${expanded}${expanded}","EXPANDEDEXPANDED");
         assertExpandsTo("$$$","$$");
@@ -57,6 +63,7 @@ public class PropertyExpansionTest exten
     /**
      * new things we want
      */
+    @Test
     public void testDollarPassthru() {
         assertExpandsTo("$-","$-");
         assertExpandsTo("Class$subclass","Class$subclass");
@@ -71,6 +78,8 @@ public class PropertyExpansionTest exten
     /**
      * old things we dont want; not a test no more
      */
+    @Test
+    @Ignore("Previously disabled through naming convention")
     public void oldtestQuirkyLegacyBehavior() {
         assertExpandsTo("Class$subclass","Classsubclass");
         assertExpandsTo("$$$-","$-");
@@ -82,7 +91,7 @@ public class PropertyExpansionTest exten
      * little helper method to validate stuff
      */
     private void assertExpandsTo(String source,String expected) {
-        String actual=project.replaceProperties(source);
+        String actual = buildRule.getProject().replaceProperties(source);
         assertEquals(source,expected,actual);
     }
 

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/PropertyFileCLITest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/PropertyFileCLITest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/PropertyFileCLITest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/PropertyFileCLITest.java Fri Apr 18 21:00:38 2014
@@ -21,11 +21,14 @@ package org.apache.tools.ant;
 import java.io.File;
 import java.io.FileReader;
 import java.io.FileWriter;
-import junit.framework.TestCase;
 import org.apache.tools.ant.util.FileUtils;
+import org.junit.Test;
 
-public class PropertyFileCLITest extends TestCase {
+import static org.apache.tools.ant.AntAssert.assertContains;
 
+public class PropertyFileCLITest {
+
+    @Test
     public void testPropertyResolution() throws Exception {
         FileUtils fu = FileUtils.getFileUtils();
         File props = fu.createTempFile("propertyfilecli", ".properties",
@@ -51,8 +54,7 @@ public class PropertyFileCLITest extends
                     "-l", log.getAbsolutePath()
                 }, null, null);
             String l = FileUtils.safeReadFully(fr = new FileReader(log));
-            assertTrue("expected log to contain 'Hello, world' but was " + l,
-                       l.indexOf("Hello, world") > -1);
+            assertContains("Hello, world", l);
         } finally {
             FileUtils.close(fw);
             FileUtils.close(fr);

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/TaskContainerTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/TaskContainerTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/TaskContainerTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/TaskContainerTest.java Fri Apr 18 21:00:38 2014
@@ -18,40 +18,49 @@
 
 package org.apache.tools.ant;
 
-public class TaskContainerTest extends BuildFileTest {
-
-    public TaskContainerTest(String name) {
-        super(name);
-    }
-
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+public class TaskContainerTest {
+
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
+    
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/core/taskcontainer.xml");
+        buildRule.configureProject("src/etc/testcases/core/taskcontainer.xml");
     }
 
+    @Test
     public void testPropertyExpansion() {
-        executeTarget("testPropertyExpansion");
+        buildRule.executeTarget("testPropertyExpansion");
         assertTrue("attribute worked",
-                   getLog().indexOf("As attribute: it worked") > -1);
+                   buildRule.getLog().indexOf("As attribute: it worked") > -1);
         assertTrue("nested text worked",
-                   getLog().indexOf("As nested text: it worked") > -1);
+                   buildRule.getLog().indexOf("As nested text: it worked") > -1);
     }
 
+    @Test
     public void testTaskdef() {
-        executeTarget("testTaskdef");
+        buildRule.executeTarget("testTaskdef");
         assertTrue("attribute worked",
-                   getLog().indexOf("As attribute: it worked") > -1);
+                   buildRule.getLog().indexOf("As attribute: it worked") > -1);
         assertTrue("nested text worked",
-                   getLog().indexOf("As nested text: it worked") > -1);
+                   buildRule.getLog().indexOf("As nested text: it worked") > -1);
         assertTrue("nested text worked",
-                   getLog().indexOf("As nested task: it worked") > -1);
+                   buildRule.getLog().indexOf("As nested task: it worked") > -1);
     }
 
+    @Test
     public void testCaseInsensitive() {
-        executeTarget("testCaseInsensitive");
+        buildRule.executeTarget("testCaseInsensitive");
         assertTrue("works outside of container",
-                   getLog().indexOf("hello ") > -1);
+                   buildRule.getLog().indexOf("hello ") > -1);
         assertTrue("works inside of container",
-                   getLog().indexOf("world") > -1);
+                   buildRule.getLog().indexOf("world") > -1);
     }
 
 }