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 [8/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/taskdefs/SQLExecTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/SQLExecTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/SQLExecTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/SQLExecTest.java Fri Apr 18 21:00:38 2014
@@ -26,10 +26,17 @@ import java.io.File;
 import java.net.URL;
 import java.util.logging.Logger;
 
-import junit.framework.TestCase;
-
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.BuildException;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import static org.apache.tools.ant.AntAssert.assertContains;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 /**
  * Simple testcase to test for driver caching.
@@ -40,7 +47,7 @@ import org.apache.tools.ant.BuildExcepti
  * as the test db, so that a db is really used.
  *
  */
-public class SQLExecTest extends TestCase {
+public class SQLExecTest {
 
     // some database keys, see #getProperties(int)
     public final static int NULL = 0;
@@ -55,23 +62,22 @@ public class SQLExecTest extends TestCas
     public final static String PATH = "path";
     public final static String SQL = "sql";
 
-    public SQLExecTest(String s) {
-        super(s);
-    }
-
-    protected void setUp() throws Exception {
+    @Before
+    public void setUp() throws Exception {
         // make sure the cache is cleared.
         JDBCTask.getLoaderMap().clear();
     }
 
    // simple test to ensure that the caching does work...
+    @Test
     public void testDriverCaching(){
         SQLExec sql = createTask(getProperties(NULL));
         assertTrue(!SQLExec.getLoaderMap().containsKey(NULL_DRIVER));
         try {
             sql.execute();
+            fail("BuildException should have been thrown");
         } catch (BuildException e){
-            assertTrue(e.getCause().getMessage().indexOf("No suitable Driver") != -1);
+            assertContains("No suitable Driver", e.getMessage());
         }
         assertTrue(SQLExec.getLoaderMap().containsKey(NULL_DRIVER));
         assertSame(sql.getLoader(), JDBCTask.getLoaderMap().get(NULL_DRIVER));
@@ -91,19 +97,22 @@ public class SQLExecTest extends TestCas
         assertSame(loader1, sql.getLoader());
     }
 
+    @Test
     public void testNull() throws Exception {
         doMultipleCalls(1000, NULL, true, true);
     }
 
-    /*
+    @Ignore
+    @Test
     public void testOracle(){
         doMultipleCalls(1000, ORACLE, true, false);
-    }*/
+    }
 
-    /*
+    @Ignore
+    @Test
     public void testMySQL(){
         doMultipleCalls(1000, MYSQL, true, false);
-    }*/
+    }
 
 
     /**
@@ -239,6 +248,7 @@ public class SQLExecTest extends TestCas
         }
     }
 
+    @Test
     public void testLastDelimiterPositionNormalModeStrict() {
         SQLExec s = new SQLExec();
         assertEquals(-1,
@@ -258,6 +268,7 @@ public class SQLExecTest extends TestCas
                      s.lastDelimiterPosition(new StringBuffer("GO"), null));
     }
 
+    @Test
     public void testLastDelimiterPositionNormalModeNonStrict() {
         SQLExec s = new SQLExec();
         s.setStrictDelimiterMatching(false);
@@ -278,6 +289,7 @@ public class SQLExecTest extends TestCas
                      s.lastDelimiterPosition(new StringBuffer("GO"), null));
     }
 
+    @Test
     public void testLastDelimiterPositionRowModeStrict() {
         SQLExec s = new SQLExec();
         SQLExec.DelimiterType t = new SQLExec.DelimiterType();
@@ -293,6 +305,7 @@ public class SQLExecTest extends TestCas
         assertEquals(0, s.lastDelimiterPosition(new StringBuffer("ab"), "GO"));
     }
 
+    @Test
     public void testLastDelimiterPositionRowModeNonStrict() {
         SQLExec s = new SQLExec();
         SQLExec.DelimiterType t = new SQLExec.DelimiterType();

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java Fri Apr 18 21:00:38 2014
@@ -19,25 +19,32 @@
 package org.apache.tools.ant.taskdefs;
 
 import java.io.File;
-import org.apache.tools.ant.BuildFileTest;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
 import org.apache.tools.ant.util.JavaEnvUtils;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.Rule;
+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;
 
 /**
  * Testcase for the Signjar task
  *
  */
-public class SignJarTest extends BuildFileTest {
-
-    public static final String EXPANDED_MANIFEST
-        = "src/etc/testcases/taskdefs/manifests/META-INF/MANIFEST.MF";
+public class SignJarTest {
 
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
-    public SignJarTest(String name) {
-        super(name);
-    }
-
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/signjar.xml");
+        buildRule.configureProject("src/etc/testcases/taskdefs/signjar.xml");
     }
 
     /**
@@ -48,13 +55,14 @@ public class SignJarTest extends BuildFi
         return Boolean.getBoolean("offline");
     }
 
+    @Test
     public void testSigFile() {
-        executeTarget("sigfile");
+        buildRule.executeTarget("sigfile");
         SignJarChild sj = new SignJarChild();
         sj.setAlias("testonly");
         sj.setKeystore("testkeystore");
         sj.setStorepass("apacheant");
-        File jar = new File(getProject().getProperty("test.jar"));
+        File jar = new File(buildRule.getProject().getProperty("test.jar"));
         sj.setJar(jar);
         assertFalse("mustn't find signature without sigfile attribute",
                     sj.isSigned());
@@ -63,13 +71,14 @@ public class SignJarTest extends BuildFi
                    sj.isSigned());
     }
 
+    @Test
     public void testInvalidChars() {
-        executeTarget("invalidchars");
+        buildRule.executeTarget("invalidchars");
         SignJarChild sj = new SignJarChild();
         sj.setAlias("test@nly");
         sj.setKeystore("testkeystore");
         sj.setStorepass("apacheant");
-        File jar = new File(getProject().getProperty("test.jar"));
+        File jar = new File(buildRule.getProject().getProperty("test.jar"));
         sj.setJar(jar);
         assertTrue(sj.isSigned());
     }
@@ -84,31 +93,35 @@ public class SignJarTest extends BuildFi
         }
     }
 
+    @Test
     public void testURLKeystoreFile() {
-        executeTarget("urlKeystoreFile");
+       buildRule.executeTarget("urlKeystoreFile");
     }
 
+    @Test
     public void testURLKeystoreHTTP() {
-        if(!isOffline()) {
-            executeTarget("urlKeystoreHTTP");
-        }
+        Assume.assumeFalse("Test is set offline", isOffline());
+        buildRule.executeTarget("urlKeystoreHTTP");
     }
 
+    @Test
     public void testTsaLocalhost() {
-        //only test on java1.5+
-        if(JavaEnvUtils.getJavaVersionNumber()>=15) {
-            expectBuildException("testTsaLocalhost",
-                "no TSA at localhost:0");
-            assertLogContaining("java.net.ConnectException");
+        Assume.assumeTrue("Only runs on Java 1.5+", JavaEnvUtils.getJavaVersionNumber()>=15);
+        try {
+            buildRule.executeTarget("testTsaLocalhost");
+            fail("Should have thrown exception - no TSA at localhost:0");
+        } catch(BuildException ex) {
+            assertEquals("jarsigner returned: 1", ex.getMessage());
         }
     }
 
     /**
      * @see <a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=50081">bug 50081</a>
      */
+    @Test
     public void testSignUnnormalizedJar() throws Exception {
-        executeTarget("jar");
-        File testJar = new File(getProject().getProperty("test.jar"));
+        buildRule.executeTarget("jar");
+        File testJar = new File(buildRule.getProject().getProperty("test.jar"));
         File testJarParent = testJar.getParentFile();
         File f = new File(testJarParent,
                           "../" + testJarParent.getName() + "/"
@@ -116,7 +129,7 @@ public class SignJarTest extends BuildFi
         assertFalse(testJar.equals(f));
         assertEquals(testJar.getCanonicalPath(), f.getCanonicalPath());
         SignJar s = new SignJar();
-        s.setProject(getProject());
+        s.setProject(buildRule.getProject());
         s.setJar(f);
         s.setAlias("testonly");
         s.setStorepass("apacheant");

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/SleepTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/SleepTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/SleepTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/SleepTest.java Fri Apr 18 21:00:38 2014
@@ -18,67 +18,76 @@
 
 package org.apache.tools.ant.taskdefs;
 
-import org.apache.tools.ant.BuildFileTest;
-/**
- * @created 01 May 2001
- */
-public class SleepTest extends BuildFileTest {
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
 
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public class SleepTest {
+
+    @Rule
+    public final BuildFileRule buildRule = new BuildFileRule();
 
     private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/";
-    private final static boolean TRACE=false;
 	private final static int ERROR_RANGE=1000;
 	
-    public SleepTest(String name) {
-        super(name);
-    }
-
+    
+    @Before
     public void setUp() {
-        configureProject(TASKDEFS_DIR + "sleep.xml");
+        buildRule.configureProject(TASKDEFS_DIR + "sleep.xml");
     }
 
+    @Test
     public void test1() {
        Timer timer=new Timer();
-        executeTarget("test1");
+        buildRule.executeTarget("test1");
         timer.stop();
-        if(TRACE) System.out.println(" test1 elapsed time="+timer.time());
         assertTrue(timer.time()>=0);
     }
 
+    @Test
     public void test2() {
         Timer timer=new Timer();
-        executeTarget("test2");
+        buildRule.executeTarget("test2");
         timer.stop();
-        if(TRACE) System.out.println(" test2 elapsed time="+timer.time());
         assertTrue(timer.time()>=0);
     }
 
+    @Test
     public void test3() {
         Timer timer=new Timer();
-        executeTarget("test3");
+        buildRule.executeTarget("test3");
         timer.stop();
-        if(TRACE) System.out.println(" test3 elapsed time="+timer.time());
         assertTrue(timer.time()>=(2000-ERROR_RANGE));
     }
 
+    @Test
     public void test4() {
         Timer timer=new Timer();
-        executeTarget("test3");
+        buildRule.executeTarget("test3");
         timer.stop();
-        if(TRACE) System.out.println(" test4 elapsed time="+timer.time());
         assertTrue(timer.time()>=(2000-ERROR_RANGE) && timer.time()<60000);
     }
 
+    @Test
     public void test5() {
-        expectBuildException("test5",
-            "Negative sleep periods are not supported");
+        try {
+            buildRule.executeTarget("test5");
+            fail("Negative sleep periods are not supported");
+        } catch (BuildException ex) {
+            //TODO assert value
+        }
     }
 
+    @Test
     public void test6() {
         Timer timer=new Timer();
-        executeTarget("test6");
+        buildRule.executeTarget("test6");
         timer.stop();
-        if(TRACE) System.out.println(" test6 elapsed time="+timer.time());
         assertTrue(timer.time()<2000);
     }
 

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/StyleTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/StyleTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/StyleTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/StyleTest.java Fri Apr 18 21:00:38 2014
@@ -19,151 +19,177 @@ package org.apache.tools.ant.taskdefs;
 
 
 import java.io.File;
-import java.io.FileReader;
 import java.io.IOException;
-import java.io.Reader;
 
-import org.apache.tools.ant.BuildFileTest;
-import org.apache.tools.ant.util.FileUtils;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
+import org.apache.tools.ant.FileUtilities;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 
 /**
  * TestCases for {@link XSLTProcess} task.
- * TODO merge with {@link XsltTest}?
+ * TODO merge with {@link org.apache.tools.ant.taskdefs.optional.XsltTest}?
  * @version 2003-08-05
  */
-public class StyleTest extends BuildFileTest {
+public class StyleTest {
 
-    private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
+    @Rule
+    public final BuildFileRule buildRule = new BuildFileRule();
 
-    public StyleTest(String s) {
-        super(s);
-    }
-
-    protected void setUp() throws Exception {
-        configureProject("src/etc/testcases/taskdefs/style/build.xml");
-        //executeTarget("setup");
-        //commented out for performance while target is empty
+    @Before
+    public void setUp() throws Exception {
+        buildRule.configureProject("src/etc/testcases/taskdefs/style/build.xml");
     }
 
+    @Test
     public void testStyleIsSet() throws Exception {
-        expectSpecificBuildException("testStyleIsSet",
-                "no stylesheet specified", "specify the " +
-                "stylesheet either as a filename in style " +
-                "attribute or as a nested resource");
+
+        try {
+            buildRule.executeTarget("testStyleIsSet");
+            fail("Must throws a BuildException: no stylesheet specified");
+        } catch (BuildException ex) {
+            assertEquals("specify the stylesheet either as a filename in style attribute or as a nested resource",
+                    ex.getMessage());
+        }
     }
 
+    @Test
     public void testTransferParameterSet() throws Exception {
         expectFileContains("testTransferParameterSet",  // target
-                           getOutputDir().getAbsoluteFile() + "/out.xml",               // file
+                           buildRule.getOutputDir().getAbsoluteFile() + "/out.xml",               // file
                            "set='myvalue'");            // exptected string
     }
 
+    @Test
     public void testTransferParameterEmpty() throws Exception {
         expectFileContains("testTransferParameterEmpty",
-                           getOutputDir().getAbsoluteFile() + "/out.xml",
+                           buildRule.getOutputDir().getAbsoluteFile() + "/out.xml",
                            "empty=''");
     }
 
+    @Test
     public void testTransferParameterUnset() throws Exception {
         expectFileContains("testTransferParameterUnset",
-                           getOutputDir().getAbsoluteFile() + "/out.xml",
+                           buildRule.getOutputDir().getAbsoluteFile() + "/out.xml",
                            "undefined='${value}'");
     }
 
+    @Test
     public void testTransferParameterUnsetWithIf() throws Exception {
         expectFileContains("testTransferParameterUnsetWithIf",
-                           getOutputDir().getAbsoluteFile() + "/out.xml",
+                           buildRule.getOutputDir().getAbsoluteFile() + "/out.xml",
                            "undefined='undefined default value'");
     }
 
+    @Test
     public void testNewerStylesheet() throws Exception {
         expectFileContains("testNewerStylesheet",
-                           getOutputDir().getAbsoluteFile() + "/out.xml",
+                           buildRule.getOutputDir().getAbsoluteFile() + "/out.xml",
                            "new-value");
     }
 
+    @Test
     public void testDefaultMapper() throws Exception {
         testDefaultMapper("testDefaultMapper");
     }
 
+    @Test
     public void testExplicitFileset() throws Exception {
         testDefaultMapper("testExplicitFileset");
     }
 
     public void testDefaultMapper(String target) throws Exception {
         assertTrue(!(
-                new File(getOutputDir().getAbsoluteFile(), "data.html").exists()));
+                new File(buildRule.getOutputDir().getAbsoluteFile(), "data.html").exists()));
         expectFileContains(target,
-                           getOutputDir().getAbsoluteFile() + "/data.html",
+                           buildRule.getOutputDir().getAbsoluteFile() + "/data.html",
                            "set='myvalue'");
     }
 
+    @Test
     public void testCustomMapper() throws Exception {
-        assertTrue(!new File(getOutputDir().getAbsoluteFile(),  "out.xml").exists());
+        assertTrue(!new File(buildRule.getOutputDir().getAbsoluteFile(),  "out.xml").exists());
         expectFileContains("testCustomMapper",
-                           getOutputDir().getAbsoluteFile() + "/out.xml",
+                           buildRule.getOutputDir().getAbsoluteFile() + "/out.xml",
                            "set='myvalue'");
     }
 
+    @Test
     public void testTypedMapper() throws Exception {
-        assertTrue(!new File(getOutputDir().getAbsoluteFile(),  "out.xml").exists());
+        assertTrue(!new File(buildRule.getOutputDir().getAbsoluteFile(),  "out.xml").exists());
         expectFileContains("testTypedMapper",
-                           getOutputDir().getAbsoluteFile() + "/out.xml",
+                           buildRule.getOutputDir().getAbsoluteFile() + "/out.xml",
                            "set='myvalue'");
     }
 
+    @Test
     public void testDirectoryHierarchyWithDirMatching() throws Exception {
-        executeTarget("testDirectoryHierarchyWithDirMatching");
-        assertTrue(new File(getOutputDir().getAbsoluteFile(),  "dest/level1/data.html")
+        buildRule.executeTarget("testDirectoryHierarchyWithDirMatching");
+        assertTrue(new File(buildRule.getOutputDir().getAbsoluteFile(),  "dest/level1/data.html")
                    .exists());
     }
 
+    @Test
     public void testDirsWithSpaces() throws Exception {
-        executeTarget("testDirsWithSpaces");
-        assertTrue(new File(getOutputDir().getAbsoluteFile(),  "d est/data.html")
+        buildRule.executeTarget("testDirsWithSpaces");
+        assertTrue(new File(buildRule.getOutputDir().getAbsoluteFile(),  "d est/data.html")
                    .exists());
     }
 
-    public void testWithStyleAttrAndResource() throws Exception {
-        expectSpecificBuildException("testWithStyleAttrAndResource",
-                "Must throws a BuildException", "specify the " +
-                "stylesheet either as a filename in style " +
-                "attribute or as a nested resource but not " +
-                "as both");
+    @Test
+    public void testWithStyleAttrAndResource() {
+        try {
+            buildRule.executeTarget("testWithStyleAttrAndResource");
+            fail("Must throws a BuildException");
+        } catch (BuildException ex) {
+            assertEquals("specify the stylesheet either as a filename in style attribute or as a "
+                    + "nested resource but not as both", ex.getMessage());
+        }
     }
 
+    @Test
     public void testWithFileResource() throws Exception {
-        expectFileContains("testWithFileResource", getOutputDir().getAbsoluteFile() + "/out.xml", "set='value'");
+        expectFileContains("testWithFileResource", buildRule.getOutputDir().getAbsoluteFile() + "/out.xml", "set='value'");
     }
 
+    @Test
     public void testWithUrlResource() throws Exception {
-        expectFileContains("testWithUrlResource", getOutputDir().getAbsoluteFile() + "/out.xml", "set='value'");
+        expectFileContains("testWithUrlResource", buildRule.getOutputDir().getAbsoluteFile() + "/out.xml", "set='value'");
     }
 
+    @Test
     public void testFilenameAsParam() throws Exception {
-        executeTarget("testFilenameAsParam");
-        assertFileContains(getOutputDir().getAbsoluteFile() + "/one.txt",      "filename='one.xml'");
-        assertFileContains(getOutputDir().getAbsoluteFile() + "/two.txt",      "filename='two.xml'");
-        assertFileContains(getOutputDir().getAbsoluteFile() + "/three.txt",    "filename='three.xml'");
-        assertFileContains(getOutputDir().getAbsoluteFile() + "/dir/four.txt", "filename='four.xml'");
-        assertFileContains(getOutputDir().getAbsoluteFile() + "/dir/four.txt", "filedir ='-not-set-'");
+        buildRule.executeTarget("testFilenameAsParam");
+        assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/one.txt",      "filename='one.xml'");
+        assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/two.txt",      "filename='two.xml'");
+        assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/three.txt",    "filename='three.xml'");
+        assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/dir/four.txt", "filename='four.xml'");
+        assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/dir/four.txt", "filedir ='-not-set-'");
     }
 
+    @Test
     public void testFilenameAsParamNoSetting() throws Exception {
-        executeTarget("testFilenameAsParamNoSetting");
-        assertFileContains(getOutputDir().getAbsoluteFile() + "/one.txt",      "filename='-not-set-'");
-        assertFileContains(getOutputDir().getAbsoluteFile() + "/two.txt",      "filename='-not-set-'");
-        assertFileContains(getOutputDir().getAbsoluteFile() + "/three.txt",    "filename='-not-set-'");
-        assertFileContains(getOutputDir().getAbsoluteFile() + "/dir/four.txt", "filename='-not-set-'");
+        buildRule.executeTarget("testFilenameAsParamNoSetting");
+        assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/one.txt",      "filename='-not-set-'");
+        assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/two.txt",      "filename='-not-set-'");
+        assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/three.txt",    "filename='-not-set-'");
+        assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/dir/four.txt", "filename='-not-set-'");
     }
 
+    @Test
     public void testFilenameAndFiledirAsParam() throws Exception {
-        executeTarget("testFilenameAndFiledirAsParam");
-        assertFileContains(getOutputDir().getAbsoluteFile() + "/one.txt",      "filename='one.xml'");
-        assertFileContains(getOutputDir().getAbsoluteFile() + "/one.txt",      "filedir ='.'");
-        assertFileContains(getOutputDir().getAbsoluteFile() + "/dir/four.txt", "filename='four.xml'");
-        assertFileContains(getOutputDir().getAbsoluteFile() + "/dir/four.txt", "filedir ='dir'");
+        buildRule.executeTarget("testFilenameAndFiledirAsParam");
+        assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/one.txt",      "filename='one.xml'");
+        assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/one.txt",      "filedir ='.'");
+        assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/dir/four.txt", "filename='four.xml'");
+        assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/dir/four.txt", "filedir ='dir'");
     }
 
 
@@ -176,21 +202,14 @@ public class StyleTest extends BuildFile
     private String getFileString(String filename)
         throws IOException
     {
-        Reader r = null;
-        try {
-            r = new FileReader(getProject().resolveFile(filename));
-            return  FileUtils.readFully(r);
-        }
-        finally {
-            FileUtils.close(r);
-        }
+        return FileUtilities.getFileContents(new File(filename));
     }
 
     private void expectFileContains(
         String target, String filename, String contains)
         throws IOException
     {
-        executeTarget(target);
+        buildRule.executeTarget(target);
         assertFileContains(filename, contains);
     }
 

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/SubAntTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/SubAntTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/SubAntTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/SubAntTest.java Fri Apr 18 21:00:38 2014
@@ -23,30 +23,40 @@ import java.io.File;
 import junit.framework.AssertionFailedError;
 
 import org.apache.tools.ant.BuildEvent;
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
 import org.apache.tools.ant.BuildListener;
+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.fail;
 
-public class SubAntTest extends BuildFileTest {
 
-    public SubAntTest(String name) {
-        super(name);
-    }
+public class SubAntTest {
+
+    @Rule
+    public final BuildFileRule buildRule = new BuildFileRule();
 
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/subant.xml");
+        buildRule.configureProject("src/etc/testcases/taskdefs/subant.xml");
     }
 
+    @Test
     public void testnodirs() {
-        project.executeTarget("testnodirs");
-        expectLog("testnodirs", "No sub-builds to iterate on");
+        buildRule.executeTarget("testnodirs");
+        assertEquals("No sub-builds to iterate on",buildRule.getLog());
     }
 
     // target must be specified
+    @Test
     public void testgenericantfile() {
-        File dir1 = project.resolveFile(".");
-        File dir2 = project.resolveFile("subant/subant-test1");
-        File dir3 = project.resolveFile("subant/subant-test2");
+        File dir1 = buildRule.getProject().resolveFile(".");
+        File dir2 = buildRule.getProject().resolveFile("subant/subant-test1");
+        File dir3 = buildRule.getProject().resolveFile("subant/subant-test2");
 
         testBaseDirs("testgenericantfile",
                      new String[] { dir1.getAbsolutePath(),
@@ -56,14 +66,15 @@ public class SubAntTest extends BuildFil
                      });
     }
 
+    @Test
     public void testantfile() {
-        File dir1 = project.resolveFile(".");
+        File dir1 = buildRule.getProject().resolveFile(".");
         // basedir of subant/subant-test1/subant.xml is ..
         // therefore we expect here the subant/subant-test1 subdirectory
-        File dir2 = project.resolveFile("subant/subant-test1");
+        File dir2 = buildRule.getProject().resolveFile("subant/subant-test1");
         // basedir of subant/subant-test2/subant.xml is ..
         // therefore we expect here the subant subdirectory
-        File dir3 = project.resolveFile("subant");
+        File dir3 = buildRule.getProject().resolveFile("subant");
 
         testBaseDirs("testantfile",
                      new String[] { dir1.getAbsolutePath(),
@@ -74,34 +85,40 @@ public class SubAntTest extends BuildFil
 
     }
     
+    @Test
     public void testMultipleTargets() {
-        executeTarget("multipleTargets");
-        assertLogContaining("test1-one");
-        assertLogContaining("test1-two");
-        assertLogContaining("test2-one");
-        assertLogContaining("test2-two");
+        buildRule.executeTarget("multipleTargets");
+        assertContains("test1-one", buildRule.getLog());
+        assertContains("test1-two", buildRule.getLog());
+        assertContains("test2-one", buildRule.getLog());
+        assertContains("test2-two", buildRule.getLog());
     }
     
+    @Test
     public void testMultipleTargetsOneDoesntExist_FOEfalse() {
-        executeTarget("multipleTargetsOneDoesntExist_FOEfalse");
-        assertLogContaining("Target \"three\" does not exist in the project \"subant\"");
+        buildRule.executeTarget("multipleTargetsOneDoesntExist_FOEfalse");
+        assertContains("Target \"three\" does not exist in the project \"subant\"", buildRule.getLog());
     }
     
+    @Test
     public void testMultipleTargetsOneDoesntExist_FOEtrue() {
-        expectBuildExceptionContaining("multipleTargetsOneDoesntExist_FOEtrue", 
-                                       "Calling not existent target", 
-                                       "Target \"three\" does not exist in the project \"subant\"");
+        try {
+            buildRule.executeTarget("multipleTargetsOneDoesntExist_FOEtrue");
+            fail("BuildException expected: Calling not existent target");
+        } catch (BuildException ex) {
+            assertContains("Target \"three\" does not exist in the project \"subant\"", ex.getMessage());
+        }
     }
 
     protected void testBaseDirs(String target, String[] dirs) {
         SubAntTest.BasedirChecker bc = new SubAntTest.BasedirChecker(dirs);
-        project.addBuildListener(bc);
-        executeTarget(target);
+        buildRule.getProject().addBuildListener(bc);
+        buildRule.executeTarget(target);
         AssertionFailedError ae = bc.getError();
         if (ae != null) {
             throw ae;
         }
-        project.removeBuildListener(bc);
+        buildRule.getProject().removeBuildListener(bc);
     }
 
     private class BasedirChecker implements BuildListener {

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/SyncTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/SyncTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/SyncTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/SyncTest.java Fri Apr 18 21:00:38 2014
@@ -18,115 +18,131 @@
 
 package org.apache.tools.ant.taskdefs;
 
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.BuildFileRule;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
 
-public class SyncTest extends BuildFileTest {
+import static org.apache.tools.ant.AntAssert.assertContains;
+import static org.junit.Assert.assertTrue;
 
-    public SyncTest(String name) {
-        super(name);
-    }
+public class SyncTest {
+
+    @Rule
+    public final BuildFileRule buildRule = new BuildFileRule();
 
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/sync.xml");
+        buildRule.configureProject("src/etc/testcases/taskdefs/sync.xml");
     }
 
+    @Test
     public void testSimpleCopy() {
-        executeTarget("simplecopy");
-        String d = getProject().getProperty("dest") + "/a/b/c/d";
+        buildRule.executeTarget("simplecopy");
+        String d = buildRule.getProject().getProperty("dest") + "/a/b/c/d";
         assertFileIsPresent(d);
-        assertTrue(getFullLog().indexOf("dangling") == -1);
+        assertTrue(buildRule.getFullLog().indexOf("dangling") == -1);
     }
 
+    @Test
     public void testEmptyCopy() {
-        executeTarget("emptycopy");
-        String d = getProject().getProperty("dest") + "/a/b/c/d";
+        buildRule.executeTarget("emptycopy");
+        String d = buildRule.getProject().getProperty("dest") + "/a/b/c/d";
         assertFileIsNotPresent(d);
-        String c = getProject().getProperty("dest") + "/a/b/c";
+        String c = buildRule.getProject().getProperty("dest") + "/a/b/c";
         assertFileIsNotPresent(c);
-        assertTrue(getFullLog().indexOf("dangling") == -1);
+        assertTrue(buildRule.getFullLog().indexOf("dangling") == -1);
     }
 
+    @Test
     public void testEmptyDirCopy() {
-        executeTarget("emptydircopy");
-        String d = getProject().getProperty("dest") + "/a/b/c/d";
+        buildRule.executeTarget("emptydircopy");
+        String d = buildRule.getProject().getProperty("dest") + "/a/b/c/d";
         assertFileIsNotPresent(d);
-        String c = getProject().getProperty("dest") + "/a/b/c";
+        String c = buildRule.getProject().getProperty("dest") + "/a/b/c";
         assertFileIsPresent(c);
-        assertTrue(getFullLog().indexOf("dangling") == -1);
+        assertTrue(buildRule.getFullLog().indexOf("dangling") == -1);
     }
 
+    @Test
     public void testCopyAndRemove() {
         testCopyAndRemove("copyandremove");
     }
 
+    @Test
     public void testCopyAndRemoveWithFileList() {
         testCopyAndRemove("copyandremove-with-filelist");
     }
 
+    @Test
     public void testCopyAndRemoveWithZipfileset() {
         testCopyAndRemove("copyandremove-with-zipfileset");
     }
 
     private void testCopyAndRemove(String target) {
-        executeTarget(target);
-        String d = getProject().getProperty("dest") + "/a/b/c/d";
+        buildRule.executeTarget(target);
+        String d = buildRule.getProject().getProperty("dest") + "/a/b/c/d";
         assertFileIsPresent(d);
-        String f = getProject().getProperty("dest") + "/e/f";
+        String f = buildRule.getProject().getProperty("dest") + "/e/f";
         assertFileIsNotPresent(f);
-        assertTrue(getFullLog().indexOf("Removing orphan file:") > -1);
-        assertDebuglogContaining("Removed 1 dangling file from");
-        assertDebuglogContaining("Removed 1 dangling directory from");
+        assertTrue(buildRule.getFullLog().indexOf("Removing orphan file:") > -1);
+        assertContains("Removed 1 dangling file from", buildRule.getFullLog());
+        assertContains("Removed 1 dangling directory from", buildRule.getFullLog());
     }
 
+    @Test
     public void testCopyAndRemoveEmptyPreserve() {
-        executeTarget("copyandremove-emptypreserve");
-        String d = getProject().getProperty("dest") + "/a/b/c/d";
+        buildRule.executeTarget("copyandremove-emptypreserve");
+        String d = buildRule.getProject().getProperty("dest") + "/a/b/c/d";
         assertFileIsPresent(d);
-        String f = getProject().getProperty("dest") + "/e/f";
+        String f = buildRule.getProject().getProperty("dest") + "/e/f";
         assertFileIsNotPresent(f);
-        assertTrue(getFullLog().indexOf("Removing orphan file:") > -1);
-        assertDebuglogContaining("Removed 1 dangling file from");
-        assertDebuglogContaining("Removed 1 dangling directory from");
+        assertTrue(buildRule.getFullLog().indexOf("Removing orphan file:") > -1);
+        assertContains("Removed 1 dangling file from", buildRule.getFullLog());
+        assertContains("Removed 1 dangling directory from", buildRule.getFullLog());
     }
 
+    @Test
     public void testEmptyDirCopyAndRemove() {
-        executeTarget("emptydircopyandremove");
-        String d = getProject().getProperty("dest") + "/a/b/c/d";
+        buildRule.executeTarget("emptydircopyandremove");
+        String d = buildRule.getProject().getProperty("dest") + "/a/b/c/d";
         assertFileIsNotPresent(d);
-        String c = getProject().getProperty("dest") + "/a/b/c";
+        String c = buildRule.getProject().getProperty("dest") + "/a/b/c";
         assertFileIsPresent(c);
-        String f = getProject().getProperty("dest") + "/e/f";
+        String f = buildRule.getProject().getProperty("dest") + "/e/f";
         assertFileIsNotPresent(f);
-        assertTrue(getFullLog().indexOf("Removing orphan directory:") > -1);
-        assertDebuglogContaining("NO dangling file to remove from");
-        assertDebuglogContaining("Removed 2 dangling directories from");
+        assertTrue(buildRule.getFullLog().indexOf("Removing orphan directory:") > -1);
+        assertContains("NO dangling file to remove from", buildRule.getFullLog());
+        assertContains("Removed 2 dangling directories from", buildRule.getFullLog());
     }
 
+    @Test
     public void testCopyNoRemove() {
-        executeTarget("copynoremove");
-        String d = getProject().getProperty("dest") + "/a/b/c/d";
+        buildRule.executeTarget("copynoremove");
+        String d = buildRule.getProject().getProperty("dest") + "/a/b/c/d";
         assertFileIsPresent(d);
-        String f = getProject().getProperty("dest") + "/e/f";
+        String f = buildRule.getProject().getProperty("dest") + "/e/f";
         assertFileIsPresent(f);
-        assertTrue(getFullLog().indexOf("Removing orphan file:") == -1);
+        assertTrue(buildRule.getFullLog().indexOf("Removing orphan file:") == -1);
     }
 
+    @Test
     public void testCopyNoRemoveSelectors() {
-        executeTarget("copynoremove-selectors");
-        String d = getProject().getProperty("dest") + "/a/b/c/d";
+        buildRule.executeTarget("copynoremove-selectors");
+        String d = buildRule.getProject().getProperty("dest") + "/a/b/c/d";
         assertFileIsPresent(d);
-        String f = getProject().getProperty("dest") + "/e/f";
+        String f = buildRule.getProject().getProperty("dest") + "/e/f";
         assertFileIsPresent(f);
-        assertTrue(getFullLog().indexOf("Removing orphan file:") == -1);
+        assertTrue(buildRule.getFullLog().indexOf("Removing orphan file:") == -1);
     }
 
     public void assertFileIsPresent(String f) {
         assertTrue("Expected file " + f,
-                   getProject().resolveFile(f).exists());
+                buildRule.getProject().resolveFile(f).exists());
     }
 
     public void assertFileIsNotPresent(String f) {
         assertTrue("Didn't expect file " + f,
-                   !getProject().resolveFile(f).exists());
+                   !buildRule.getProject().resolveFile(f).exists());
     }
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TStampTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TStampTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TStampTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TStampTest.java Fri Apr 18 21:00:38 2014
@@ -22,24 +22,25 @@ import java.util.TimeZone;
 import java.util.Date;
 import java.text.SimpleDateFormat;
 
-import junit.framework.TestCase;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.Location;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 
 /**
  *
  */
-public class TStampTest extends TestCase {
+public class TStampTest {
 
     protected Tstamp tstamp;
     protected Project project;
     protected Location location;
 
-    public TStampTest(String s) {
-        super(s);
-    }
-
-    protected void setUp() throws Exception {
+    @Before
+    public void setUp() throws Exception {
         location = new Location("test.xml");
         project = new Project();
         tstamp = new Tstamp();
@@ -47,6 +48,7 @@ public class TStampTest extends TestCase
         tstamp.setProject(project);
     }
 
+    @Test
     public void testTimeZone() throws Exception {
         Tstamp.CustomFormat format = tstamp.createFormat();
         format.setProperty("today");
@@ -68,6 +70,7 @@ public class TStampTest extends TestCase
      * originals
      * @throws Exception
      */
+    @Test
     public void testWriteOrder() throws Exception {
         Tstamp.CustomFormat format = tstamp.createFormat();
         format.setProperty("TODAY");
@@ -90,6 +93,7 @@ public class TStampTest extends TestCase
      * originals
      * @throws Exception
      */
+    @Test
     public void testPrefix() throws Exception {
         tstamp.setPrefix("prefix");
         tstamp.execute();
@@ -97,8 +101,9 @@ public class TStampTest extends TestCase
         assertNotNull(prop);
     }
 
+    @Test
     public void testFormatPrefix() throws Exception {
-	Tstamp.CustomFormat format = tstamp.createFormat();
+	    Tstamp.CustomFormat format = tstamp.createFormat();
         format.setProperty("format");
         format.setPattern("HH:mm:ss z");
         format.setTimezone("GMT");

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TarTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TarTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TarTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TarTest.java Fri Apr 18 21:00:38 2014
@@ -20,138 +20,190 @@ package org.apache.tools.ant.taskdefs;
 
 import java.io.IOException;
 import java.io.File;
-import org.apache.tools.ant.BuildFileTest;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.util.FileUtils;
-
-/**
- */
-public class TarTest extends BuildFileTest {
 
-    public TarTest(String name) {
-        super(name);
-    }
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
+import org.apache.tools.ant.FileUtilities;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+public class TarTest {
+
+    @Rule
+    public final BuildFileRule buildRule = new BuildFileRule();
 
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/tar.xml");
-        executeTarget("setUp");
+        buildRule.configureProject("src/etc/testcases/taskdefs/tar.xml");
+        buildRule.executeTarget("setUp");
     }
 
+    @Test
     public void test1() {
-        expectBuildException("test1", "required argument not specified");
+        try {
+			buildRule.executeTarget("test1");
+			fail("BuildException expected: required argument not specified");
+		} catch (BuildException ex) {
+			//TODO assert value
+		}
     }
 
+    @Test
     public void test2() {
-        expectBuildException("test2", "required argument not specified");
+        try {
+			buildRule.executeTarget("test2");
+			fail("BuildException expected: required argument not specified");
+		} catch (BuildException ex) {
+			//TODO assert value
+		}
     }
 
+    @Test
     public void test3() {
-        expectBuildException("test3", "required argument not specified");
+        try {
+			buildRule.executeTarget("test3");
+			fail("BuildException expected: required argument not specified");
+		} catch (BuildException ex) {
+			//TODO assert value
+		}
     }
 
+    @Test
     public void test4() {
-        expectBuildException("test4", "tar cannot include itself");
+        try {
+			buildRule.executeTarget("test4");
+			fail("BuildException expected: tar cannot include itself");
+		} catch (BuildException ex) {
+			//TODO assert value
+		}
     }
 
+    @Test
     public void test5() {
-        executeTarget("test5");
+        buildRule.executeTarget("test5");
         File f
-            = new File(getProject().getProperty("output"), "test5.tar");
+            = new File(buildRule.getProject().getProperty("output"), "test5.tar");
 
         if (!f.exists()) {
             fail("Tarring a directory failed");
         }
     }
 
+    @Test
     public void test6() {
-        expectBuildException("test6", "Invalid value specified for longfile attribute.");
+        try {
+			buildRule.executeTarget("test6");
+			fail("BuildException expected: Invalid value specified for longfile attribute.");
+		} catch (BuildException ex) {
+			//TODO assert value
+		}
     }
 
+    @Test
     public void test7() {
         test7("test7");
     }
 
+    @Test
     public void test7UsingPlainFileSet() {
         test7("test7UsingPlainFileSet");
     }
 
+    @Test
     public void test7UsingFileList() {
         test7("test7UsingFileList");
     }
 
     private void test7(String target) {
-        executeTarget(target);
+        buildRule.executeTarget(target);
         File f1
-            = new File(getProject().getProperty("output"), "untar/test7-prefix");
+            = new File(buildRule.getProject().getProperty("output"), "untar/test7-prefix");
 
         if (!(f1.exists() && f1.isDirectory())) {
             fail("The prefix attribute is not working properly.");
         }
 
         File f2
-            = new File(getProject().getProperty("output"), "untar/test7dir");
+            = new File(buildRule.getProject().getProperty("output"), "untar/test7dir");
 
         if (!(f2.exists() && f2.isDirectory())) {
             fail("The prefix attribute is not working properly.");
         }
     }
 
+    @Test
     public void test8() {
         test8("test8");
     }
 
+    @Test
     public void test8UsingZipFileset() {
         test8("test8UsingZipFileset");
     }
 
+    @Test
     public void test8UsingZipFilesetSrc() {
         test8("test8UsingZipFilesetSrc");
     }
 
+    @Test
     public void test8UsingTarFilesetSrc() {
         test8("test8UsingTarFilesetSrc");
     }
 
+    @Test
     public void test8UsingZipEntry() {
         test8("test8UsingZipEntry");
     }
 
     private void test8(String target) {
-        executeTarget(target);
+        buildRule.executeTarget(target);
         File f1
-            = new File(getProject().getProperty("output"), "untar/test8.xml");
+            = new File(buildRule.getProject().getProperty("output"), "untar/test8.xml");
         if (! f1.exists()) {
             fail("The fullpath attribute or the preserveLeadingSlashes attribute does not work propertly");
         }
     }
 
+    @Test
     public void test9() {
-        expectBuildException("test9", "Invalid value specified for compression attribute.");
+        try {
+			buildRule.executeTarget("test9");
+			fail("BuildException expected: Invalid value specified for compression attribute.");
+		} catch (BuildException ex) {
+			//TODO assert value
+		}
     }
 
+    @Test
     public void test10() {
-        executeTarget("test10");
+        buildRule.executeTarget("test10");
         File f1
-            = new File(getProject().getProperty("output"), "untar/test10.xml");
+            = new File(buildRule.getProject().getProperty("output"), "untar/test10.xml");
         if (! f1.exists()) {
             fail("The fullpath attribute or the preserveLeadingSlashes attribute does not work propertly");
         }
     }
 
+    @Test
     public void test11() {
-        executeTarget("test11");
+        buildRule.executeTarget("test11");
         File f1
-            = new File(getProject().getProperty("output"), "untar/test11.xml");
+            = new File(buildRule.getProject().getProperty("output"), "untar/test11.xml");
         if (! f1.exists()) {
             fail("The fullpath attribute or the preserveLeadingSlashes attribute does not work propertly");
         }
     }
 
+    @Test
     public void testGZipResource() throws IOException {
-        executeTarget("testGZipResource");
-        assertTrue(FileUtils.getFileUtils()
-                   .contentEquals(getProject().resolveFile("../asf-logo.gif"),
-                           new File(getProject().getProperty("output"), "untar/asf-logo.gif.gz")));
+        buildRule.executeTarget("testGZipResource");
+        assertEquals(FileUtilities.getFileContents(buildRule.getProject().resolveFile("../asf-logo.gif")),
+                FileUtilities.getFileContents(new File(buildRule.getProject().getProperty("output"), "untar/asf-logo.gif.gz")));
     }
 
 

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TaskdefTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TaskdefTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TaskdefTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TaskdefTest.java Fri Apr 18 21:00:38 2014
@@ -18,60 +18,106 @@
 
 package org.apache.tools.ant.taskdefs;
 
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
 import org.apache.tools.ant.Project;
-import org.apache.tools.ant.BuildFileTest;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 /**
  */
-public class TaskdefTest extends BuildFileTest {
+public class TaskdefTest {
 
-    public TaskdefTest(String name) {
-        super(name);
-    }
+    @Rule
+    public final BuildFileRule buildRule = new BuildFileRule();
 
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/taskdef.xml");
+        buildRule.configureProject("src/etc/testcases/taskdefs/taskdef.xml");
     }
 
+    @Test
     public void test1() {
-        expectBuildException("test1", "required argument not specified");
+        try {
+			buildRule.executeTarget("test1");
+			fail("BuildException expected: required argument not specified");
+		} catch (BuildException ex) {
+			//TODO assert value
+		}
     }
 
+    @Test
     public void test2() {
-        expectBuildException("test2", "required argument not specified");
+        try {
+			buildRule.executeTarget("test2");
+			fail("BuildException expected: required argument not specified");
+		} catch (BuildException ex) {
+			//TODO assert value
+		}
     }
 
+    @Test
     public void test3() {
-        expectBuildException("test3", "required argument not specified");
+        try {
+			buildRule.executeTarget("test3");
+			fail("BuildException expected: required argument not specified");
+		} catch (BuildException ex) {
+			//TODO assert value
+		}
     }
 
+    @Test
     public void test4() {
-        expectBuildException("test4", "classname specified doesn't exist");
+        try {
+			buildRule.executeTarget("test4");
+			fail("BuildException expected: classname specified doesn't exist");
+		} catch (BuildException ex) {
+			//TODO assert value
+		}
     }
 
+    @Test
     public void test5() {
-        expectBuildException("test5", "No public execute() in " + Project.class);
+        try {
+            buildRule.executeTarget("test5");
+            fail("BuildException expected: No public execute() in " + Project.class);
+        } catch (BuildException ex) {
+            //TODO assert value
+        }
     }
 
+    @Test
     public void test5a() {
-        executeTarget("test5a");
+        buildRule.executeTarget("test5a");
     }
 
+    @Test
     public void test6() {
-        expectLog("test6", "simpletask: worked");
+        buildRule.executeTarget("test6");
+		assertEquals("simpletask: worked", buildRule.getLog());
     }
 
+    @Test
     public void test7() {
-        expectLog("test7", "worked");
+        buildRule.executeTarget("test7");
+		assertEquals("worked", buildRule.getLog());
     }
 
+    @Test
     public void testGlobal() {
-        expectLog("testGlobal", "worked");
+        buildRule.executeTarget("testGlobal");
+		assertEquals("worked", buildRule.getLog());
     }
 
+    @Test
     public void testOverride() {
-        executeTarget("testOverride");
-        String log = getLog();
+        buildRule.executeTarget("testOverride");
+        String log = buildRule.getLog();
         assertTrue("override warning sent",
                    log.indexOf("Trying to override old definition of task copy") > -1);
         assertTrue("task inside target worked",

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TaskdefsTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TaskdefsTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TaskdefsTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TaskdefsTest.java Fri Apr 18 21:00:38 2014
@@ -21,7 +21,7 @@ package org.apache.tools.ant.taskdefs;
 import org.apache.tools.ant.BuildFileTest;
 
 /**
- * @deprecated use BuildFileTest instead.
+ * @deprecated use {@link org.apache.tools.ant.BuildFileRule} instead.
  */
 public abstract class TaskdefsTest extends BuildFileTest {
 

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TestProcess.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TestProcess.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TestProcess.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TestProcess.java Fri Apr 18 21:00:38 2014
@@ -18,6 +18,8 @@
 
 package org.apache.tools.ant.taskdefs;
 
+import org.junit.internal.AssumptionViolatedException;
+
 /**
  * Interactive Testcase for Processdestroyer.
  *
@@ -39,7 +41,11 @@ public class TestProcess
             {
                 while (!done)
                 {
-                    try { wait(); } catch (InterruptedException ie) {}
+                    try {
+                        wait();
+                    } catch (InterruptedException ie) {
+                        throw new AssumptionViolatedException("Thread interrupted", ie);
+                    }
                 }
             }
 
@@ -53,7 +59,11 @@ public class TestProcess
         {
             System.out.println(Thread.currentThread().getName());
 
-            try { Thread.sleep(2000); } catch (InterruptedException ie) {}
+            try {
+                Thread.sleep(2000);
+            } catch (InterruptedException ie) {
+                throw new AssumptionViolatedException("Thread interrupted", ie);
+            }
         }
 
         synchronized(this)

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TouchTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TouchTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TouchTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TouchTest.java Fri Apr 18 21:00:38 2014
@@ -18,29 +18,39 @@
 
 package org.apache.tools.ant.taskdefs;
 
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.BuildFileRule;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.util.FileUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
 
 import java.io.File;
 
-public class TouchTest extends BuildFileTest {
+import static org.apache.tools.ant.AntAssert.assertContains;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public class TouchTest {
+    
+    @Rule
+    public final BuildFileRule buildRule = new BuildFileRule();
 
     private static String TOUCH_FILE = "src/etc/testcases/taskdefs/touchtest";
 
     /** Utilities used for file operations */
     private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
 
-    public TouchTest(String name) {
-        super(name);
-    }
 
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/touch.xml");
+        buildRule.configureProject("src/etc/testcases/taskdefs/touch.xml");
     }
 
+    @After
     public void tearDown() {
-        executeTarget("cleanup");
+        buildRule.executeTarget("cleanup");
     }
 
     public long getTargetTime() {
@@ -56,22 +66,25 @@ public class TouchTest extends BuildFile
      * No real test, simply checks whether the dateformat without
      * seconds is accepted - by erroring out otherwise.
      */
+    @Test
     public void testNoSeconds() {
-        executeTarget("noSeconds");
-        long time = getTargetTime();
+        buildRule.executeTarget("noSeconds");
+        getTargetTime();
     }
 
     /**
      * No real test, simply checks whether the dateformat with
      * seconds is accepted - by erroring out otherwise.
      */
+    @Test
     public void testSeconds() {
-        executeTarget("seconds");
-        long time=getTargetTime();
+        buildRule.executeTarget("seconds");
+        getTargetTime();
     }
     /**
      * verify that the millis test sets things up
      */
+    @Test
     public void testMillis() {
         touchFile("testMillis", 662256000000L);
     }
@@ -79,15 +92,17 @@ public class TouchTest extends BuildFile
     /**
      * verify that the default value defaults to now
      */
+    @Test
     public void testNow() {
         long now=System.currentTimeMillis();
-        executeTarget("testNow");
+        buildRule.executeTarget("testNow");
         long time = getTargetTime();
         assertTimesNearlyMatch(time,now,5000);
     }
     /**
      * verify that the millis test sets things up
      */
+    @Test
     public void test2000() {
         touchFile("test2000", 946080000000L);
     }
@@ -95,6 +110,7 @@ public class TouchTest extends BuildFile
     /**
      * test the file list
      */
+    @Test
     public void testFilelist() {
         touchFile("testFilelist", 662256000000L);
     }
@@ -102,6 +118,7 @@ public class TouchTest extends BuildFile
     /**
      * test the file set
      */
+    @Test
     public void testFileset() {
         touchFile("testFileset", 946080000000L);
     }
@@ -109,6 +126,7 @@ public class TouchTest extends BuildFile
     /**
      * test the resource collection
      */
+    @Test
     public void testResourceCollection() {
         touchFile("testResourceCollection", 1662256000000L);
     }
@@ -116,37 +134,47 @@ public class TouchTest extends BuildFile
     /**
      * test the mapped file set
      */
+    @Test
     public void testMappedFileset() {
-        executeTarget("testMappedFileset");
+        buildRule.executeTarget("testMappedFileset");
     }
 
     /**
      * test the explicit mapped file set
      */
+    @Test
     public void testExplicitMappedFileset() {
-        executeTarget("testExplicitMappedFileset");
+        buildRule.executeTarget("testExplicitMappedFileset");
     }
 
     /**
      * test the mapped file list
      */
+    @Test
     public void testMappedFilelist() {
-        executeTarget("testMappedFilelist");
+        buildRule.executeTarget("testMappedFilelist");
     }
 
     /**
      * test the pattern attribute
      */
+    @Test
     public void testGoodPattern() {
-        executeTarget("testGoodPattern");
+        buildRule.executeTarget("testGoodPattern");
     }
 
     /**
      * test the pattern attribute again
      */
+    @Test
     public void testBadPattern() {
-        expectBuildExceptionContaining("testBadPattern",
-            "No parsing exception thrown", "Unparseable");
+        try {
+            buildRule.executeTarget("testBadPattern");
+            fail("No parsing exception thrown");
+        } catch (BuildException ex) {
+            assertContains("Unparseable", ex.getMessage());
+        }
+
     }
 
     /**
@@ -155,7 +183,7 @@ public class TouchTest extends BuildFile
      * @param timestamp
      */
     private void touchFile(String targetName, long timestamp) {
-        executeTarget(targetName);
+        buildRule.executeTarget(targetName);
         long time = getTargetTime();
         assertTimesNearlyMatch(timestamp, time);
     }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TypeAdapterTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TypeAdapterTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TypeAdapterTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TypeAdapterTest.java Fri Apr 18 21:00:38 2014
@@ -20,49 +20,71 @@ package org.apache.tools.ant.taskdefs;
 
 import java.lang.reflect.Method;
 
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.BuildFileRule;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.Task;
 import org.apache.tools.ant.TypeAdapter;
+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.fail;
 
 
 /**
  */
-public class TypeAdapterTest extends BuildFileTest {
+public class TypeAdapterTest {
+
+    @Rule
+    public final BuildFileRule buildRule = new BuildFileRule();
 
-    public TypeAdapterTest(String name) {
-        super(name);
-    }
 
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/typeadapter.xml");
+        buildRule.configureProject("src/etc/testcases/taskdefs/typeadapter.xml");
     }
 
+    @Test
     public void testTaskAdapter() {
-        expectLogContaining("taskadapter", "MyExec called");
+        buildRule.executeTarget("taskadapter");
+		assertContains("MyExec called", buildRule.getLog());
     }
 
+    @Test
     public void testRunAdapter() {
-        expectLogContaining("runadapter", "MyRunnable called");
+        buildRule.executeTarget("runadapter");
+		assertContains("MyRunnable called", buildRule.getLog());
     }
 
+    @Test
     public void testRunAdapterError() {
-        expectBuildExceptionContaining(
-            "runadaptererror", "xx", "No public run() method in");
+        try {
+            buildRule.executeTarget("runadaptererror");
+            fail("BuildException expected: no public run method");
+        } catch (BuildException ex) {
+            assertContains("No public run() method in", ex.getMessage());
+        }
     }
 
+    @Test
     public void testDelay() {
-        expectLogContaining("delay", "MyTask called");
+        buildRule.executeTarget("delay");
+		assertContains("MyTask called", buildRule.getLog());
     }
 
+    @Test
     public void testOnErrorReport() {
-        expectLogContaining("onerror.report",
-                            "MyTaskNotPresent cannot be found");
+        buildRule.executeTarget("onerror.report");
+		assertContains("MyTaskNotPresent cannot be found", buildRule.getLog());
     }
 
+    @Test
     public void testOnErrorIgnore() {
-        expectLog("onerror.ignore","");
+        buildRule.executeTarget("onerror.ignore");
+		assertEquals("", buildRule.getLog());
     }
 
     public static class MyTask extends Task {

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TypedefTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TypedefTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TypedefTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TypedefTest.java Fri Apr 18 21:00:38 2014
@@ -18,48 +18,85 @@
 
 package org.apache.tools.ant.taskdefs;
 
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.apache.tools.ant.AntAssert.assertContains;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
 
 /**
  */
-public class TypedefTest extends BuildFileTest {
+public class TypedefTest {
+    
+    @Rule
+    public final BuildFileRule buildRule = new BuildFileRule();
 
-    public TypedefTest(String name) {
-        super(name);
-    }
 
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/typedef.xml");
+        buildRule.configureProject("src/etc/testcases/taskdefs/typedef.xml");
     }
 
+    @Test
     public void testEmpty() {
-        expectBuildException("empty", "required argument not specified");
+        try {
+			buildRule.executeTarget("empty");
+			fail("BuildException expected: required argument not specified");
+		} catch (BuildException ex) {
+			//TODO assert value
+		}
     }
 
+    @Test
     public void testNoName() {
-        expectBuildException("noName", "required argument not specified");
+        try {
+			buildRule.executeTarget("noName");
+			fail("BuildException expected: required argument not specified");
+		} catch (BuildException ex) {
+			//TODO assert value
+		}
     }
 
+    @Test
     public void testNoClassname() {
-        expectBuildException("noClassname", "required argument not specified");
+        try {
+			buildRule.executeTarget("noClassname");
+			fail("BuildException expected: required argument not specified");
+		} catch (BuildException ex) {
+			//TODO assert value
+		}
     }
 
+    @Test
     public void testClassNotFound() {
-        expectBuildException("classNotFound",
-                             "classname specified doesn't exist");
+        try {
+			buildRule.executeTarget("classNotFound");
+			fail("BuildException expected: classname specified doesn't exist");
+		} catch (BuildException ex) {
+			//TODO assert value
+		}
     }
 
+    @Test
     public void testGlobal() {
-        expectLog("testGlobal", "");
-        Object ref = project.getReferences().get("global");
+        buildRule.executeTarget("testGlobal");
+        assertEquals("", buildRule.getLog());
+        Object ref = buildRule.getProject().getReferences().get("global");
         assertNotNull("ref is not null", ref);
         assertEquals("org.example.types.TypedefTestType",
                      ref.getClass().getName());
     }
 
+    @Test
     public void testLocal() {
-        expectLog("testLocal", "");
-        Object ref = project.getReferences().get("local");
+        buildRule.executeTarget("testLocal");
+        assertEquals("", buildRule.getLog());
+        Object ref = buildRule.getProject().getReferences().get("local");
         assertNotNull("ref is not null", ref);
         assertEquals("org.example.types.TypedefTestType",
                      ref.getClass().getName());
@@ -69,19 +106,31 @@ public class TypedefTest extends BuildFi
      * test to make sure that one can define a not present
      * optional type twice and then have a valid definition.
      */
+    @Test
     public void testDoubleNotPresent() {
-        expectLogContaining("double-notpresent", "hi");
+        buildRule.executeTarget("double-notpresent");
+		assertContains("hi", buildRule.getLog());
     }
     
+    @Test
     public void testNoResourceOnErrorFailAll(){
-    		this.expectBuildExceptionContaining("noresourcefailall","the requested resource does not exist","Could not load definitions from resource ");
+    		try {
+			buildRule.executeTarget("noresourcefailall");
+			fail("BuildException expected: the requested resource does not exist");
+		} catch (BuildException ex) {
+			assertContains("Could not load definitions from resource ", ex.getMessage());
+		}
     }
     
+    @Test
     public void testNoResourceOnErrorFail(){
-		expectLogContaining("noresourcefail","Could not load definitions from resource ");
+		buildRule.executeTarget("noresourcefail");
+		assertContains("Could not load definitions from resource ", buildRule.getLog());
     }
     
+    @Test
     public void testNoResourceOnErrorNotFail(){
-    		expectLogContaining("noresourcenotfail","Could not load definitions from resource ");
+    		buildRule.executeTarget("noresourcenotfail");
+		assertContains("Could not load definitions from resource ", buildRule.getLog());
     }
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/UntarTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/UntarTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/UntarTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/UntarTest.java Fri Apr 18 21:00:38 2014
@@ -17,75 +17,97 @@
  */
 package org.apache.tools.ant.taskdefs;
 
-import org.apache.tools.ant.BuildFileTest;
-import org.apache.tools.ant.util.FileUtils;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
+import org.apache.tools.ant.FileUtilities;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
 
 import java.io.File;
 
-/**
- */
-public class UntarTest extends BuildFileTest {
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
-    /** Utilities used for file operations */
-    private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
 
-    public UntarTest(String name) {
-        super(name);
-    }
+public class UntarTest {
 
+    @Rule
+    public final BuildFileRule buildRule = new BuildFileRule();
+
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/untar.xml");
+        buildRule.configureProject("src/etc/testcases/taskdefs/untar.xml");
     }
 
+    @Test
     public void testRealTest() throws java.io.IOException {
         testLogoExtraction("realTest");
     }
 
+    @Test
     public void testRealGzipTest() throws java.io.IOException {
         testLogoExtraction("realGzipTest");
     }
 
+    @Test
     public void testRealBzip2Test() throws java.io.IOException {
         testLogoExtraction("realBzip2Test");
     }
 
+    @Test
     public void testTestTarTask() throws java.io.IOException {
         testLogoExtraction("testTarTask");
     }
 
+    @Test
     public void testTestGzipTarTask() throws java.io.IOException {
         testLogoExtraction("testGzipTarTask");
     }
 
+    @Test
     public void testTestBzip2TarTask() throws java.io.IOException {
         testLogoExtraction("testBzip2TarTask");
     }
 
+    @Test
     public void testSrcDirTest() {
-        expectBuildException("srcDirTest", "Src cannot be a directory.");
+        try {
+            buildRule.executeTarget("srcDirTest");
+            fail("Src cannot be a directory.");
+        } catch (BuildException ex) {
+            //TODO assert value
+        }
     }
 
+    @Test
     public void testEncoding() {
-        expectSpecificBuildException("encoding",
-                                     "<untar> overrides setEncoding.",
-                                     "The untar task doesn't support the "
-                                     + "encoding attribute");
+        try {
+            buildRule.executeTarget("encoding");
+            fail("<untar> overrides setEncoding.");
+        } catch (BuildException ex) {
+            assertEquals("The untar task doesn't support the encoding attribute", ex.getMessage());
+        }
     }
 
+    @Test
     public void testResourceCollection() throws java.io.IOException {
         testLogoExtraction("resourceCollection");
     }
 
     private void testLogoExtraction(String target) throws java.io.IOException {
-        executeTarget(target);
-        assertTrue(FILE_UTILS.contentEquals(project.resolveFile("../asf-logo.gif"),
-                                           new File(getProject().getProperty("output"), "untar/" +
-                                                   "asf-logo.gif")));
+        buildRule.executeTarget(target);
+        assertEquals(FileUtilities.getFileContents(buildRule.getProject().resolveFile("../asf-logo.gif")),
+                FileUtilities.getFileContents(new File(buildRule.getProject().getProperty("output"), "untar/asf-logo.gif")));
+
     }
 
+    @Test
     public void testDocumentationClaimsOnCopy() {
-        executeTarget("testDocumentationClaimsOnCopy");
-        assertFalse(new File(getProject().getProperty("output"), "untar/1/foo").exists());
-        assertTrue(new File(getProject().getProperty("output"), "untar/2/bar").exists());
+        buildRule.executeTarget("testDocumentationClaimsOnCopy");
+        assertFalse(new File(buildRule.getProject().getProperty("output"), "untar/1/foo").exists());
+        assertTrue(new File(buildRule.getProject().getProperty("output"), "untar/2/bar").exists());
     }
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/UnzipTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/UnzipTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/UnzipTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/UnzipTest.java Fri Apr 18 21:00:38 2014
@@ -17,42 +17,65 @@
  */
 
 package org.apache.tools.ant.taskdefs;
-import org.apache.tools.ant.BuildFileTest;
-import org.apache.tools.ant.util.FileUtils;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
+import org.apache.tools.ant.FileUtilities;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
 
 import java.io.File;
 import java.io.IOException;
 
-/**
- */
-public class UnzipTest extends BuildFileTest {
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
-    /** Utilities used for file operations */
-    private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
+public class UnzipTest {
 
-    public UnzipTest(String name) {
-        super(name);
-    }
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/unzip.xml");
+        buildRule.configureProject("src/etc/testcases/taskdefs/unzip.xml");
     }
 
+    @Test
     public void test1() {
-        expectBuildException("test1", "required argument not specified");
+        try {
+			buildRule.executeTarget("test1");
+			fail("BuildException expected: required argument not specified");
+		} catch (BuildException ex) {
+			//TODO assert value
+		}
     }
 
+    @Test
     public void test2() {
-        expectBuildException("test2", "required argument not specified");
+        try {
+			buildRule.executeTarget("test2");
+			fail("BuildException expected: required argument not specified");
+		} catch (BuildException ex) {
+			//TODO assert value
+		}
     }
 
+    @Test
     public void test3() {
-        expectBuildException("test3", "required argument not specified");
+        try {
+			buildRule.executeTarget("test3");
+			fail("BuildException expected: required argument not specified");
+		} catch (BuildException ex) {
+			//TODO assert value
+		}
     }
 
 
+    @Test
     public void testRealTest() throws java.io.IOException {
-        executeTarget("realTest");
+        buildRule.executeTarget("realTest");
         assertLogoUncorrupted();
     }
 
@@ -61,100 +84,113 @@ public class UnzipTest extends BuildFile
      * @throws IOException
      */
     private void assertLogoUncorrupted() throws IOException {
-        assertTrue(FILE_UTILS.contentEquals(project.resolveFile("../asf-logo.gif"),
-                                           new File(getProject().getProperty("output"), "asf-logo.gif")));
+        assertEquals(FileUtilities.getFileContents(buildRule.getProject().resolveFile("../asf-logo.gif")),
+                FileUtilities.getFileContents(new File(buildRule.getProject().getProperty("output"), "asf-logo.gif")));
+
     }
 
+    @Test
     public void testTestZipTask() throws java.io.IOException {
-        executeTarget("testZipTask");
+        buildRule.executeTarget("testZipTask");
         assertLogoUncorrupted();
     }
 
+    @Test
     public void testTestUncompressedZipTask() throws java.io.IOException {
-        executeTarget("testUncompressedZipTask");
+        buildRule.executeTarget("testUncompressedZipTask");
         assertLogoUncorrupted();
     }
 
     /*
      * PR 11100
      */
+    @Test
     public void testPatternSetExcludeOnly() {
-        executeTarget("testPatternSetExcludeOnly");
-        assertFileMissing("1/foo is excluded", getProject().getProperty("output") + "/unziptestout/1/foo");
-        assertFileExists("2/bar is not excluded", getProject().getProperty("output") + "/unziptestout/2/bar");
+        buildRule.executeTarget("testPatternSetExcludeOnly");
+        assertFileMissing("1/foo is excluded", buildRule.getProject().getProperty("output") + "/unziptestout/1/foo");
+        assertFileExists("2/bar is not excluded", buildRule.getProject().getProperty("output") + "/unziptestout/2/bar");
     }
 
     /*
      * PR 11100
      */
+    @Test
     public void testPatternSetIncludeOnly() {
-        executeTarget("testPatternSetIncludeOnly");
-        assertFileMissing("1/foo is not included", getProject().getProperty("output") + "/unziptestout/1/foo");
-        assertFileExists("2/bar is included", getProject().getProperty("output") + "/unziptestout/2/bar");
+        buildRule.executeTarget("testPatternSetIncludeOnly");
+        assertFileMissing("1/foo is not included", buildRule.getProject().getProperty("output") + "/unziptestout/1/foo");
+        assertFileExists("2/bar is included", buildRule.getProject().getProperty("output") + "/unziptestout/2/bar");
     }
 
     /*
      * PR 11100
      */
+    @Test
     public void testPatternSetIncludeAndExclude() {
-        executeTarget("testPatternSetIncludeAndExclude");
-        assertFileMissing("1/foo is not included", getProject().getProperty("output") + "/unziptestout/1/foo");
-        assertFileMissing("2/bar is excluded", getProject().getProperty("output") + "/unziptestout/2/bar");
+        buildRule.executeTarget("testPatternSetIncludeAndExclude");
+        assertFileMissing("1/foo is not included", buildRule.getProject().getProperty("output") + "/unziptestout/1/foo");
+        assertFileMissing("2/bar is excluded", buildRule.getProject().getProperty("output") + "/unziptestout/2/bar");
     }
 
     /*
      * PR 38973
      */
+    @Test
     public void testTwoPatternSets() {
-        executeTarget("testTwoPatternSets");
-        assertFileMissing("1/foo is not included", getProject().getProperty("output") + "/unziptestout/1/foo");
-        assertFileExists("2/bar is included", getProject().getProperty("output") + "/unziptestout/2/bar");
+        buildRule.executeTarget("testTwoPatternSets");
+        assertFileMissing("1/foo is not included", buildRule.getProject().getProperty("output") + "/unziptestout/1/foo");
+        assertFileExists("2/bar is included", buildRule.getProject().getProperty("output") + "/unziptestout/2/bar");
     }
 
     /*
      * PR 38973
      */
+    @Test
     public void testTwoPatternSetsWithExcludes() {
-        executeTarget("testTwoPatternSetsWithExcludes");
-        assertFileMissing("1/foo is not included", getProject().getProperty("output") + "/unziptestout/1/foo");
-        assertFileMissing("2/bar is excluded", getProject().getProperty("output") + "/unziptestout/2/bar");
+        buildRule.executeTarget("testTwoPatternSetsWithExcludes");
+        assertFileMissing("1/foo is not included", buildRule.getProject().getProperty("output") + "/unziptestout/1/foo");
+        assertFileMissing("2/bar is excluded", buildRule.getProject().getProperty("output") + "/unziptestout/2/bar");
     }
 
     /*
      * PR 16213
      */
-    public void XtestSelfExtractingArchive() {
+    @Test
+    @Ignore("we lack a self extracting archive that we are allowed to distribute - see PR 49080")
+    public void testSelfExtractingArchive() {
         // disabled because we lack a self extracting archive that we
         // are allowed to distribute - see PR 49080
-        executeTarget("selfExtractingArchive");
+        buildRule.executeTarget("selfExtractingArchive");
     }
 
 
     /*
      * PR 20969
      */
+    @Test
     public void testPatternSetSlashOnly() {
-        executeTarget("testPatternSetSlashOnly");
-        assertFileMissing("1/foo is not included", getProject().getProperty("output") + "/unziptestout/1/foo");
-        assertFileExists("\"2/bar is included", getProject().getProperty("output") + "/unziptestout/2/bar");
+        buildRule.executeTarget("testPatternSetSlashOnly");
+        assertFileMissing("1/foo is not included", buildRule.getProject().getProperty("output") + "/unziptestout/1/foo");
+        assertFileExists("\"2/bar is included", buildRule.getProject().getProperty("output") + "/unziptestout/2/bar");
     }
 
 
     /*
      * PR 10504
      */
+    @Test
     public void testEncoding() {
-        executeTarget("encodingTest");
-        assertFileExists("foo has been properly named", getProject().getProperty("output") + "/unziptestout/foo");
+        buildRule.executeTarget("encodingTest");
+        assertFileExists("foo has been properly named", buildRule.getProject().getProperty("output") + "/unziptestout/foo");
     }
 
     /*
      * PR 21996
      */
+    @Test
     public void testFlattenMapper() {
-        executeTarget("testFlattenMapper");
-        assertFileMissing("1/foo is not flattened", getProject().getProperty("output") + "/unziptestout/1/foo");
-        assertFileExists("foo is flattened", getProject().getProperty("output") + "/unziptestout/foo");
+        buildRule.executeTarget("testFlattenMapper");
+        assertFileMissing("1/foo is not flattened", buildRule.getProject().getProperty("output") + "/unziptestout/1/foo");
+        assertFileExists("foo is flattened", buildRule.getProject().getProperty("output") + "/unziptestout/foo");
     }
 
     /**
@@ -164,7 +200,7 @@ public class UnzipTest extends BuildFile
      */
     private void assertFileExists(String message, String filename) {
         assertTrue(message,
-                   getProject().resolveFile(filename).exists());
+                buildRule.getProject().resolveFile(filename).exists());
     }
 
     /**
@@ -175,31 +211,40 @@ public class UnzipTest extends BuildFile
      */
     private void assertFileMissing(String message, String filename) {
         assertTrue(message,
-                !getProject().resolveFile(filename).exists());
+                !buildRule.getProject().resolveFile(filename).exists());
     }
 
     /**
      * PR 21996
      */
+    @Test
     public void testGlobMapper() {
-        executeTarget("testGlobMapper");
-        assertFileMissing("1/foo is not mapped", getProject().getProperty("output") + "/unziptestout/1/foo");
-        assertFileExists("1/foo is mapped", getProject().getProperty("output") + "/unziptestout/1/foo.txt");
+        buildRule.executeTarget("testGlobMapper");
+        assertFileMissing("1/foo is not mapped", buildRule.getProject().getProperty("output") + "/unziptestout/1/foo");
+        assertFileExists("1/foo is mapped", buildRule.getProject().getProperty("output") + "/unziptestout/1/foo.txt");
     }
 
+    @Test
     public void testTwoMappers() {
-        expectBuildException("testTwoMappers",Expand.ERROR_MULTIPLE_MAPPERS);
+        try {
+			buildRule.executeTarget("testTwoMappers");
+			fail("BuildException expected: " + Expand.ERROR_MULTIPLE_MAPPERS);
+		} catch (BuildException ex) {
+			//TODO assert value
+		}
     }
 
+    @Test
     public void testResourceCollections() {
-        executeTarget("testResourceCollection");
+        buildRule.executeTarget("testResourceCollection");
         assertFileExists("junit.jar has been extracted",
-                getProject().getProperty("output") + "/unziptestout/junit/framework/Assert.class");
+                buildRule.getProject().getProperty("output") + "/unziptestout/junit/framework/Assert.class");
     }
 
+    @Test
     public void testDocumentationClaimsOnCopy() {
-        executeTarget("testDocumentationClaimsOnCopy");
-        assertFileMissing("1/foo is excluded", getProject().getProperty("output") + "/unziptestout/1/foo");
-        assertFileExists("2/bar is not excluded", getProject().getProperty("output") + "/unziptestout/2/bar");
+        buildRule.executeTarget("testDocumentationClaimsOnCopy");
+        assertFileMissing("1/foo is excluded", buildRule.getProject().getProperty("output") + "/unziptestout/1/foo");
+        assertFileExists("2/bar is not excluded", buildRule.getProject().getProperty("output") + "/unziptestout/2/bar");
     }
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/UpToDateTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/UpToDateTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/UpToDateTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/UpToDateTest.java Fri Apr 18 21:00:38 2014
@@ -18,35 +18,60 @@
 
 package org.apache.tools.ant.taskdefs;
 
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.BuildFileRule;
+import org.apache.tools.ant.util.FileUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
 
-public class UpToDateTest extends BuildFileTest {
+import java.io.File;
 
-    public UpToDateTest(String name) {
-        super(name);
-    }
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assume.assumeTrue;
+
+public class UpToDateTest {
+
+    @Rule
+    public final BuildFileRule buildRule = new BuildFileRule();
 
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/uptodate.xml");
+        buildRule.configureProject("src/etc/testcases/taskdefs/uptodate.xml");
+        buildRule.executeTarget("setUp");
+        File srcDir = buildRule.getProject().resolveFile("source");
+        assumeTrue("Could not change modification timestamp of source directory",
+                srcDir.setLastModified(srcDir.lastModified()
+                - (3 * FileUtils.getFileUtils().getFileTimestampGranularity())));
     }
 
+    @After
     public void tearDown() {
-        executeTarget("tearDown");
+        buildRule.executeTarget("tearDown");
     }
 
+    @Test
     public void testFilesetUpToDate() {
-        expectPropertySet("testFilesetUpToDate", "foo");
+        buildRule.executeTarget("testFilesetUpToDate");
+		assertEquals("true", buildRule.getProject().getProperty("foo"));
     }
 
+    @Test
     public void testFilesetOutOfDate() {
-        expectPropertyUnset("testFilesetOutOfDate", "foo");
+        buildRule.executeTarget("testFilesetOutOfDate");
+		assertNull(buildRule.getProject().getProperty("foo"));
     }
 
+    @Test
     public void testRCUpToDate() {
-        expectPropertySet("testRCUpToDate", "foo");
+        buildRule.executeTarget("testRCUpToDate");
+		assertEquals("true", buildRule.getProject().getProperty("foo"));
     }
 
+    @Test
     public void testRCOutOfDate() {
-        expectPropertyUnset("testRCOutOfDate", "foo");
+        buildRule.executeTarget("testRCOutOfDate");
+		assertNull(buildRule.getProject().getProperty("foo"));
     }
 }