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 [3/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/TopLevelTaskTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/TopLevelTaskTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/TopLevelTaskTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/TopLevelTaskTest.java Fri Apr 18 21:00:38 2014
@@ -21,29 +21,39 @@ package org.apache.tools.ant;
 // This test will fail with embed, or if top-level is moved out of
 // dependency - as 'echo' happens as part of configureProject stage.
 
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
 /**
  * Tests for builds with tasks at the top level
  *
  * @since Ant 1.6
  */
-public class TopLevelTaskTest extends BuildFileTest {
+public class TopLevelTaskTest {
 
-    public TopLevelTaskTest(String name) {
-        super(name);
-    }
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
+    @Test
     public void testNoTarget() {
-        configureProject("src/etc/testcases/core/topleveltasks/notarget.xml");
-        expectLog("", "Called");
+        buildRule.configureProject("src/etc/testcases/core/topleveltasks/notarget.xml");
+        buildRule.executeTarget("");
+        assertEquals("Called", buildRule.getLog());
     }
 
+    @Test
     public void testCalledFromTopLevelAnt() {
-        configureProject("src/etc/testcases/core/topleveltasks/toplevelant.xml");
-        expectLog("", "Called");
+        buildRule.configureProject("src/etc/testcases/core/topleveltasks/toplevelant.xml");
+        buildRule.executeTarget("");
+        assertEquals("Called", buildRule.getLog());
     }
 
+    @Test
     public void testCalledFromTargetLevelAnt() {
-        configureProject("src/etc/testcases/core/topleveltasks/targetlevelant.xml");
-        expectLog("foo", "Called");
+        buildRule.configureProject("src/etc/testcases/core/topleveltasks/targetlevelant.xml");
+        buildRule.executeTarget("foo");
+        assertEquals("Called", buildRule.getLog());
     }
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/UnknownElementTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/UnknownElementTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/UnknownElementTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/UnknownElementTest.java Fri Apr 18 21:00:38 2014
@@ -18,26 +18,45 @@
 
 package org.apache.tools.ant;
 
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
-public class UnknownElementTest extends BuildFileTest {
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNotNull;
+
+public class UnknownElementTest {
+
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
+
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/core/unknownelement.xml");
+        buildRule.configureProject("src/etc/testcases/core/unknownelement.xml");
     }
+
+    @Test
     public void testMaybeConfigure() {
         // make sure we do not get a NPE
-        executeTarget("testMaybeConfigure");
+        buildRule.executeTarget("testMaybeConfigure");
     }
 
     /**
      * Not really a UnknownElement test but rather one of "what
      * information is available in taskFinished".
-     * @see https://issues.apache.org/bugzilla/show_bug.cgi?id=26197
+     * @see <a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=26197">
+     *     https://issues.apache.org/bugzilla/show_bug.cgi?id=26197</a>
      */
+    @Test
+    @Ignore("Previously disabled through naming convention")
     public void XtestTaskFinishedEvent() {
-        getProject().addBuildListener(new BuildListener() {
+        buildRule.getProject().addBuildListener(new BuildListener() {
                 public void buildStarted(BuildEvent event) {}
                 public void buildFinished(BuildEvent event) {}
                 public void targetStarted(BuildEvent event) {}
@@ -58,7 +77,7 @@ public class UnknownElementTest extends 
                                  t.getClass().getName());
                 }
             });
-        executeTarget("echo");
+        buildRule.executeTarget("echo");
     }
 
     public static class Child extends Task {

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/ConcatFilterTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/ConcatFilterTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/ConcatFilterTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/ConcatFilterTest.java Fri Apr 18 21:00:38 2014
@@ -21,16 +21,21 @@ package org.apache.tools.ant.filters;
 import java.io.File;
 import java.io.IOException;
 
-import org.apache.tools.ant.BuildFileTest;
-import org.apache.tools.ant.util.FileUtils;
+import org.apache.tools.ant.BuildFileRule;
+import org.apache.tools.ant.FileUtilities;
 import org.apache.tools.ant.util.StringUtils;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 /**
  * JUnit Testcases for ConcatReader
  */
-public class ConcatFilterTest extends BuildFileTest {
+public class ConcatFilterTest {
 
-    private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
     private static final String lSep = StringUtils.LINE_SEP;
 
     private static final String FILE_PREPEND_WITH =
@@ -65,48 +70,55 @@ public class ConcatFilterTest extends Bu
         + "Line 60" + lSep
     ;
 
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
-    public ConcatFilterTest(String name) {
-        super(name);
-    }
-
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/filters/concat.xml");
+        buildRule.configureProject("src/etc/testcases/filters/concat.xml");
     }
 
-
+    @Test
     public void testFilterReaderNoArgs() throws IOException {
-        executeTarget("testFilterReaderNoArgs");
-        File expected = new File(getProject().getProperty("output"), "concatfilter.test");
-        File result = new File(getProject().getProperty("output"),  "concat.FilterReaderNoArgs.test");
-        assertTrue("testFilterReaderNoArgs: Result not like expected", FILE_UTILS.contentEquals(expected, result));
+        buildRule.executeTarget("testFilterReaderNoArgs");
+        File expected = new File(buildRule.getProject().getProperty("output"), "concatfilter.test");
+        File result = new File(buildRule.getProject().getProperty("output"),  "concat.FilterReaderNoArgs.test");
+        assertEquals("testFilterReaderNoArgs: Result not like expected", FileUtilities.getFileContents(expected),
+                FileUtilities.getFileContents(result));
     }
 
-    public void testFilterReaderBefore() {
+    @Test
+    public void testFilterReaderBefore() throws IOException {
         doTest("testFilterReaderPrepend", FILE_PREPEND_WITH, FILE_APPEND);
     }
 
-    public void testFilterReaderAfter() {
+    @Test
+    public void testFilterReaderAfter() throws IOException {
         doTest("testFilterReaderAppend", FILE_PREPEND, FILE_APPEND_WITH);
     }
 
-    public void testFilterReaderBeforeAfter() {
+    @Test
+    public void testFilterReaderBeforeAfter() throws IOException {
         doTest("testFilterReaderPrependAppend", FILE_PREPEND_WITH, FILE_APPEND_WITH);
     }
 
-    public void testConcatFilter() {
+    @Test
+    public void testConcatFilter() throws IOException {
         doTest("testConcatFilter", FILE_PREPEND, FILE_APPEND);
     }
 
-    public void testConcatFilterBefore() {
+    @Test
+    public void testConcatFilterBefore() throws IOException {
         doTest("testConcatFilterPrepend", FILE_PREPEND_WITH, FILE_APPEND);
     }
 
-    public void testConcatFilterAfter() {
+    @Test
+    public void testConcatFilterAfter() throws IOException {
         doTest("testConcatFilterAppend", FILE_PREPEND, FILE_APPEND_WITH);
     }
 
-    public void testConcatFilterBeforeAfter() {
+    @Test
+    public void testConcatFilterBeforeAfter() throws IOException {
         doTest("testConcatFilterPrependAppend", FILE_PREPEND_WITH, FILE_APPEND_WITH);
     }
 
@@ -119,33 +131,13 @@ public class ConcatFilterTest extends Bu
      * @param expectedStart The string which should be at the beginning of the file
      * @param expectedEnd The string which should be at the end of the file
      */
-    protected void doTest(String target, String expectedStart, String expectedEnd) {
-        executeTarget(target);
-        String resultContent = read(getProject().getProperty("output") + "/concat." + target.substring(4) + ".test");
+    protected void doTest(String target, String expectedStart, String expectedEnd) throws IOException {
+        buildRule.executeTarget(target);
+        String resultContent = FileUtilities.getFileContents(
+                new File(buildRule.getProject().getProperty("output") + "/concat." + target.substring(4) + ".test"));
         assertTrue("First 5 lines differs.", resultContent.startsWith(expectedStart));
         assertTrue("Last 5 lines differs.", resultContent.endsWith(expectedEnd));
     }
 
 
-    /**
-     * Wrapper for FileUtils.readFully().
-     * Additionally it resolves the filename according the the projects basedir
-     * and closes the used reader.
-     * @param filename The name of the file to read
-     * @return the content of the file or <i>null</i> if something goes wrong
-     */
-    protected String read(String filename) {
-        String content = null;
-        try {
-            File file = FILE_UTILS.resolveFile(getProject().getBaseDir(), filename);
-            java.io.FileReader rdr = new java.io.FileReader(file);
-            content = FileUtils.readFully(rdr);
-            rdr.close();
-            rdr = null;
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return content;
-    }
-
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/DynamicFilterTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/DynamicFilterTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/DynamicFilterTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/DynamicFilterTest.java Fri Apr 18 21:00:38 2014
@@ -18,67 +18,38 @@
 
 package org.apache.tools.ant.filters;
 
+import java.io.File;
 import java.io.Reader;
-import java.io.FileReader;
 import java.io.IOException;
 
-import org.apache.tools.ant.BuildFileTest;
-import org.apache.tools.ant.util.FileUtils;
+import org.apache.tools.ant.BuildFileRule;
+import org.apache.tools.ant.FileUtilities;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
 
-/**
- */
-public class DynamicFilterTest extends BuildFileTest {
-
-    private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
-    
-    public DynamicFilterTest(String name) {
-        super(name);
-    }
+import static org.apache.tools.ant.AntAssert.assertContains;
+
+public class DynamicFilterTest {
+
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/filters/dynamicfilter.xml");
-        executeTarget("setUp");
+        buildRule.configureProject("src/etc/testcases/filters/dynamicfilter.xml");
+        buildRule.executeTarget("setUp");
     }
 
+    @Test
     public void testCustomFilter() throws IOException {
-        expectFileContains("dynamicfilter", getProject().getProperty("output") + "/dynamicfilter",
-                           "hellO wOrld");
-    }
-
-    // ------------------------------------------------------
-    //   Helper methods
-    // -----------------------------------------------------
-
-    private String getFileString(String filename)
-        throws IOException
-    {
-        Reader r = null;
-        try {
-            r = new FileReader(FILE_UTILS.resolveFile(getProject().getBaseDir(), filename));
-            return  FileUtils.readFully(r);
-        }
-        finally {
-            FileUtils.close(r);
-        }
-
+        buildRule.executeTarget("dynamicfilter");
+        String content = FileUtilities.getFileContents(
+                new File(buildRule.getProject().getProperty("output") + "/dynamicfilter"));
+        assertContains("hellO wOrld", content);
     }
 
-    private void expectFileContains(String name, String contains)
-        throws IOException
-    {
-        String content = getFileString(name);
-        assertTrue(
-            "expecting file " + name + " to contain " + contains +
-            " but got " + content, content.indexOf(contains) > -1);
-    }
 
-    private void expectFileContains(
-        String target, String name, String contains)
-        throws IOException
-    {
-        executeTarget(target);
-        expectFileContains(name, contains);
-    }
 
     public static class CustomFilter implements ChainableReader {
         char replace = 'x';

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/EscapeUnicodeTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/EscapeUnicodeTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/EscapeUnicodeTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/EscapeUnicodeTest.java Fri Apr 18 21:00:38 2014
@@ -21,28 +21,30 @@ package org.apache.tools.ant.filters;
 import java.io.File;
 import java.io.IOException;
 
-import org.apache.tools.ant.BuildFileTest;
-import org.apache.tools.ant.util.FileUtils;
+import org.apache.tools.ant.BuildFileRule;
+import org.apache.tools.ant.FileUtilities;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
 
-/**
- */
-public class EscapeUnicodeTest extends BuildFileTest {
-    
-    private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
+import static org.junit.Assert.assertEquals;
 
-    public EscapeUnicodeTest(String name) {
-        super(name);
-    }
+public class EscapeUnicodeTest {
+
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/filters/build.xml");
+        buildRule.configureProject("src/etc/testcases/filters/build.xml");
     }
 
+    @Test
     public void testEscapeUnicode() throws IOException {
-        executeTarget("testEscapeUnicode");
-        File expected = FILE_UTILS.resolveFile(getProject().getBaseDir(), "expected/escapeunicode.test");
-        File result = new File(getProject().getProperty("output"), "escapeunicode.test");
-        assertTrue(FILE_UTILS.contentEquals(expected, result));
+        buildRule.executeTarget("testEscapeUnicode");
+        File expected = buildRule.getProject().resolveFile("expected/escapeunicode.test");
+        File result = new File(buildRule.getProject().getProperty("output"), "escapeunicode.test");
+        assertEquals(FileUtilities.getFileContents(expected), FileUtilities.getFileContents(result));
     }
 
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/HeadTailTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/HeadTailTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/HeadTailTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/HeadTailTest.java Fri Apr 18 21:00:38 2014
@@ -21,105 +21,117 @@ package org.apache.tools.ant.filters;
 import java.io.File;
 import java.io.IOException;
 
-import org.apache.tools.ant.BuildFileTest;
-import org.apache.tools.ant.util.FileUtils;
+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;
 
 /** JUnit Testcases for TailFilter and HeadFilter
  */
 /* I wrote the testcases in one java file because I want also to test the
  * combined behaviour (see end of the class).
 */
-public class HeadTailTest extends BuildFileTest {
+public class HeadTailTest {
 
-    private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
     
-    public HeadTailTest(String name) {
-        super(name);
-    }
-
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/filters/head-tail.xml");
+        buildRule.configureProject("src/etc/testcases/filters/head-tail.xml");
     }
 
+    @Test
     public void testHead() throws IOException {
-        executeTarget("testHead");
-        File expected = FILE_UTILS.resolveFile(getProject().getBaseDir(), "expected/head-tail.head.test");
-        File result = new File(getProject().getProperty("output") + "/head-tail.head.test");
-        assertTrue("testHead: Result not like expected", FILE_UTILS.contentEquals(expected, result));
+        buildRule.executeTarget("testHead");
+        File expected = buildRule.getProject().resolveFile("expected/head-tail.head.test");
+        File result = new File(buildRule.getProject().getProperty("output") + "/head-tail.head.test");
+        assertEquals("testHead: Result not like expected", FileUtilities.getFileContents(expected), FileUtilities.getFileContents(result));
     }
 
+    @Test
     public void testHeadLines() throws IOException {
-        executeTarget("testHeadLines");
-        File expected = FILE_UTILS.resolveFile(getProject().getBaseDir(), "expected/head-tail.headLines.test");
-        File result = new File(getProject().getProperty("output") + "/head-tail.headLines.test");
-        assertTrue("testHeadLines: Result not like expected", FILE_UTILS.contentEquals(expected, result));
+        buildRule.executeTarget("testHeadLines");
+        File expected = buildRule.getProject().resolveFile("expected/head-tail.headLines.test");
+        File result = new File(buildRule.getProject().getProperty("output") + "/head-tail.headLines.test");
+        assertEquals("testHeadLines: Result not like expected", FileUtilities.getFileContents(expected), FileUtilities.getFileContents(result));
     }
 
+    @Test
     public void testHeadSkip() throws IOException {
-        executeTarget("testHeadSkip");
-        File expected = FILE_UTILS.resolveFile(getProject().getBaseDir(),"expected/head-tail.headSkip.test");
-        File result = new File(getProject().getProperty("output") + "/head-tail.headSkip.test");
-        assertTrue("testHeadSkip: Result not like expected", FILE_UTILS.contentEquals(expected, result));
+        buildRule.executeTarget("testHeadSkip");
+        File expected = buildRule.getProject().resolveFile("expected/head-tail.headSkip.test");
+        File result = new File(buildRule.getProject().getProperty("output") + "/head-tail.headSkip.test");
+        assertEquals("testHeadSkip: Result not like expected", FileUtilities.getFileContents(expected), FileUtilities.getFileContents(result));
     }
 
+    @Test
     public void testHeadLinesSkip() throws IOException {
-        executeTarget("testHeadLinesSkip");
-        File expected = FILE_UTILS.resolveFile(getProject().getBaseDir(),"expected/head-tail.headLinesSkip.test");
-        File result = new File(getProject().getProperty("output") + "/head-tail.headLinesSkip.test");
-        assertTrue("testHeadLinesSkip: Result not like expected", FILE_UTILS.contentEquals(expected, result));
+        buildRule.executeTarget("testHeadLinesSkip");
+        File expected = buildRule.getProject().resolveFile("expected/head-tail.headLinesSkip.test");
+        File result = new File(buildRule.getProject().getProperty("output") + "/head-tail.headLinesSkip.test");
+        assertEquals("testHeadLinesSkip: Result not like expected", FileUtilities.getFileContents(expected), FileUtilities.getFileContents(result));
     }
 
+    @Test
     public void testFilterReaderHeadLinesSkip() throws IOException {
-        executeTarget("testFilterReaderHeadLinesSkip");
-        File expected = FILE_UTILS.resolveFile(getProject().getBaseDir(),
-            "expected/head-tail.headLinesSkip.test");
-        File result = new File(getProject().getProperty("output") + "/head-tail.filterReaderHeadLinesSkip.test");
-        assertTrue("testFilterReaderHeadLinesSkip: Result not like expected",
-                   FILE_UTILS.contentEquals(expected, result));
+        buildRule.executeTarget("testFilterReaderHeadLinesSkip");
+        File expected = buildRule.getProject().resolveFile("expected/head-tail.headLinesSkip.test");
+        File result = new File(buildRule.getProject().getProperty("output") + "/head-tail.filterReaderHeadLinesSkip.test");
+        assertEquals("testFilterReaderHeadLinesSkip: Result not like expected",
+                FileUtilities.getFileContents(expected), FileUtilities.getFileContents(result));
     }
 
+    @Test
     public void testTail() throws IOException {
-        executeTarget("testTail");
-        File expected = FILE_UTILS.resolveFile(getProject().getBaseDir(),"expected/head-tail.tail.test");
-        File result = new File(getProject().getProperty("output") + "/head-tail.tail.test");
-        assertTrue("testTail: Result not like expected", FILE_UTILS.contentEquals(expected, result));
+        buildRule.executeTarget("testTail");
+        File expected =buildRule.getProject().resolveFile("expected/head-tail.tail.test");
+        File result = new File(buildRule.getProject().getProperty("output") + "/head-tail.tail.test");
+        assertEquals("testTail: Result not like expected", FileUtilities.getFileContents(expected), FileUtilities.getFileContents(result));
     }
 
+    @Test
     public void testTailLines() throws IOException {
-        executeTarget("testTailLines");
-        File expected = FILE_UTILS.resolveFile(getProject().getBaseDir(),"expected/head-tail.tailLines.test");
-        File result = new File(getProject().getProperty("output") + "/head-tail.tailLines.test");
-        assertTrue("testTailLines: Result not like expected", FILE_UTILS.contentEquals(expected, result));
+        buildRule.executeTarget("testTailLines");
+        File expected = buildRule.getProject().resolveFile("expected/head-tail.tailLines.test");
+        File result = new File(buildRule.getProject().getProperty("output") + "/head-tail.tailLines.test");
+        assertEquals("testTailLines: Result not like expected", FileUtilities.getFileContents(expected), FileUtilities.getFileContents(result));
     }
 
+    @Test
     public void testTailSkip() throws IOException {
-        executeTarget("testTailSkip");
-        File expected = FILE_UTILS.resolveFile(getProject().getBaseDir(),"expected/head-tail.tailSkip.test");
-        File result = new File(getProject().getProperty("output") + "/head-tail.tailSkip.test");
-        assertTrue("testTailSkip: Result not like expected", FILE_UTILS.contentEquals(expected, result));
+        buildRule.executeTarget("testTailSkip");
+        File expected = buildRule.getProject().resolveFile("expected/head-tail.tailSkip.test");
+        File result = new File(buildRule.getProject().getProperty("output") + "/head-tail.tailSkip.test");
+        assertEquals("testTailSkip: Result not like expected", FileUtilities.getFileContents(expected), FileUtilities.getFileContents(result));
     }
 
+    @Test
     public void testTailLinesSkip() throws IOException {
-        executeTarget("testTailLinesSkip");
-        File expected = FILE_UTILS.resolveFile(getProject().getBaseDir(),"expected/head-tail.tailLinesSkip.test");
-        File result = new File(getProject().getProperty("output") + "/head-tail.tailLinesSkip.test");
-        assertTrue("testTailLinesSkip: Result not like expected", FILE_UTILS.contentEquals(expected, result));
+        buildRule.executeTarget("testTailLinesSkip");
+        File expected = buildRule.getProject().resolveFile("expected/head-tail.tailLinesSkip.test");
+        File result = new File(buildRule.getProject().getProperty("output") + "/head-tail.tailLinesSkip.test");
+        assertEquals("testTailLinesSkip: Result not like expected", FileUtilities.getFileContents(expected), FileUtilities.getFileContents(result));
     }
 
+    @Test
     public void testFilterReaderTailLinesSkip() throws IOException {
-        executeTarget("testFilterReaderTailLinesSkip");
-        File expected = FILE_UTILS.resolveFile(getProject().getBaseDir(),
-            "expected/head-tail.tailLinesSkip.test");
-        File result = new File(getProject().getProperty("output") + "/head-tail.filterReaderTailLinesSkip.test");
-        assertTrue("testFilterReaderTailLinesSkip: Result not like expected",
-                   FILE_UTILS.contentEquals(expected, result));
+        buildRule.executeTarget("testFilterReaderTailLinesSkip");
+        File expected = buildRule.getProject().resolveFile("expected/head-tail.tailLinesSkip.test");
+        File result = new File(buildRule.getProject().getProperty("output") + "/head-tail.filterReaderTailLinesSkip.test");
+        assertEquals("testFilterReaderTailLinesSkip: Result not like expected",
+                FileUtilities.getFileContents(expected), FileUtilities.getFileContents(result));
     }
 
+    @Test
     public void testHeadTail() throws IOException {
-        executeTarget("testHeadTail");
-        File expected = FILE_UTILS.resolveFile(getProject().getBaseDir(),"expected/head-tail.headtail.test");
-        File result = new File(getProject().getProperty("output") + "/head-tail.headtail.test");
-        assertTrue("testHeadTail: Result not like expected", FILE_UTILS.contentEquals(expected, result));
+        buildRule.executeTarget("testHeadTail");
+        File expected = buildRule.getProject().resolveFile("expected/head-tail.headtail.test");
+        File result = new File(buildRule.getProject().getProperty("output") + "/head-tail.headtail.test");
+        assertEquals("testHeadTail: Result not like expected", FileUtilities.getFileContents(expected), FileUtilities.getFileContents(result));
     }
 
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/LineContainsTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/LineContainsTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/LineContainsTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/LineContainsTest.java Fri Apr 18 21:00:38 2014
@@ -21,32 +21,37 @@ package org.apache.tools.ant.filters;
 import java.io.File;
 import java.io.IOException;
 
-import org.apache.tools.ant.BuildFileTest;
-import org.apache.tools.ant.util.FileUtils;
+import org.apache.tools.ant.BuildFileRule;
+import org.apache.tools.ant.FileUtilities;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
 
-/**
- */
-public class LineContainsTest extends BuildFileTest {
+import static org.junit.Assert.assertEquals;
 
-    private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
-    
-    public LineContainsTest(String name) {
-        super(name);
-    }
 
+public class LineContainsTest {
+
+
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
+    
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/filters/build.xml");
+        buildRule.configureProject("src/etc/testcases/filters/build.xml");
     }
 
+    @Test
     public void testLineContains() throws IOException {
-        executeTarget("testLineContains");
-        File expected = FILE_UTILS.resolveFile(getProject().getBaseDir(),"expected/linecontains.test");
-        File result = new File(getProject().getProperty("output"),"linecontains.test");
-        assertTrue(FILE_UTILS.contentEquals(expected, result));
+        buildRule.executeTarget("testLineContains");
+        File expected = buildRule.getProject().resolveFile("expected/linecontains.test");
+        File result = new File(buildRule.getProject().getProperty("output"),"linecontains.test");
+        assertEquals(FileUtilities.getFileContents(expected), FileUtilities.getFileContents(result));
     }
 
+    @Test
     public void testNegateLineContains() throws IOException {
-        executeTarget("testNegateLineContains");
+        buildRule.executeTarget("testNegateLineContains");
     }
 
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/NoNewLineTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/NoNewLineTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/NoNewLineTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/NoNewLineTest.java Fri Apr 18 21:00:38 2014
@@ -20,24 +20,29 @@ package org.apache.tools.ant.filters;
 
 import java.io.IOException;
 
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.BuildFileRule;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
 
 /** JUnit Testcases for No new line when filterchain used
  */
 
 
-public class NoNewLineTest extends BuildFileTest {
+public class NoNewLineTest  {
 
-    public NoNewLineTest(String name) {
-        super(name);
-    }
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/filters/build.xml");
+        buildRule.configureProject("src/etc/testcases/filters/build.xml");
     }
 
+
+    @Test
     public void testNoAddNewLine() throws IOException {
-        executeTarget("testNoAddNewLine");
+        buildRule.executeTarget("testNoAddNewLine");
     }
 
 

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/ReplaceTokensTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/ReplaceTokensTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/ReplaceTokensTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/ReplaceTokensTest.java Fri Apr 18 21:00:38 2014
@@ -21,35 +21,39 @@ package org.apache.tools.ant.filters;
 import java.io.File;
 import java.io.IOException;
 
-import org.apache.tools.ant.BuildFileTest;
-import org.apache.tools.ant.util.FileUtils;
+import org.apache.tools.ant.BuildFileRule;
+import org.apache.tools.ant.FileUtilities;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
 
-/**
- */
-public class ReplaceTokensTest extends BuildFileTest {
+import static org.junit.Assert.assertEquals;
 
-    private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
+public class ReplaceTokensTest {
 
-    public ReplaceTokensTest(String name) {
-        super(name);
-    }
 
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
+
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/filters/build.xml");
+        buildRule.configureProject("src/etc/testcases/filters/build.xml");
     }
 
+    @Test
     public void testReplaceTokens() throws IOException {
-        executeTarget("testReplaceTokens");
-        File expected = FILE_UTILS.resolveFile(getProject().getBaseDir(),"expected/replacetokens.test");
-        File result = new File(getProject().getProperty("output"), "replacetokens.test");
-        assertTrue(FILE_UTILS.contentEquals(expected, result));
+        buildRule.executeTarget("testReplaceTokens");
+        File expected = buildRule.getProject().resolveFile("expected/replacetokens.test");
+        File result = new File(buildRule.getProject().getProperty("output"), "replacetokens.test");
+       assertEquals(FileUtilities.getFileContents(expected), FileUtilities.getFileContents(result));
     }
 
+    @Test
     public void testReplaceTokensPropertyFile() throws IOException {
-        executeTarget("testReplaceTokensPropertyFile");
-        File expected = FILE_UTILS.resolveFile(getProjectDir(), "expected/replacetokens.test");
-        File result = new File(getProject().getProperty("output"), "replacetokensPropertyFile.test");
-        assertTrue(FILE_UTILS.contentEquals(expected, result));
+        buildRule.executeTarget("testReplaceTokensPropertyFile");
+        File expected = buildRule.getProject().resolveFile("expected/replacetokens.test");
+        File result = new File(buildRule.getProject().getProperty("output"), "replacetokensPropertyFile.test");
+        assertEquals(FileUtilities.getFileContents(expected), FileUtilities.getFileContents(result));
     }
 
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/StripJavaCommentsTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/StripJavaCommentsTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/StripJavaCommentsTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/StripJavaCommentsTest.java Fri Apr 18 21:00:38 2014
@@ -21,28 +21,31 @@ package org.apache.tools.ant.filters;
 import java.io.File;
 import java.io.IOException;
 
-import org.apache.tools.ant.BuildFileTest;
-import org.apache.tools.ant.util.FileUtils;
+import org.apache.tools.ant.BuildFileRule;
+import org.apache.tools.ant.FileUtilities;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
 
-/**
- */
-public class StripJavaCommentsTest extends BuildFileTest {
-    
-    private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
+import static org.junit.Assert.assertEquals;
 
-    public StripJavaCommentsTest(String name) {
-        super(name);
-    }
+public class StripJavaCommentsTest {
+
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/filters/build.xml");
+        buildRule.configureProject("src/etc/testcases/filters/build.xml");
     }
 
+
+    @Test
     public void testStripJavaComments() throws IOException {
-        executeTarget("testStripJavaComments");
-        File expected = FILE_UTILS.resolveFile(getProject().getBaseDir(),"expected/stripjavacomments.test");
-        File result = new File(getProject().getProperty("output"), "stripjavacomments.test");
-        assertTrue(FILE_UTILS.contentEquals(expected, result));
+        buildRule.executeTarget("testStripJavaComments");
+        File expected = buildRule.getProject().resolveFile("expected/stripjavacomments.test");
+        File result = new File(buildRule.getProject().getProperty("output"), "stripjavacomments.test");
+        assertEquals(FileUtilities.getFileContents(expected), FileUtilities.getFileContents(result));
     }
 
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/TokenFilterTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/TokenFilterTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/TokenFilterTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/TokenFilterTest.java Fri Apr 18 21:00:38 2014
@@ -18,265 +18,252 @@
 
 package org.apache.tools.ant.filters;
 
-import java.io.Reader;
+import static org.apache.tools.ant.AntAssert.assertContains;
+import static org.apache.tools.ant.AntAssert.assertNotContains;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 import java.io.FileReader;
 import java.io.IOException;
+import java.io.Reader;
 
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.BuildFileRule;
 import org.apache.tools.ant.util.FileUtils;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
 
 /**
  */
-public class TokenFilterTest extends BuildFileTest {
+public class TokenFilterTest {
+	
+	@Rule
+	public BuildFileRule buildRule = new BuildFileRule();
 
     private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
     
-    public TokenFilterTest(String name) {
-        super(name);
-    }
-
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/filters/tokenfilter.xml");
-        executeTarget("setUp");
+        buildRule.configureProject("src/etc/testcases/filters/tokenfilter.xml");
+        buildRule.executeTarget("setUp");
     }
 
     /** make sure tokenfilter exists */
+    @Test
     public void testTokenfilter() throws IOException {
-        executeTarget("tokenfilter");
+        buildRule.executeTarget("tokenfilter");
     }
 
+    @Test
     public void testTrimignore() throws IOException {
-        expectLogContaining("trimignore", "Hello-World");
+    	buildRule.executeTarget("trimignore");
+    	assertContains("Hello-World", buildRule.getLog());
     }
 
+    @Test
     public void testStringTokenizer() throws IOException {
-        expectLogContaining(
-            "stringtokenizer", "#This#is#a#number#of#words#");
+    	buildRule.executeTarget("stringtokenizer");
+        assertContains("#This#is#a#number#of#words#", buildRule.getLog());
     }
 
+    @Test
     public void testUnixLineOutput() throws IOException {
-        expectFileContains(
-            "unixlineoutput", getProject().getProperty("output") + "/unixlineoutput",
-            "\nThis\nis\na\nnumber\nof\nwords\n");
+    	buildRule.executeTarget("unixlineoutput");
+    	assertContains("\nThis\nis\na\nnumber\nof\nwords\n",
+                getFileString(buildRule.getProject().getProperty("output") + "/unixlineoutput"));
     }
 
+    @Test
     public void testDosLineOutput() throws IOException {
-        expectFileContains(
-            "doslineoutput", getProject().getProperty("output") + "/doslineoutput",
-            "\r\nThis\r\nis\r\na\r\nnumber\r\nof\r\nwords\r\n");
+
+        buildRule.executeTarget("doslineoutput");
+        assertContains("\r\nThis\r\nis\r\na\r\nnumber\r\nof\r\nwords\r\n",
+                getFileString(buildRule.getProject().getProperty("output") + "/doslineoutput"));
     }
 
+    @Test
     public void testFileTokenizer() throws IOException {
-        String contents = getFileString(
-            "filetokenizer", getProject().getProperty("output") + "/filetokenizer");
-        assertStringContains(contents, "   of words");
-        assertStringNotContains(contents, " This is");
+    	buildRule.executeTarget("filetokenizer");
+        String contents = getFileString(buildRule.getProject().getProperty("output") + "/filetokenizer");
+        assertContains("   of words", contents);
+        assertNotContains(" This is", contents);
     }
 
+    @Test
     public void testReplaceString() throws IOException {
-        expectFileContains(
-            "replacestring", getProject().getProperty("output") + "/replacestring",
-            "this is the moon");
+    	buildRule.executeTarget("replacestring");
+    	assertContains("this is the moon",
+                getFileString(buildRule.getProject().getProperty("output") + "/replacestring"));
     }
 
+    @Test
     public void testReplaceStrings() throws IOException {
-        expectLogContaining("replacestrings", "bar bar bar");
+    	buildRule.executeTarget("replacestrings");
+    	assertContains("bar bar bar", buildRule.getLog());
     }
 
+    @Test
     public void testContainsString() throws IOException {
-        String contents = getFileString(
-            "containsstring", getProject().getProperty("output") + "/containsstring");
-        assertStringContains(contents, "this is a line contains foo");
-        assertStringNotContains(contents, "this line does not");
+    	buildRule.executeTarget("containsstring");
+        String contents = getFileString(buildRule.getProject().getProperty("output") + "/containsstring");
+        assertContains("this is a line contains foo", contents);
+        assertNotContains("this line does not", contents);
     }
 
+    @Test
     public void testReplaceRegex() throws IOException {
-        if (! hasRegex("testReplaceRegex"))
-            return;
-        String contents = getFileString(
-            "replaceregex", getProject().getProperty("output") + "/replaceregex");
-        assertStringContains(contents, "world world world world");
-        assertStringContains(contents, "dog Cat dog");
-        assertStringContains(contents, "moon Sun Sun");
-        assertStringContains(contents, "found WhiteSpace");
-        assertStringContains(contents, "Found digits [1234]");
-        assertStringNotContains(contents, "This is a line with digits");
+
+    	buildRule.executeTarget("hasregex");
+        Assume.assumeTrue("Regex not present",
+                getFileString(buildRule.getProject().getProperty("output") + "/replaceregexp").contains("bye world"));
+
+        buildRule.executeTarget("replaceregex");
+        String contents = getFileString(buildRule.getProject().getProperty("output") + "/replaceregex");
+        assertContains("world world world world", contents);
+        assertContains("dog Cat dog", contents);
+        assertContains("moon Sun Sun", contents);
+        assertContains("found WhiteSpace", contents);
+        assertContains("Found digits [1234]", contents);
+        assertNotContains("This is a line with digits", contents);
     }
 
+    @Test
     public void testFilterReplaceRegex() throws IOException {
-        if (! hasRegex("testFilterReplaceRegex"))
-            return;
-        String contents = getFileString(
-            "filterreplaceregex", getProject().getProperty("output") + "/filterreplaceregex");
-        assertStringContains(contents, "world world world world");
+    	buildRule.executeTarget("hasregex");
+        Assume.assumeTrue("Regex not present",
+                getFileString(buildRule.getProject().getProperty("output") + "/replaceregexp").contains("bye world"));
+
+        buildRule.executeTarget("filterreplaceregex");
+        String contents = getFileString(buildRule.getProject().getProperty("output") + "/filterreplaceregex");
+        assertContains("world world world world", contents);
+
     }
 
+    @Test
     public void testHandleDollerMatch() throws IOException {
-        if (! hasRegex("testFilterReplaceRegex"))
-            return;
-        executeTarget("dollermatch");
+    	buildRule.executeTarget("hasregex");
+        Assume.assumeTrue("Regex not present", getFileString(buildRule.getProject().getProperty("output") + "/replaceregexp").contains("bye world"));
+
+        buildRule.executeTarget("dollermatch");
     }
 
+    @Test
     public void testTrimFile() throws IOException {
-        String contents = getFileString(
-            "trimfile", getProject().getProperty("output") + "/trimfile");
+    	buildRule.executeTarget("trimfile");
+        String contents = getFileString(buildRule.getProject().getProperty("output") + "/trimfile");
         assertTrue("no ws at start", contents.startsWith("This is th"));
         assertTrue("no ws at end", contents.endsWith("second line."));
-        assertStringContains(contents, "  This is the second");
+        assertContains("  This is the second", contents);
     }
 
+    @Test
     public void testTrimFileByLine() throws IOException {
-        String contents = getFileString(
-            "trimfilebyline", getProject().getProperty("output") + "/trimfilebyline");
+    	buildRule.executeTarget("trimfilebyline");
+        String contents = getFileString(buildRule.getProject().getProperty("output") + "/trimfilebyline");
         assertFalse("no ws at start", contents.startsWith("This is th"));
         assertFalse("no ws at end", contents.endsWith("second line."));
-        assertStringNotContains(contents, "  This is the second");
-        assertStringContains(contents, "file.\nThis is the second");
+        assertNotContains("  This is the second", contents);
+        assertContains("file.\nThis is the second", contents);
     }
 
+    @Test
     public void testFilterReplaceString() throws IOException {
-        String contents = getFileString(
-            "filterreplacestring", getProject().getProperty("output") + "/filterreplacestring");
-        assertStringContains(contents, "This is the moon");
+    	buildRule.executeTarget("filterreplacestring");
+        String contents = getFileString(buildRule.getProject().getProperty("output") + "/filterreplacestring");
+        assertContains("This is the moon", contents);
     }
 
+    @Test
     public void testFilterReplaceStrings() throws IOException {
-        expectLogContaining("filterreplacestrings", "bar bar bar");
+    	buildRule.executeTarget("filterreplacestrings");
+    	assertContains("bar bar bar", buildRule.getLog());
     }
 
+    @Test
     public void testContainsRegex() throws IOException {
-        if (! hasRegex("testContainsRegex"))
-            return;
-        String contents = getFileString(
-            "containsregex", getProject().getProperty("output") + "/containsregex");
-        assertStringContains(contents, "hello world");
-        assertStringNotContains(contents, "this is the moon");
-        assertStringContains(contents, "World here");
+    	buildRule.executeTarget("hasregex");
+        Assume.assumeTrue("Regex not present", getFileString(buildRule.getProject().getProperty("output") + "/replaceregexp").contains("bye world"));
+
+        //expectFileContains(buildRule.getProject().getProperty("output") + "/replaceregexp", "bye world");
+
+        buildRule.executeTarget("containsregex");
+        String contents = getFileString(buildRule.getProject().getProperty("output") + "/containsregex");
+        assertContains("hello world", contents);
+        assertNotContains("this is the moon", contents);
+        assertContains("World here", contents);
     }
 
+    @Test
     public void testFilterContainsRegex() throws IOException {
-        if (! hasRegex("testFilterContainsRegex"))
-            return;
-        String contents = getFileString(
-            "filtercontainsregex", getProject().getProperty("output") + "/filtercontainsregex");
-        assertStringContains(contents, "hello world");
-        assertStringNotContains(contents, "this is the moon");
-        assertStringContains(contents, "World here");
+    	buildRule.executeTarget("hasregex");
+        Assume.assumeTrue("Regex not present", getFileString(buildRule.getProject().getProperty("output") + "/replaceregexp").contains("bye world"));
+
+        buildRule.executeTarget("filtercontainsregex");
+        String contents = getFileString(buildRule.getProject().getProperty("output") + "/filtercontainsregex");
+        assertContains("hello world", contents);
+        assertNotContains("this is the moon", contents);
+        assertContains("World here", contents);
     }
 
+    @Test
     public void testContainsRegex2() throws IOException {
-        if (! hasRegex("testContainsRegex2"))
-            return;
-        String contents = getFileString(
-            "containsregex2", getProject().getProperty("output") + "/containsregex2");
-        assertStringContains(contents, "void register_bits();");
+    	buildRule.executeTarget("hasregex");
+        Assume.assumeTrue("Regex not present", getFileString(buildRule.getProject().getProperty("output") + "/replaceregexp").contains("bye world"));
+        
+        buildRule.executeTarget("containsregex2");
+        String contents = getFileString(buildRule.getProject().getProperty("output") + "/containsregex2");
+        assertContains("void register_bits();", contents);
     }
 
+    @Test
     public void testDeleteCharacters() throws IOException {
-        String contents = getFileString(
-            "deletecharacters", getProject().getProperty("output") + "/deletechars");
-        assertStringNotContains(contents, "#");
-        assertStringNotContains(contents, "*");
-        assertStringContains(contents, "This is some ");
+    	buildRule.executeTarget("deletecharacters");
+        String contents = getFileString(buildRule.getProject().getProperty("output") + "/deletechars");
+        assertNotContains("#", contents);
+        assertNotContains("*", contents);
+        assertContains("This is some ", contents);
     }
 
+    @Test
     public void testScriptFilter() throws IOException {
-        if (! hasScript("testScriptFilter"))
-            return;
+    	Assume.assumeTrue("Project does not have 'testScriptFilter' target",
+                buildRule.getProject().getTargets().contains("testScriptFilter"));
+    	buildRule.executeTarget("scriptfilter");
+    	assertContains("HELLO WORLD", getFileString(buildRule.getProject().getProperty("output") + "/scriptfilter"));
 
-        expectFileContains("scriptfilter", getProject().getProperty("output") + "/scriptfilter",
-                           "HELLO WORLD");
     }
 
-
+    @Test
     public void testScriptFilter2() throws IOException {
-        if (! hasScript("testScriptFilter"))
-            return;
-
-        expectFileContains("scriptfilter2", getProject().getProperty("output") + "/scriptfilter2",
-                           "HELLO MOON");
+    	Assume.assumeTrue("Project does not have 'testScriptFilter' target", buildRule.getProject().getTargets().contains("testScriptFilter"));
+        buildRule.executeTarget("scriptfilter2");
+    	assertContains("HELLO MOON", getFileString(buildRule.getProject().getProperty("output") + "/scriptfilter2"));
     }
 
+    @Test
     public void testCustomTokenFilter() throws IOException {
-        expectFileContains("customtokenfilter", getProject().getProperty("output") + "/custom",
-                           "Hello World");
+        buildRule.executeTarget("customtokenfilter");
+    	assertContains("Hello World", getFileString(buildRule.getProject().getProperty("output") + "/custom"));
     }
 
     // ------------------------------------------------------
     //   Helper methods
     // -----------------------------------------------------
-    private boolean hasScript(String test) {
-        try {
-            executeTarget("hasscript");
-        }
-        catch (Throwable ex) {
-            System.out.println(
-                test + ": skipped - script not present ");
-            return false;
-        }
-        return true;
-    }
-
-    private boolean hasRegex(String test) {
-        try {
-            executeTarget("hasregex");
-            expectFileContains(getProject().getProperty("output") + "/replaceregexp", "bye world");
-        }
-        catch (Throwable ex) {
-            System.out.println(test + ": skipped - regex not present "
-                               + ex);
-            return false;
-        }
-        return true;
-    }
-
-    private void assertStringContains(String string, String contains) {
-        assertTrue("[" + string + "] does not contain [" + contains +"]",
-                   string.indexOf(contains) > -1);
-    }
-
-    private void assertStringNotContains(String string, String contains) {
-        assertTrue("[" + string + "] does contain [" + contains +"]",
-                   string.indexOf(contains) == -1);
-    }
 
     private String getFileString(String filename)
         throws IOException
     {
         Reader r = null;
         try {
-            r = new FileReader(FILE_UTILS.resolveFile(getProject().getBaseDir(),filename));
+            r = new FileReader(FILE_UTILS.resolveFile(buildRule.getProject().getBaseDir(),filename));
             return  FileUtils.readFully(r);
         }
         finally {
             FileUtils.close(r);
         }
-
-    }
-
-    private String getFileString(String target, String filename)
-        throws IOException
-    {
-        executeTarget(target);
-        return getFileString(filename);
-    }
-
-    private void expectFileContains(String name, String contains)
-        throws IOException
-    {
-        String content = getFileString(name);
-        assertTrue(
-            "expecting file " + name + " to contain " + contains +
-            " but got " + content, content.indexOf(contains) > -1);
     }
 
-    private void expectFileContains(
-        String target, String name, String contains)
-        throws IOException
-    {
-        executeTarget(target);
-        expectFileContains(name, contains);
-    }
 
     public static class Capitalize
         implements TokenFilter.Filter

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/launch/LocatorTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/launch/LocatorTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/launch/LocatorTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/launch/LocatorTest.java Fri Apr 18 21:00:38 2014
@@ -17,39 +17,27 @@
  */
 package org.apache.tools.ant.launch;
 
-import junit.framework.TestCase;
-
 import java.io.File;
 
 import org.apache.tools.ant.taskdefs.condition.Os;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import static junit.framework.Assert.assertEquals;
+import static org.apache.tools.ant.AntAssert.assertContains;
+import static org.junit.Assert.fail;
 
 /** Test the locator in the ant-launch JAR */
-public class LocatorTest extends TestCase {
+public class LocatorTest {
     private boolean windows;
     private boolean unix;
     private static final String LAUNCHER_JAR = "//morzine/slo/Java/Apache/ant/lib/ant-launcher.jar";
     private static final String SHARED_JAR_URI = "jar:file:"+ LAUNCHER_JAR +"!/org/apache/tools/ant/launch/Launcher.class";
 
-    /**
-     * No-arg constructor to enable serialization. This method is not intended to be used by mere mortals without calling
-     * setName().
-     */
-    public LocatorTest() {
-    }
-
-    /** Constructs a test case with the given name.
-     * @param name
-     */
-    public LocatorTest(String name) {
-        super(name);
-    }
 
-    /**
-     * Sets up the fixture, for example, open a network connection.
-     * This method is called before a test is executed.
-     */
-    protected void setUp() throws Exception {
-        super.setUp();
+    @Before
+    public void setUp() throws Exception {
         windows = Os.isFamily(Os.FAMILY_DOS);
         unix = Os.isFamily(Os.FAMILY_UNIX);
     }
@@ -105,26 +93,27 @@ public class LocatorTest extends TestCas
                 "\\\\PC03\\jclasses\\lib\\ant-1.7.0.jar");
     }
 
-    /**
-     * This is not being tested as we don't appear to generate paths like this in the launcher
-     * @throws Exception
-     */
-    public void NotestTripleForwardSlashNetworkURI() throws Exception {
+    @Ignore("We don't appear to generate paths like this in the launcher")
+    @Test
+    public void testTripleForwardSlashNetworkURI() throws Exception {
         resolveTo("file:///PC03/jclasses/lib/ant-1.7.0.jar",
                 "///PC03/jclasses/lib/ant-1.7.0.jar",
                 "\\\\PC03\\jclasses\\lib\\ant-1.7.0.jar");
     }
 
+    @Test
     public void testUnixNetworkPath() throws Exception {
         resolveTo("file://cluster/home/ant/lib",
                 "//cluster/home/ant/lib",
                 "\\\\cluster\\home\\ant\\lib");
     }
 
+    @Test
     public void testUnixPath() throws Exception {
         resolveTo("file:/home/ant/lib", "/home/ant/lib", null);
     }
 
+    @Test
     public void testSpacedURI() throws Exception {
         resolveTo("file:C:\\Program Files\\Ant\\lib",
                 "C:\\Program Files\\Ant\\lib",
@@ -135,6 +124,7 @@ public class LocatorTest extends TestCas
      * Bug 42275; Ant failing to run off a remote share
      * @throws Throwable if desired
      */
+    @Test
     public void testAntOnRemoteShare() throws Throwable {
         String resolved=Locator.fromJarURI(SHARED_JAR_URI);
         assertResolved(SHARED_JAR_URI, LAUNCHER_JAR, resolved, unix);
@@ -147,6 +137,7 @@ public class LocatorTest extends TestCas
      *
      * @throws Throwable if desired
      */
+    @Test
     public void testFileFromRemoteShare() throws Throwable {
         String resolved = Locator.fromJarURI(SHARED_JAR_URI);
         File f = new File(resolved);
@@ -156,17 +147,20 @@ public class LocatorTest extends TestCas
         }
     }
 
+    @Test
     public void testHttpURI() throws Exception {
         String url = "http://ant.apache.org";
         try {
             Locator.fromURI(url);
+            fail("Exception should have been thrown");
         } catch (IllegalArgumentException e) {
             String message = e.getMessage();
-            assertTrue(message, message.indexOf(Locator.ERROR_NOT_FILE_URI) >= 0);
-            assertTrue(message, message.indexOf(url) >= 0);
+            assertContains(Locator.ERROR_NOT_FILE_URI, message);
+            assertContains(url, message);
         }
     }
 
+    @Test
     public void testInternationalURI() throws Exception {
         String result = assertResolves("L\u00f6wenbrau.aus.M\u00fcnchen");
         char umlauted = result.charAt(1);
@@ -178,6 +172,7 @@ public class LocatorTest extends TestCas
         assertEquals("file:/tmp/hezky \u010Desky", Locator.decodeUri("file:/tmp/hezky%20\u010Desky")); // non-ISO-8859-1 variant
     }
 
+    @Test
     public void testOddLowAsciiURI() throws Exception {
         assertResolves("hash# and percent%");
     }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/loader/AntClassLoader5Test.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/loader/AntClassLoader5Test.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/loader/AntClassLoader5Test.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/loader/AntClassLoader5Test.java Fri Apr 18 21:00:38 2014
@@ -21,19 +21,26 @@ package org.apache.tools.ant.loader;
 import java.io.IOException;
 import java.net.URL;
 import java.util.Enumeration;
-import junit.framework.TestCase;
 import org.apache.tools.ant.AntClassLoader;
 import org.apache.tools.ant.types.Path;
 import org.apache.tools.ant.util.CollectionUtils;
+import org.junit.Test;
 
-public class AntClassLoader5Test extends TestCase {
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+public class AntClassLoader5Test {
 
     /**
      * Asserts that getResources won't return resources that cannot be
      * seen by AntClassLoader but by ClassLoader.this.parent.
      *
-     * @see https://issues.apache.org/bugzilla/show_bug.cgi?id=46752
+     * @see <a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=46752">
+     *     https://issues.apache.org/bugzilla/show_bug.cgi?id=46752</a>
      */
+    @Test
     public void testGetResources() throws IOException {
         AntClassLoader acl = new AntClassLoader5(new EmptyLoader(), null,
                                                  new Path(null), true);
@@ -46,6 +53,7 @@ public class AntClassLoader5Test extends
         assertTrue(acl.getResources("META-INF/MANIFEST.MF").hasMoreElements());
     }
 
+    @Test
     public void testGetResourcesUsingFactory() throws IOException {
         AntClassLoader acl =
             AntClassLoader.newAntClassLoader(new EmptyLoader(), null,

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AbstractCvsTaskTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AbstractCvsTaskTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AbstractCvsTaskTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AbstractCvsTaskTest.java Fri Apr 18 21:00:38 2014
@@ -17,38 +17,55 @@
  */
 package org.apache.tools.ant.taskdefs;
 
+import org.apache.tools.ant.AntAssert;
+import org.apache.tools.ant.BuildFileRule;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
 import java.io.File;
 
-import org.apache.tools.ant.BuildFileTest;
+import static org.junit.Assert.assertTrue;
 
 /**
  */
-public class AbstractCvsTaskTest extends BuildFileTest {
+public class AbstractCvsTaskTest {
+
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
-    public AbstractCvsTaskTest() {
-        this( "AbstractCvsTaskTest" );
+    @Before
+    public void setUp() {
+        buildRule.configureProject("src/etc/testcases/taskdefs/abstractcvstask.xml");
+        buildRule.executeTarget("setUp");
     }
 
-    public AbstractCvsTaskTest(String name) {
-        super(name);
+    @After
+    public void tearDown() {
+        buildRule.executeTarget("cleanup");
     }
 
-    public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/abstractcvstask.xml");
-        executeTarget("setUp");
+    @Test
+    public void testAbstractCvsTask() {
+        buildRule.executeTarget("all");
     }
 
+    @Test
     public void testPackageAttribute() {
-        File f = new File(getProject().getProperty("output") + "/src/Makefile");
+        File f = new File(buildRule.getProject().getProperty("output") + "/src/Makefile");
         assertTrue("starting empty", !f.exists());
-        expectLogContaining("package-attribute", "U src/Makefile");
+        buildRule.executeTarget("package-attribute");
+        AntAssert.assertContains("U src/Makefile", buildRule.getLog());
         assertTrue("now it is there", f.exists());
     }
 
+    @Test
     public void testTagAttribute() {
-        File f = new File(getProject().getProperty("output") + "/src/Makefile");
+        File f = new File(buildRule.getProject().getProperty("output") + "/src/Makefile");
         assertTrue("starting empty", !f.exists());
-        expectLogContaining("tag-attribute", "OPENBSD_5_3");
+        buildRule.executeTarget("tag-attribute");
+        AntAssert.assertContains("OPENBSD_5_3", buildRule.getLog());
         assertTrue("now it is there", f.exists());
     }
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AntLikeTasksAtTopLevelTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AntLikeTasksAtTopLevelTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AntLikeTasksAtTopLevelTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AntLikeTasksAtTopLevelTest.java Fri Apr 18 21:00:38 2014
@@ -19,19 +19,25 @@
 package org.apache.tools.ant.taskdefs;
 
 import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.BuildFileRule;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
 
 /**
  * @since Ant 1.6
  */
-public class AntLikeTasksAtTopLevelTest extends BuildFileTest {
-    public AntLikeTasksAtTopLevelTest(String name) {
-        super(name);
-    }
+public class AntLikeTasksAtTopLevelTest {
+
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
+    @Test
     public void testAnt() {
         try {
-            configureProject("src/etc/testcases/taskdefs/toplevelant.xml");
+            buildRule.configureProject("src/etc/testcases/taskdefs/toplevelant.xml");
             fail("no exception thrown");
         } catch (BuildException e) {
             assertEquals("ant task at the top level must not invoke its own"
@@ -39,9 +45,10 @@ public class AntLikeTasksAtTopLevelTest 
         }
     }
 
+    @Test
     public void testSubant() {
         try {
-            configureProject("src/etc/testcases/taskdefs/toplevelsubant.xml");
+            buildRule.configureProject("src/etc/testcases/taskdefs/toplevelsubant.xml");
             fail("no exception thrown");
         } catch (BuildException e) {
             assertEquals("subant task at the top level must not invoke its own"
@@ -49,9 +56,10 @@ public class AntLikeTasksAtTopLevelTest 
         }
     }
 
+    @Test
     public void testAntcall() {
         try {
-            configureProject("src/etc/testcases/taskdefs/toplevelantcall.xml");
+            buildRule.configureProject("src/etc/testcases/taskdefs/toplevelantcall.xml");
             fail("no exception thrown");
         } catch (BuildException e) {
             assertEquals("antcall must not be used at the top level.",

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AntStructureTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AntStructureTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AntStructureTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AntStructureTest.java Fri Apr 18 21:00:38 2014
@@ -18,40 +18,57 @@
 
 package org.apache.tools.ant.taskdefs;
 
+import org.apache.tools.ant.AntAssert;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
+import org.apache.tools.ant.Project;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
 import java.io.PrintWriter;
 import java.util.Hashtable;
-import junit.framework.Assert;
-import org.apache.tools.ant.BuildFileTest;
-import org.apache.tools.ant.Project;
+
+import static org.junit.Assert.fail;
 
 /**
  */
-public class AntStructureTest extends BuildFileTest {
+public class AntStructureTest {
 
-    public AntStructureTest(String name) {
-        super(name);
-    }
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/antstructure.xml");
+        buildRule.configureProject("src/etc/testcases/taskdefs/antstructure.xml");
     }
 
+    @After
     public void tearDown() {
-        executeTarget("tearDown");
+        buildRule.executeTarget("tearDown");
     }
 
+    @Test
     public void test1() {
-        expectBuildException("test1", "required argument not specified");
+        try {
+            buildRule.executeTarget("test1");
+            fail("required argument not specified");
+        } catch (BuildException ex) {
+            //TODO assert exception message
+        }
     }
 
+    @Test
     public void testCustomPrinter() {
-        executeTarget("testCustomPrinter");
+        buildRule.executeTarget("testCustomPrinter");
         // can't access the booleans in MyPrinter here (even if they
         // were static) since the MyPrinter instance that was used in
         // the test has likely been loaded via a different classloader
         // than this class.  Therefore we make the printer assert its
         // state and only check for the tail invocation.
-        assertLogContaining(MyPrinter.TAIL_CALLED);
+        AntAssert.assertContains(MyPrinter.TAIL_CALLED, buildRule.getLog());
     }
 
     public static class MyPrinter implements AntStructure.StructurePrinter {

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java Fri Apr 18 21:00:38 2014
@@ -22,94 +22,145 @@ import java.io.File;
 
 import junit.framework.AssertionFailedError;
 
+import org.apache.tools.ant.AntAssert;
 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.apache.tools.ant.input.InputHandler;
 import org.apache.tools.ant.input.PropertyFileInputHandler;
 import org.apache.tools.ant.types.Path;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+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;
 
 /**
  */
-public class AntTest extends BuildFileTest {
-
-    public AntTest(String name) {
-        super(name);
-    }
+public class AntTest {
+    
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/ant.xml");
+        buildRule.configureProject("src/etc/testcases/taskdefs/ant.xml");
     }
 
+    @After
     public void tearDown() {
-        executeTarget("cleanup");
+        buildRule.executeTarget("cleanup");
     }
 
+    @Test
     public void test1() {
-        expectBuildException("test1", "recursive call");
+        try {
+            buildRule.executeTarget("test1");
+            fail("recursive call");
+        } catch(BuildException ex) {
+            //TODO assert exception message
+        }
     }
 
     // target must be specified
+    @Test
     public void test2() {
-        expectBuildException("test2", "required argument not specified");
+        try {
+            buildRule.executeTarget("test2");
+            fail("required argument not specified");
+        } catch(BuildException ex) {
+            //TODO assert exception message
+        }
     }
 
     // Should fail since a recursion will occur...
+    @Test
     public void test3() {
-        expectBuildException("test1", "recursive call");
+        try {
+            buildRule.executeTarget("test1");
+            fail("recursive call");
+        } catch(BuildException ex) {
+            //TODO assert exception message
+        }
     }
 
+    @Test
     public void test4() {
-        expectBuildException("test4", "target attribute must not be empty");
+        try {
+            buildRule.executeTarget("test4");
+            fail("target attribute must not be empty");
+        } catch (BuildException ex) {
+            //TODO assert exception message
+        }
     }
 
+    @Test
     public void test4b() {
-        expectBuildException("test4b", "target doesn't exist");
+        try {
+            buildRule.executeTarget("test4b");
+            fail("target doesn't exist");
+        } catch(BuildException ex) {
+            //TODO assert exception message
+        }
     }
 
+    @Test
     public void test5() {
-        executeTarget("test5");
+        buildRule.executeTarget("test5");
     }
 
+    @Test
     public void test6() {
-        executeTarget("test6");
+        buildRule.executeTarget("test6");
     }
 
+    @Test
     public void testExplicitBasedir1() {
-        File dir1 = getProjectDir();
-        File dir2 = project.resolveFile("..");
+        File dir1 = buildRule.getProject().getBaseDir();
+        File dir2 = buildRule.getProject().resolveFile("..");
         testBaseDirs("explicitBasedir1",
                      new String[] {dir1.getAbsolutePath(),
                                    dir2.getAbsolutePath()
                      });
     }
 
+    @Test
     public void testExplicitBasedir2() {
-        File dir1 = getProjectDir();
-        File dir2 = project.resolveFile("..");
+        File dir1 = buildRule.getProject().getBaseDir();
+        File dir2 = buildRule.getProject().resolveFile("..");
         testBaseDirs("explicitBasedir2",
                      new String[] {dir1.getAbsolutePath(),
                                    dir2.getAbsolutePath()
                      });
     }
 
+    @Test
     public void testInheritBasedir() {
-        String basedir = getProjectDir().getAbsolutePath();
+        String basedir = buildRule.getProject().getBaseDir().getAbsolutePath();
         testBaseDirs("inheritBasedir", new String[] {basedir, basedir});
     }
 
+    @Test
     public void testDoNotInheritBasedir() {
-        File dir1 = getProjectDir();
-        File dir2 = project.resolveFile("ant");
+        File dir1 = buildRule.getProject().getBaseDir();
+        File dir2 = buildRule.getProject().resolveFile("ant");
         testBaseDirs("doNotInheritBasedir",
                      new String[] {dir1.getAbsolutePath(),
                                    dir2.getAbsolutePath()
                      });
     }
 
+    @Test
     public void testBasedirTripleCall() {
-        File dir1 = getProjectDir();
-        File dir2 = project.resolveFile("ant");
+        File dir1 = buildRule.getProject().getBaseDir();
+        File dir2 = buildRule.getProject().resolveFile("ant");
         testBaseDirs("tripleCall",
                      new String[] {dir1.getAbsolutePath(),
                                    dir2.getAbsolutePath(),
@@ -119,20 +170,21 @@ public class AntTest extends BuildFileTe
 
     protected void testBaseDirs(String target, String[] dirs) {
         BasedirChecker bc = new 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);
     }
 
+    @Test
     public void testReferenceInheritance() {
         Path p = Path.systemClasspath;
-        p.setProject(project);
-        project.addReference("path", p);
-        project.addReference("no-override", p);
+        p.setProject(buildRule.getProject());
+        buildRule.getProject().addReference("path", p);
+        buildRule.getProject().addReference("no-override", p);
         testReference("testInherit", new String[] {"path", "path"},
                       new boolean[] {true, true}, p);
         testReference("testInherit",
@@ -143,11 +195,12 @@ public class AntTest extends BuildFileTe
                       new boolean[] {false, false}, null);
     }
 
+    @Test
     public void testReferenceNoInheritance() {
         Path p = Path.systemClasspath;
-        p.setProject(project);
-        project.addReference("path", p);
-        project.addReference("no-override", p);
+        p.setProject(buildRule.getProject());
+        buildRule.getProject().addReference("path", p);
+        buildRule.getProject().addReference("no-override", p);
         testReference("testNoInherit", new String[] {"path", "path"},
                       new boolean[] {true, false}, p);
         testReference("testNoInherit", new String[] {"path", "path"},
@@ -160,10 +213,11 @@ public class AntTest extends BuildFileTe
                       new boolean[] {false, false}, null);
     }
 
+    @Test
     public void testReferenceRename() {
         Path p = Path.systemClasspath;
-        p.setProject(project);
-        project.addReference("path", p);
+        p.setProject(buildRule.getProject());
+        buildRule.getProject().addReference("path", p);
         testReference("testRename", new String[] {"path", "path"},
                       new boolean[] {true, false}, p);
         testReference("testRename", new String[] {"path", "path"},
@@ -172,35 +226,37 @@ public class AntTest extends BuildFileTe
                       new boolean[] {false, true}, p);
     }
 
+    @Test
     public void testInheritPath() {
-        executeTarget("testInheritPath");
+        buildRule.executeTarget("testInheritPath");
     }
 
     protected void testReference(String target, String[] keys,
                                  boolean[] expect, Object value) {
         ReferenceChecker rc = new ReferenceChecker(keys, expect, value);
-        project.addBuildListener(rc);
-        executeTarget(target);
+        buildRule.getProject().addBuildListener(rc);
+        buildRule.executeTarget(target);
         AssertionFailedError ae = rc.getError();
         if (ae != null) {
             throw ae;
         }
-        project.removeBuildListener(rc);
+        buildRule.getProject().removeBuildListener(rc);
     }
 
+    @Test
     public void testLogfilePlacement() {
         File[] logFiles = new File[] {
-            getProject().resolveFile("test1.log"),
-            getProject().resolveFile("test2.log"),
-            getProject().resolveFile("ant/test3.log"),
-            getProject().resolveFile("ant/test4.log")
+            buildRule.getProject().resolveFile("test1.log"),
+            buildRule.getProject().resolveFile("test2.log"),
+            buildRule.getProject().resolveFile("ant/test3.log"),
+            buildRule.getProject().resolveFile("ant/test4.log")
         };
         for (int i=0; i<logFiles.length; i++) {
             assertTrue(logFiles[i].getName()+" doesn\'t exist",
                        !logFiles[i].exists());
         }
 
-        executeTarget("testLogfilePlacement");
+        buildRule.executeTarget("testLogfilePlacement");
 
         for (int i=0; i<logFiles.length; i++) {
             assertTrue(logFiles[i].getName()+" exists",
@@ -208,84 +264,106 @@ public class AntTest extends BuildFileTe
         }
     }
 
+    @Test
     public void testInputHandlerInheritance() {
         InputHandler ih = new PropertyFileInputHandler();
-        getProject().setInputHandler(ih);
+        buildRule.getProject().setInputHandler(ih);
         InputHandlerChecker ic = new InputHandlerChecker(ih);
-        getProject().addBuildListener(ic);
-        executeTarget("tripleCall");
+        buildRule.getProject().addBuildListener(ic);
+        buildRule.executeTarget("tripleCall");
         AssertionFailedError ae = ic.getError();
         if (ae != null) {
             throw ae;
         }
-        getProject().removeBuildListener(ic);
+        buildRule.getProject().removeBuildListener(ic);
     }
 
+    @Test
     public void testRefId() {
-        Path testPath = new Path(project);
+        Path testPath = new Path(buildRule.getProject());
         testPath.createPath().setPath(System.getProperty("java.class.path"));
         PropertyChecker pc =
             new PropertyChecker("testprop",
                                 new String[] {null,
                                               testPath.toString()});
-        project.addBuildListener(pc);
-        executeTarget("testRefid");
+        buildRule.getProject().addBuildListener(pc);
+        buildRule.executeTarget("testRefid");
         AssertionFailedError ae = pc.getError();
         if (ae != null) {
             throw ae;
         }
-        project.removeBuildListener(pc);
+        buildRule.getProject().removeBuildListener(pc);
     }
 
+    @Test
     public void testUserPropertyWinsInheritAll() {
-        getProject().setUserProperty("test", "7");
-        expectLogContaining("test-property-override-inheritall-start",
-                            "The value of test is 7");
+        buildRule.getProject().setUserProperty("test", "7");
+        buildRule.executeTarget("test-property-override-inheritall-start");
+
+        AntAssert.assertContains("The value of test is 7", buildRule.getLog());
     }
 
+    @Test
     public void testUserPropertyWinsNoInheritAll() {
-        getProject().setUserProperty("test", "7");
-        expectLogContaining("test-property-override-no-inheritall-start",
-                            "The value of test is 7");
+        buildRule.getProject().setUserProperty("test", "7");
+        buildRule.executeTarget("test-property-override-no-inheritall-start");
+
+        AntAssert.assertContains("The value of test is 7", buildRule.getLog());
     }
 
+    @Test
     public void testOverrideWinsInheritAll() {
-        expectLogContaining("test-property-override-inheritall-start",
-                            "The value of test is 4");
+        buildRule.executeTarget("test-property-override-inheritall-start");
+
+        AntAssert.assertContains("The value of test is 4", buildRule.getLog());
     }
 
+    @Test
     public void testOverrideWinsNoInheritAll() {
-        expectLogContaining("test-property-override-no-inheritall-start",
-                            "The value of test is 4");
+        buildRule.executeTarget("test-property-override-no-inheritall-start");
+        AntAssert.assertContains("The value of test is 4", buildRule.getLog());
     }
 
+    @Test
     public void testPropertySet() {
-        executeTarget("test-propertyset");
-        assertTrue(getLog().indexOf("test1 is ${test1}") > -1);
-        assertTrue(getLog().indexOf("test2 is ${test2}") > -1);
-        assertTrue(getLog().indexOf("test1.x is 1") > -1);
+        buildRule.executeTarget("test-propertyset");
+        assertTrue(buildRule.getLog().indexOf("test1 is ${test1}") > -1);
+        assertTrue(buildRule.getLog().indexOf("test2 is ${test2}") > -1);
+        assertTrue(buildRule.getLog().indexOf("test1.x is 1") > -1);
     }
 
+    @Test
     public void testInfiniteLoopViaDepends() {
-        expectBuildException("infinite-loop-via-depends", "recursive call");
+        try {
+            buildRule.executeTarget("infinite-loop-via-depends");
+            fail("recursive call");
+        } catch(BuildException ex) {
+            //TODO assert exception message
+        }
     }
 
+    @Test
     public void testMultiSameProperty() {
-        expectLog("multi-same-property", "prop is two");
+        buildRule.executeTarget("multi-same-property");
+        assertEquals("prop is two", buildRule.getLog());
     }
 
+    @Test
     public void testTopLevelTarget() {
-        expectLog("topleveltarget", "Hello world");
+        buildRule.executeTarget("topleveltarget");
+
+        assertEquals("Hello world", buildRule.getLog());
     }
 
+    @Test
     public void testMultiplePropertyFileChildren() {
         PropertyChecker pcBar = new PropertyChecker("bar",
                                                     new String[] {null, "Bar"});
         PropertyChecker pcFoo = new PropertyChecker("foo",
                                                     new String[] {null, "Foo"});
-        project.addBuildListener(pcBar);
-        project.addBuildListener(pcFoo);
-        executeTarget("multiple-property-file-children");
+        buildRule.getProject().addBuildListener(pcBar);
+        buildRule.getProject().addBuildListener(pcFoo);
+        buildRule.executeTarget("multiple-property-file-children");
         AssertionFailedError aeBar = pcBar.getError();
         if (aeBar != null) {
             throw aeBar;
@@ -294,26 +372,37 @@ public class AntTest extends BuildFileTe
         if (aeFoo != null) {
             throw aeFoo;
         }
-        project.removeBuildListener(pcBar);
-        project.removeBuildListener(pcFoo);
+        buildRule.getProject().removeBuildListener(pcBar);
+        buildRule.getProject().removeBuildListener(pcFoo);
     }
 
+    @Test
     public void testBlankTarget() {
-        expectBuildException("blank-target", "target name must not be empty");
+        try {
+            buildRule.executeTarget("blank-target");
+            fail("target name must not be empty");
+        } catch(BuildException ex) {
+            //TODO assert exception message
+        }
     }
 
+    @Test
     public void testMultipleTargets() {
-        expectLog("multiple-targets", "tadadctbdbtc");
+        buildRule.executeTarget("multiple-targets");
+        assertEquals("tadadctbdbtc", buildRule.getLog());
     }
 
+    @Test
     public void testMultipleTargets2() {
-        expectLog("multiple-targets-2", "dadctb");
+        buildRule.executeTarget("multiple-targets-2");
+        assertEquals("dadctb", buildRule.getLog());
     }
 
+    @Test
     public void testAntCoreLib() {
         // Cf. #42263
-        executeTarget("sub-show-ant.core.lib");
-        String realLog = getLog();
+        buildRule.executeTarget("sub-show-ant.core.lib");
+        String realLog = buildRule.getLog();
         assertTrue("found ant.core.lib in: " + realLog, realLog.matches(".*(ant[.]jar|build.classes).*"));
     }
 

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AntlibTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AntlibTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AntlibTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AntlibTest.java Fri Apr 18 21:00:38 2014
@@ -18,19 +18,26 @@
 
 package org.apache.tools.ant.taskdefs;
 
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.BuildFileRule;
 import org.apache.tools.ant.Task;
 import org.apache.tools.ant.Project;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
 
 /**
  */
-public class AntlibTest extends BuildFileTest {
-    public AntlibTest(String name) {
-        super(name);
-    }
+public class AntlibTest {
 
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
+
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/antlib.xml");
+        buildRule.configureProject("src/etc/testcases/taskdefs/antlib.xml");
     }
 
     /**
@@ -42,8 +49,10 @@ public class AntlibTest extends BuildFil
         return property!=null && Project.toBoolean(property);
     }
 
+    @Test
     public void testAntlibFile() {
-        expectLog("antlib.file", "MyTask called");
+        buildRule.executeTarget("antlib.file");
+        assertEquals("MyTask called", buildRule.getLog());
     }
 
     /**
@@ -51,31 +60,34 @@ public class AntlibTest extends BuildFil
      * can collect several antlibs in one Definer call.
      * @see "http://issues.apache.org/bugzilla/show_bug.cgi?id=24024"
      */
+    @Test
     public void testAntlibResource() {
-        expectLog("antlib.resource", "MyTask called-and-then-MyTask2 called");
+        buildRule.executeTarget("antlib.resource");
+        assertEquals("MyTask called-and-then-MyTask2 called", buildRule.getLog());
     }
 
+    @Test
     public void testNsCurrent() {
-        expectLog("ns.current", "Echo2 inside a macroHello from x:p");
+        buildRule.executeTarget("ns.current");
+        assertEquals("Echo2 inside a macroHello from x:p", buildRule.getLog());
     }
 
-
+    @Test
     public void testAntlib_uri() {
-        if (isSharedJVM()) {
-            executeTarget("antlib_uri");
-        }
+        Assume.assumeTrue("Test requires shared JVM", isSharedJVM());
+        buildRule.executeTarget("antlib_uri");
     }
 
+    @Test
     public void testAntlib_uri_auto() {
-        if (isSharedJVM()) {
-            executeTarget("antlib_uri_auto");
-        }
+        Assume.assumeTrue("Test requires shared JVM", isSharedJVM());
+        buildRule.executeTarget("antlib_uri_auto");
     }
 
+    @Test
     public void testAntlib_uri_auto2() {
-        if (isSharedJVM()) {
-            executeTarget("antlib_uri_auto2");
-        }
+        Assume.assumeTrue("Test requires shared JVM", isSharedJVM());
+        buildRule.executeTarget("antlib_uri_auto2");
     }
     
     public static class MyTask extends Task {