ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcla...@apache.org
Subject svn commit: r1588563 [11/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/taskde...
Date Fri, 18 Apr 2014 21:00:43 GMT
Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTest.java Fri Apr 18 21:00:38 2014
@@ -18,80 +18,82 @@
 
 package org.apache.tools.ant.taskdefs.optional.jdepend;
 
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.AntAssert;
+import org.apache.tools.ant.BuildFileRule;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
 
 /**
  * Testcase for the JDepend optional task.
  *
  */
-public class JDependTest extends BuildFileTest {
-    public static final String RESULT_FILESET = "result";
+public class JDependTest {
 
-    public JDependTest(String name) {
-        super(name);
-    }
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
+    @Before
     public void setUp() {
-        configureProject(
-            "src/etc/testcases/taskdefs/optional/jdepend/jdepend.xml");
+        buildRule.configureProject(
+                "src/etc/testcases/taskdefs/optional/jdepend/jdepend.xml");
     }
 
     /**
      * Test simple
      */
+    @Test
     public void testSimple() {
-        expectOutputContaining(
-            "simple", "Package: org.apache.tools.ant.util.facade");
+        buildRule.executeTarget("simple");
+        AntAssert.assertContains("Package: org.apache.tools.ant.util.facade",
+                buildRule.getOutput());
     }
 
     /**
      * Test xml
      */
+    @Test
     public void testXml() {
-        expectOutputContaining(
-            "xml", "<DependsUpon>");
+        buildRule.executeTarget("xml");
+        AntAssert.assertContains("<DependsUpon>", buildRule.getOutput());
     }
 
     /**
      * Test fork
      * - forked output goes to log
      */
+    @Test
     public void testFork() {
-        expectLogContaining(
-            "fork", "Package: org.apache.tools.ant.util.facade");
+        buildRule.executeTarget("fork");
+        AntAssert.assertContains("Package: org.apache.tools.ant.util.facade", buildRule.getLog());
     }
 
     /**
      * Test fork xml
      */
+    @Test
     public void testForkXml() {
-        expectLogContaining(
-            "fork-xml", "<DependsUpon>");
+        buildRule.executeTarget("fork-xml");
+        AntAssert.assertContains("<DependsUpon>", buildRule.getLog());
     }
 
     /**
      * Test timeout
      */
+    @Test
     public void testTimeout() {
-        expectLogContaining(
-            "fork-timeout", "JDepend FAILED - Timed out");
+        buildRule.executeTarget("fork-xml");
+        AntAssert.assertContains( "JDepend FAILED - Timed out", buildRule.getLog());
     }
 
 
     /**
      * Test timeout without timing out
      */
+    @Test
     public void testTimeoutNot() {
-        expectLogContaining(
-            "fork-timeout-not", "Package: org.apache.tools.ant.util.facade");
-    }
-
-    /**
-     * Assert that the given message has been outputted
-     */
-    protected void expectOutputContaining(String target, String substring) {
-        executeTarget(target);
-        assertOutputContaining(substring);
+        buildRule.executeTarget("fork-timeout-not");
+        AntAssert.assertContains("Package: org.apache.tools.ant.util.facade", buildRule.getLog());
     }
 
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/BatchTestTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/BatchTestTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/BatchTestTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/BatchTestTest.java Fri Apr 18 21:00:38 2014
@@ -18,20 +18,19 @@
 
 package org.apache.tools.ant.taskdefs.optional.junit;
 
-import junit.framework.ComparisonFailure;
-import junit.framework.TestCase;
+
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertArrayEquals;
+
+import org.junit.Test;
 
 /**
  *
  * @author  Marian Petras
  */
-public class BatchTestTest extends TestCase {
+public class BatchTestTest {
     
-    public BatchTestTest(String testName) {
-        super(testName);
-    }
-
-
+	@Test
     public void testParseTestMethodNamesList() {
         try {
             JUnitTest.parseTestMethodNamesList(null);
@@ -40,9 +39,9 @@ public class BatchTestTest extends TestC
             //this is an expected exception
         }
 
-        assertEquals(new String[0], JUnitTest.parseTestMethodNamesList(""));
-        assertEquals(new String[0], JUnitTest.parseTestMethodNamesList(" "));
-        assertEquals(new String[0], JUnitTest.parseTestMethodNamesList("  "));
+        assertArrayEquals(new String[0], JUnitTest.parseTestMethodNamesList(""));
+        assertArrayEquals(new String[0], JUnitTest.parseTestMethodNamesList(" "));
+        assertArrayEquals(new String[0], JUnitTest.parseTestMethodNamesList("  "));
 
         checkParseCausesIAE(",");
         checkParseCausesIAE(" ,");
@@ -60,24 +59,24 @@ public class BatchTestTest extends TestC
         checkParseCausesIAE("ab,  ,cd,");
         checkParseCausesIAE(",ab,  ,cd,");
 
-        assertEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList("abc"));
-        assertEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList("abc "));
-        assertEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList(" abc"));
-        assertEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList(" abc "));
-        assertEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList("abc  "));
-        assertEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList("abc,"));
-        assertEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList("abc, "));
-        assertEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList("abc ,"));
-        assertEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList("abc , "));
-        assertEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList(" abc  ,"));
+        assertArrayEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList("abc"));
+        assertArrayEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList("abc "));
+        assertArrayEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList(" abc"));
+        assertArrayEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList(" abc "));
+        assertArrayEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList("abc  "));
+        assertArrayEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList("abc,"));
+        assertArrayEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList("abc, "));
+        assertArrayEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList("abc ,"));
+        assertArrayEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList("abc , "));
+        assertArrayEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList(" abc  ,"));
 
         /* legal Java identifiers: */
-        assertEquals(new String[] {"a"}, JUnitTest.parseTestMethodNamesList("a"));
-        assertEquals(new String[] {"a1"}, JUnitTest.parseTestMethodNamesList("a1"));
-        assertEquals(new String[] {"a$"}, JUnitTest.parseTestMethodNamesList("a$"));
-        assertEquals(new String[] {"a$1"}, JUnitTest.parseTestMethodNamesList("a$1"));
-        assertEquals(new String[] {"_bc"}, JUnitTest.parseTestMethodNamesList("_bc"));
-        assertEquals(new String[] {"___"}, JUnitTest.parseTestMethodNamesList("___"));
+        assertArrayEquals(new String[] {"a"}, JUnitTest.parseTestMethodNamesList("a"));
+        assertArrayEquals(new String[] {"a1"}, JUnitTest.parseTestMethodNamesList("a1"));
+        assertArrayEquals(new String[] {"a$"}, JUnitTest.parseTestMethodNamesList("a$"));
+        assertArrayEquals(new String[] {"a$1"}, JUnitTest.parseTestMethodNamesList("a$1"));
+        assertArrayEquals(new String[] {"_bc"}, JUnitTest.parseTestMethodNamesList("_bc"));
+        assertArrayEquals(new String[] {"___"}, JUnitTest.parseTestMethodNamesList("___"));
 
         /* illegal Java identifiers: */
         checkParseCausesIAE("1");
@@ -90,24 +89,24 @@ public class BatchTestTest extends TestC
         checkParseCausesIAE("1abc def,");
         checkParseCausesIAE(",1abc def");
 
-        assertEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc,def"));
-        assertEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc,def,"));
-        assertEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc,def "));
-        assertEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc, def"));
-        assertEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc, def "));
-        assertEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc ,def"));
-        assertEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc ,def "));
-        assertEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc , def"));
-        assertEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc , def "));
-        assertEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc,def"));
-        assertEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc,def "));
-        assertEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc, def"));
-        assertEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc, def "));
-        assertEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc ,def"));
-        assertEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc ,def "));
-        assertEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc , def"));
-        assertEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc , def "));
-        assertEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc , def ,"));
+        assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc,def"));
+        assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc,def,"));
+        assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc,def "));
+        assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc, def"));
+        assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc, def "));
+        assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc ,def"));
+        assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc ,def "));
+        assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc , def"));
+        assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc , def "));
+        assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc,def"));
+        assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc,def "));
+        assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc, def"));
+        assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc, def "));
+        assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc ,def"));
+        assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc ,def "));
+        assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc , def"));
+        assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc , def "));
+        assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc , def ,"));
     }
 
     private static void checkParseCausesIAE(String param) {
@@ -119,24 +118,4 @@ public class BatchTestTest extends TestC
         }
     }
 
-    private static void assertEquals(String[] expected, String[] actual) {
-        assertEquals(null, expected, actual);
-    }
-
-    private static void assertEquals(String message,
-                                     String[] expected,
-                                     String[] actual) {
-        if ((expected == null) && (actual == null)) {
-            return;
-        }
-        if (expected.length != actual.length) {
-            throw new ComparisonFailure(message,
-                                        expected.toString(),
-                                        actual.toString());
-        }
-        for (int i = 0; i < expected.length; i++) {
-            assertEquals(expected[i], actual[i]);
-        }
-    }
-
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/DOMUtilTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/DOMUtilTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/DOMUtilTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/DOMUtilTest.java Fri Apr 18 21:00:38 2014
@@ -17,20 +17,23 @@
  */
 package org.apache.tools.ant.taskdefs.optional.junit;
 
+import static org.junit.Assert.assertEquals;
+
 import java.io.IOException;
 import java.io.InputStream;
 
 import javax.xml.parsers.DocumentBuilder;
 
-import junit.framework.TestCase;
-
 import org.apache.tools.ant.util.JAXPUtils;
+import org.junit.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 import org.xml.sax.SAXException;
 
-public class DOMUtilTest extends TestCase {
+public class DOMUtilTest {
+	
+	@Test
     public void testListChildNodes() throws SAXException, IOException {
         DocumentBuilder db = JAXPUtils.getDocumentBuilder();
         InputStream is = this.getClass().getClassLoader().getResourceAsStream("taskdefs/optional/junit/matches.xml");
@@ -38,6 +41,7 @@ public class DOMUtilTest extends TestCas
         NodeList nl = DOMUtil.listChildNodes(doc.getDocumentElement(), new FooNodeFilter(), true);
         assertEquals("expecting 3", 3, nl.getLength());
     }
+	
     public class FooNodeFilter implements DOMUtil.NodeFilter {
         public boolean accept(Node node) {
             if (node.getNodeName().equals("foo")) {

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitClassLoaderTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitClassLoaderTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitClassLoaderTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitClassLoaderTest.java Fri Apr 18 21:00:38 2014
@@ -17,19 +17,18 @@
  */
 package org.apache.tools.ant.taskdefs.optional.junit;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertSame;
+
+import org.junit.Test;
 
 /**
  * Test to ensure that the classloader loading JUnit testcase
  * is also the context classloader.
  *
  */
-public class JUnitClassLoaderTest extends TestCase {
-
-    public JUnitClassLoaderTest(String s) {
-        super(s);
-    }
+public class JUnitClassLoaderTest {
 
+    @Test
     public void testContextClassLoader(){
         ClassLoader context = Thread.currentThread().getContextClassLoader();
         ClassLoader caller = getClass().getClassLoader();

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java Fri Apr 18 21:00:38 2014
@@ -18,26 +18,35 @@
 
 package org.apache.tools.ant.taskdefs.optional.junit;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.apache.tools.ant.AntAssert.assertContains;
+import static org.junit.Assert.fail;
+
 import java.io.File;
 import java.io.FileReader;
 import java.io.InputStream;
 import java.net.URL;
-import org.apache.tools.ant.BuildFileTest;
+
+import org.apache.tools.ant.BuildFileRule;
 import org.apache.tools.ant.util.FileUtils;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
 
 /**
  * Small testcase for the junitreporttask.
  * First test added to reproduce an fault, still a lot to improve
  *
  */
-public class JUnitReportTest extends BuildFileTest {
-
-    public JUnitReportTest(String name){
-        super(name);
-    }
-
-    protected void setUp() {
-        configureProject("src/etc/testcases/taskdefs/optional/junitreport.xml");
+public class JUnitReportTest {
+	
+	@Rule
+	public BuildFileRule buildRule = new BuildFileRule();
+
+	@Before
+    public void setUp() {
+        buildRule.configureProject("src/etc/testcases/taskdefs/optional/junitreport.xml");
     }
 
     /**
@@ -45,62 +54,53 @@ public class JUnitReportTest extends Bui
      * output is selected via the default.
      * Needs reports1 task from junitreport.xml.
      */
+	@Test
     public void testNoFileJUnitNoFrames() {
-        executeTarget("reports1");
-        if (new File(getOutputDir(), "html/junit-noframes.html").exists())
-        {
-            fail("No file junit-noframes.html expected");
-        }
+        buildRule.executeTarget("reports1");
+        assertFalse("No file junit-noframes.html expected", (new File(System.getProperty("root"), "src/etc/testcases/taskdefs/optional/junitreport/test/html/junit-noframes.html").exists()));
+        
     }
 
     public void assertIndexCreated() {
-        if (!new File(getOutputDir(), "html/index.html").exists()) {
+        if (!new File(buildRule.getProject().getProperty("output"), "html/index.html").exists()) {
             fail("No file index file found");
         }
 
     }
 
-    /**
-     * run a target, assert the index file is there, look for text in the log
-     * @param targetName target
-     * @param text optional text to look for
-     */
-    private void expectReportWithText(String targetName, String text) {
-        executeTarget(targetName);
-        assertIndexCreated();
-        if(text!=null) {
-            assertLogContaining(text);
-        }
-    }
-
 
+    @Test
     public void testEmptyFile() throws Exception {
-        expectReportWithText("testEmptyFile",
-                XMLResultAggregator.WARNING_EMPTY_FILE);
+    	buildRule.executeTarget("testEmptyFile");
+        assertIndexCreated();
+    	assertContains("Required text not found in log", XMLResultAggregator.WARNING_EMPTY_FILE, buildRule.getLog());
     }
 
+    @Test
     public void testIncompleteFile() throws Exception {
-        expectReportWithText("testIncompleteFile",
-                XMLResultAggregator.WARNING_IS_POSSIBLY_CORRUPTED);
+        buildRule.executeTarget("testIncompleteFile");
+        assertIndexCreated();
+    	assertContains("Required text not found in log", XMLResultAggregator.WARNING_IS_POSSIBLY_CORRUPTED, buildRule.getLog());
     }
+    
+    @Test
     public void testWrongElement() throws Exception {
-        expectReportWithText("testWrongElement",
-                XMLResultAggregator.WARNING_INVALID_ROOT_ELEMENT);
+        buildRule.executeTarget("testWrongElement");
+        assertIndexCreated();
+    	assertContains("Required text not found in log", XMLResultAggregator.WARNING_INVALID_ROOT_ELEMENT, buildRule.getLog());
     }
 
     // Bugzilla Report 34963
+    @Test
     public void testStackTraceLineBreaks() throws Exception {
-        expectReportWithText("testStackTraceLineBreaks", null);
+        buildRule.executeTarget("testStackTraceLineBreaks");
+        assertIndexCreated();
         FileReader r = null;
         try {
-            r = new FileReader(new File(getOutputDir(), "html/sampleproject/coins/0_CoinTest.html"));
+            r = new FileReader(new File(buildRule.getOutputDir(), "html/sampleproject/coins/0_CoinTest.html"));
             String report = FileUtils.readFully(r);
-            assertTrue("output must contain <br>:\n" + report,
-                       report.indexOf("junit.framework.AssertionFailedError: DOEG<br>")
-                   > -1);
-            assertTrue("#51049: output must translate line breaks:\n" + report,
-                       report.indexOf("cur['line.separator'] = '\\r\\n';")
-                   > -1);
+            assertContains("output must contain <br>:\n" + report, "junit.framework.AssertionFailedError: DOEG<br>", report);
+            assertContains("#51049: output must translate line breaks:\n" + report, "cur['line.separator'] = '\\r\\n';", report);
         } finally {
             FileUtils.close(r);
         }
@@ -108,96 +108,104 @@ public class JUnitReportTest extends Bui
 
 
     // Bugzilla Report 38477
+    @Test
     public void testSpecialSignsInSrcPath() throws Exception {
-        executeTarget("testSpecialSignsInSrcPath");
-        File reportFile = new File(getOutputDir(), "html/index.html");
+        buildRule.executeTarget("testSpecialSignsInSrcPath");
+        File reportFile = new File(buildRule.getOutputDir(), "html/index.html");
         // tests one the file object
         assertTrue("No index.html present. Not generated?", reportFile.exists() );
         assertTrue("Cant read the report file.", reportFile.canRead() );
-        assertTrue("File shouldnt be empty.", reportFile.length() > 0 );
+        assertTrue("File shouldn't be empty.", reportFile.length() > 0 );
         // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
         URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) );
         InputStream reportStream = reportUrl.openStream();
-        assertTrue("This shouldnt be an empty stream.", reportStream.available() > 0);
+        assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0);
     }
 
+    @Test
     public void testSpecialSignsInHtmlPath() throws Exception {
-        executeTarget("testSpecialSignsInHtmlPath");
-        File reportFile = new File(getOutputDir(), "html# $%\u00A7&-!report/index.html");
+        buildRule.executeTarget("testSpecialSignsInHtmlPath");
+        File reportFile = new File(buildRule.getOutputDir(), "html# $%\u00A7&-!report/index.html");
         // tests one the file object
         assertTrue("No index.html present. Not generated?", reportFile.exists() );
         assertTrue("Cant read the report file.", reportFile.canRead() );
-        assertTrue("File shouldnt be empty.", reportFile.length() > 0 );
+        assertTrue("File shouldn't be empty.", reportFile.length() > 0 );
         // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
         URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) );
         InputStream reportStream = reportUrl.openStream();
-        assertTrue("This shouldnt be an empty stream.", reportStream.available() > 0);
+        assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0);
     }
 
     //Bugzilla Report 39708
+    @Test
     public void testWithStyleFromDir() throws Exception {
-        executeTarget("testWithStyleFromDir");
-        File reportFile = new File(getOutputDir(), "html/index.html");
+        buildRule.executeTarget("testWithStyleFromDir");
+        File reportFile = new File(buildRule.getOutputDir(), "html/index.html");
         // tests one the file object
         assertTrue("No index.html present. Not generated?", reportFile.exists() );
         assertTrue("Cant read the report file.", reportFile.canRead() );
-        assertTrue("File shouldnt be empty.", reportFile.length() > 0 );
+        assertTrue("File shouldn't be empty.", reportFile.length() > 0 );
         // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
         URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) );
         InputStream reportStream = reportUrl.openStream();
-        assertTrue("This shouldnt be an empty stream.", reportStream.available() > 0);
+        assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0);
     }
 
     //Bugzilla Report 40021
+    @Test
     public void testNoFrames() throws Exception {
-        executeTarget("testNoFrames");
-        File reportFile = new File(getOutputDir(), "html/junit-noframes.html");
+        buildRule.executeTarget("testNoFrames");
+        File reportFile = new File(buildRule.getOutputDir(), "html/junit-noframes.html");
         // tests one the file object
         assertTrue("No junit-noframes.html present. Not generated?", reportFile.exists() );
         assertTrue("Cant read the report file.", reportFile.canRead() );
-        assertTrue("File shouldnt be empty.", reportFile.length() > 0 );
+        assertTrue("File shouldn't be empty.", reportFile.length() > 0 );
         // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
         URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) );
         InputStream reportStream = reportUrl.openStream();
-        assertTrue("This shouldnt be an empty stream.", reportStream.available() > 0);
+        assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0);
     }
     //Bugzilla Report 39708
+    @Test
     public void testWithStyleFromDirAndXslImport() throws Exception {
-        executeTarget("testWithStyleFromDirAndXslImport");
-        File reportFile = new File(getOutputDir(), "html/index.html");
+        buildRule.executeTarget("testWithStyleFromDirAndXslImport");
+        File reportFile = new File(buildRule.getOutputDir(), "html/index.html");
         // tests one the file object
         assertTrue("No index.html present. Not generated?", reportFile.exists() );
         assertTrue("Cant read the report file.", reportFile.canRead() );
-        assertTrue("File shouldnt be empty.", reportFile.length() > 0 );
+        assertTrue("File shouldn't be empty.", reportFile.length() > 0 );
         // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
         URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) );
         InputStream reportStream = reportUrl.openStream();
-        assertTrue("This shouldnt be an empty stream.", reportStream.available() > 0);
+        assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0);
     }
 
+    @Test
     public void testWithStyleFromClasspath() throws Exception {
-        executeTarget("testWithStyleFromClasspath");
-        File reportFile = new File(getOutputDir(), "html/index.html");
+        buildRule.executeTarget("testWithStyleFromClasspath");
+        File reportFile = new File(buildRule.getOutputDir(), "html/index.html");
         // tests one the file object
         assertTrue("No index.html present. Not generated?", reportFile.exists() );
         assertTrue("Cant read the report file.", reportFile.canRead() );
-        assertTrue("File shouldnt be empty.", reportFile.length() > 0 );
+        assertTrue("File shouldn't be empty.", reportFile.length() > 0 );
         // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
         URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) );
         InputStream reportStream = reportUrl.openStream();
-        assertTrue("This shouldnt be an empty stream.", reportStream.available() > 0);
+        assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0);
     }
 
+    @Test
     public void testWithParams() throws Exception {
-        expectLogContaining("testWithParams", "key1=value1,key2=value2");
-        File reportFile = new File(getOutputDir(), "html/index.html");
+    	buildRule.executeTarget("testWithParams");
+    	assertContains("key1=value1,key2=value2", buildRule.getLog());
+        File reportFile = new File(buildRule.getOutputDir(), "html/index.html");
         // tests one the file object
         assertTrue("No index.html present. Not generated?", reportFile.exists() );
         assertTrue("Cant read the report file.", reportFile.canRead() );
-        assertTrue("File shouldnt be empty.", reportFile.length() > 0 );
+        assertTrue("File shouldn't be empty.", reportFile.length() > 0 );
         // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
         URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) );
         InputStream reportStream = reportUrl.openStream();
-        assertTrue("This shouldnt be an empty stream.", reportStream.available() > 0);
+        assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0);
     }
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java Fri Apr 18 21:00:38 2014
@@ -17,75 +17,96 @@
  */
 package org.apache.tools.ant.taskdefs.optional.junit;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import static org.apache.tools.ant.AntAssert.assertNotContains;
+import static org.apache.tools.ant.AntAssert.assertContains;
+
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileReader;
 import java.io.IOException;
 
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.BuildFileTest;
-import org.apache.tools.ant.util.JavaEnvUtils;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.xpath.XPath;
 import javax.xml.xpath.XPathConstants;
 import javax.xml.xpath.XPathFactory;
 
-public class JUnitTaskTest extends BuildFileTest {
+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 org.w3c.dom.Document;
+import org.w3c.dom.Node;
 
-    /**
-     * Constructor for the JUnitTaskTest object.
-     */
-    public JUnitTaskTest(String name) {
-        super(name);
-    }
+public class JUnitTaskTest {
 
+	@Rule
+	public BuildFileRule buildRule = new BuildFileRule();
+	
     /**
      * The JUnit setup method.
      */
+	@Before
     public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/optional/junit.xml");
+        buildRule.configureProject("src/etc/testcases/taskdefs/optional/junit.xml");
     }
 
+	@Test
     public void testCrash() {
-       expectPropertySet("crash", "crashed");
+    	buildRule.executeTarget("crash");
+    	assertEquals("true", buildRule.getProject().getProperty("crashed"));
     }
 
+	@Test
     public void testNoCrash() {
-       expectPropertyUnset("nocrash", "crashed");
+    	buildRule.executeTarget("nocrash");
+    	assertNull(buildRule.getProject().getProperty("crashed"));
     }
 
+	@Test
     public void testTimeout() {
-       expectPropertySet("timeout", "timeout");
+    	buildRule.executeTarget("timeout");
+    	assertEquals("true", buildRule.getProject().getProperty("timeout"));
     }
 
+    @Test
     public void testNoTimeout() {
-       expectPropertyUnset("notimeout", "timeout");
+       buildRule.executeTarget("notimeout");
+   	   assertNull(buildRule.getProject().getProperty("timeout"));
     }
 
+    @Test
     public void testNonForkedCapture() throws IOException {
-        executeTarget("capture");
-        assertNoPrint(getLog(), "log");
-        assertNoPrint(getFullLog(), "debug log");
+        buildRule.executeTarget("capture");
+        assertNoPrint(buildRule.getLog(), "log");
+        assertNoPrint(buildRule.getFullLog(), "debug log");
     }
 
+    @Test
     public void testForkedCapture() throws IOException {
-        getProject().setProperty("fork", "true");
+        buildRule.getProject().setProperty("fork", "true");
         testNonForkedCapture();
-        // those would fail because of the way BuildFileTest captures output
-        assertNoPrint(getOutput(), "output");
-        assertNoPrint(getError(), "error output");
+        // those would fail because of the way BuildFileRule captures output
+        assertNoPrint(buildRule.getOutput(), "output");
+        assertNoPrint(buildRule.getError(), "error output");
         assertOutput();
     }
 
+    @Test
     public void testBatchTestForkOnceToDir() {
         assertResultFilesExist("testBatchTestForkOnceToDir", ".xml");
     }
 
     /** Bugzilla Report 32973 */
+    @Test
     public void testBatchTestForkOnceExtension() {
         assertResultFilesExist("testBatchTestForkOnceExtension", ".foo");
     }
@@ -101,140 +122,157 @@ public class JUnitTaskTest extends Build
     //     $ ant -f junit.xml failureRecorder.runtest
     //     $ ant -f junit.xml failureRecorder.runtest
     //     But running the JUnit testcase fails in 4th run.
+    @Test
     public void testFailureRecorder() {
         if (JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_1_5)) {
             try {
-                Class.forName("junit.framework.JUnit4TestAdapter");
-                System.err.println("skipping tests since it fails when"
-                                   + " using JUnit 4");
-                return;
+            	Class<?> clazz =Class.forName("junit.framework.JUnit4TestAdapter");
+                Assume.assumeFalse("Skipping test since it fails with JUnit 4", clazz != null);
             } catch (ClassNotFoundException e) {
                 // OK, this is JUnit3, can run test
             }
         }
 
-        try {
-            File testDir = new File(getOutputDir(), "out");
-            File collectorFile = new File(getOutputDir(),
-                                          "out/FailedTests.java");
-        
-            // ensure that there is a clean test environment
-            assertFalse("Test directory '" + testDir.getAbsolutePath()
-                        + "' must not exist before the test preparation.", 
-                        testDir.exists());
-            assertFalse("The collector file '"
-                        + collectorFile.getAbsolutePath()
-                        + "'must not exist before the test preparation.", 
-                        collectorFile.exists());
-
-        
-            // prepare the test environment
-            executeTarget("failureRecorder.prepare");
-            assertTrue("Test directory '" + testDir.getAbsolutePath()
-                       + "' was not created.", testDir.exists());
-            assertTrue("There should be one class.",
-                       (new File(testDir, "A.class")).exists());
-            assertFalse("The collector file '"
-                        + collectorFile.getAbsolutePath() 
-                        + "' should not exist before the 1st run.",
-                        collectorFile.exists());
-        
-        
-            // 1st junit run: should do all tests - failing and not failing tests
-            executeTarget("failureRecorder.runtest");
-            assertTrue("The collector file '" + collectorFile.getAbsolutePath() 
-                       + "' should exist after the 1st run.",
-                       collectorFile.exists());
-            // the passing test cases
-            assertOutputContaining("1st run: should run A.test01", "A.test01");
-            assertOutputContaining("1st run: should run B.test05", "B.test05");
-            assertOutputContaining("1st run: should run B.test06", "B.test06");
-            assertOutputContaining("1st run: should run C.test07", "C.test07");
-            assertOutputContaining("1st run: should run C.test08", "C.test08");
-            assertOutputContaining("1st run: should run C.test09", "C.test09");
-            // the failing test cases
-            assertOutputContaining("1st run: should run A.test02", "A.test02");
-            assertOutputContaining("1st run: should run A.test03", "A.test03");
-            assertOutputContaining("1st run: should run B.test04", "B.test04");
-            assertOutputContaining("1st run: should run D.test10", "D.test10");
-
-        
-            // 2nd junit run: should do only failing tests
-            executeTarget("failureRecorder.runtest");
-            assertTrue("The collector file '" + collectorFile.getAbsolutePath() 
-                       + "' should exist after the 2nd run.",
-                       collectorFile.exists());
-            // the passing test cases
-            assertOutputNotContaining("2nd run: should not run A.test01",
-                                      "A.test01");
-            assertOutputNotContaining("2nd run: should not run A.test05",
-                                      "B.test05");
-            assertOutputNotContaining("2nd run: should not run B.test06",
-                                      "B.test06");
-            assertOutputNotContaining("2nd run: should not run C.test07",
-                                      "C.test07");
-            assertOutputNotContaining("2nd run: should not run C.test08",
-                                      "C.test08");
-            assertOutputNotContaining("2nd run: should not run C.test09",
-                                      "C.test09");
-            // the failing test cases
-            assertOutputContaining("2nd run: should run A.test02", "A.test02");
-            assertOutputContaining("2nd run: should run A.test03", "A.test03");
-            assertOutputContaining("2nd run: should run B.test04", "B.test04");
-            assertOutputContaining("2nd run: should run D.test10", "D.test10");
-        
-        
-            // "fix" errors in class A
-            executeTarget("failureRecorder.fixing");
-        
-            // 3rd run: four running tests with two errors
-            executeTarget("failureRecorder.runtest");
-            assertTrue("The collector file '" + collectorFile.getAbsolutePath() 
-                       + "' should exist after the 3rd run.",
-                       collectorFile.exists());
-            assertOutputContaining("3rd run: should run A.test02", "A.test02");
-            assertOutputContaining("3rd run: should run A.test03", "A.test03");
-            assertOutputContaining("3rd run: should run B.test04", "B.test04");
-            assertOutputContaining("3rd run: should run D.test10", "D.test10");
-        
-        
-            // 4rd run: two running tests with errors
-            executeTarget("failureRecorder.runtest");
-            assertTrue("The collector file '" + collectorFile.getAbsolutePath() 
-                       + "' should exist after the 4th run.",
-                       collectorFile.exists());
-            //TODO: these two statements fail
-            //assertOutputNotContaining("4th run: should not run A.test02", "A.test02");
-            //assertOutputNotContaining("4th run: should not run A.test03", "A.test03");
-            assertOutputContaining("4th run: should run B.test04", "B.test04");
-            assertOutputContaining("4th run: should run D.test10", "D.test10");
-        } catch (BuildException be) {
-            be.printStackTrace();
-            System.err.println("nested build's log: " + getLog());
-            System.err.println("nested build's System.out: " + getOutput());
-            System.err.println("nested build's System.err: " + getError());
-            fail("Ant execution failed: " + be.getMessage());
-        }
+        File testDir = new File(buildRule.getOutputDir(), "out");
+        File collectorFile = new File(buildRule.getOutputDir(),
+                "out/FailedTests.java");
+
+        // ensure that there is a clean test environment
+        assertFalse("Test directory '" + testDir.getAbsolutePath()
+                    + "' must not exist before the test preparation.", 
+                    testDir.exists());
+        assertFalse("The collector file '"
+                    + collectorFile.getAbsolutePath()
+                    + "'must not exist before the test preparation.", 
+                    collectorFile.exists());
+
+    
+        // prepare the test environment
+        buildRule.executeTarget("failureRecorder.prepare");
+        assertTrue("Test directory '" + testDir.getAbsolutePath()
+                   + "' was not created.", testDir.exists());
+        assertTrue("There should be one class.",
+                   (new File(testDir, "A.class")).exists());
+        assertFalse("The collector file '"
+                    + collectorFile.getAbsolutePath() 
+                    + "' should not exist before the 1st run.",
+                    collectorFile.exists());
+    
+    
+        // 1st junit run: should do all tests - failing and not failing tests
+        buildRule.executeTarget("failureRecorder.runtest");
+        assertTrue("The collector file '" + collectorFile.getAbsolutePath() 
+                   + "' should exist after the 1st run.",
+                   collectorFile.exists());
+        // the passing test cases
+        buildRule.executeTarget("A.test01");
+        assertContains("1st run: should run A.test01", buildRule.getOutput());
+        buildRule.executeTarget("B.test05");
+        assertContains("1st run: should run B.test05", buildRule.getOutput());
+        buildRule.executeTarget("B.test06");
+        assertContains("1st run: should run B.test06", buildRule.getOutput());
+        buildRule.executeTarget("C.test07");
+        assertContains("1st run: should run C.test07", buildRule.getOutput());
+        buildRule.executeTarget("C.test08");
+        assertContains("1st run: should run C.test08", buildRule.getOutput());
+        buildRule.executeTarget("C.test09");
+        assertContains("1st run: should run C.test09", buildRule.getOutput());
+        // the failing test cases
+        buildRule.executeTarget("A.test02");
+        assertContains("1st run: should run A.test02", buildRule.getOutput());
+        buildRule.executeTarget("A.test03");
+        assertContains("1st run: should run A.test03", buildRule.getOutput());
+        buildRule.executeTarget("B.test04");
+        assertContains("1st run: should run B.test04", buildRule.getOutput());
+        buildRule.executeTarget("D.test10");
+        assertContains("1st run: should run D.test10", buildRule.getOutput());
+
+    
+        // 2nd junit run: should do only failing tests
+        buildRule.executeTarget("failureRecorder.runtest");
+        assertTrue("The collector file '" + collectorFile.getAbsolutePath() 
+                   + "' should exist after the 2nd run.",
+                   collectorFile.exists());
+        // the passing test cases
+        buildRule.executeTarget("A.test01");
+        assertNotContains("2nd run: should not run A.test01", buildRule.getOutput());
+        buildRule.executeTarget("B.test05");
+        assertNotContains("2nd run: should not run A.test05", buildRule.getOutput());
+        buildRule.executeTarget("B.test06");
+        assertNotContains("2nd run: should not run B.test06", buildRule.getOutput());
+        buildRule.executeTarget("C.test07");
+        assertNotContains("2nd run: should not run C.test07", buildRule.getOutput());
+        buildRule.executeTarget("C.test08");
+        assertNotContains("2nd run: should not run C.test08", buildRule.getOutput());
+        buildRule.executeTarget("C.test09");
+        assertNotContains("2nd run: should not run C.test09", buildRule.getOutput());
+        // the failing test cases
+        buildRule.executeTarget("A.test02");
+        assertContains("2nd run: should run A.test02", buildRule.getOutput());
+        buildRule.executeTarget("A.test03");
+        assertContains("2nd run: should run A.test03", buildRule.getOutput());
+        buildRule.executeTarget("B.test04");
+        assertContains("2nd run: should run B.test04", buildRule.getOutput());
+        buildRule.executeTarget("D.test10");
+        assertContains("2nd run: should run D.test10", buildRule.getOutput());
+    
+    
+        // "fix" errors in class A
+        buildRule.executeTarget("failureRecorder.fixing");
+    
+        // 3rd run: four running tests with two errors
+        buildRule.executeTarget("failureRecorder.runtest");
+        assertTrue("The collector file '" + collectorFile.getAbsolutePath() 
+                   + "' should exist after the 3rd run.",
+                   collectorFile.exists());
+        buildRule.executeTarget("A.test02");
+        assertContains("3rd run: should run A.test02", buildRule.getOutput());
+        buildRule.executeTarget("A.test03");
+        assertContains("3rd run: should run A.test03", buildRule.getOutput());
+        buildRule.executeTarget("B.test04");
+        assertContains("3rd run: should run B.test04", buildRule.getOutput());
+        buildRule.executeTarget("D.test10");
+        assertContains("3rd run: should run D.test10", buildRule.getOutput());
+    
+    
+        // 4rd run: two running tests with errors
+        buildRule.executeTarget("failureRecorder.runtest");
+        assertTrue("The collector file '" + collectorFile.getAbsolutePath() 
+                   + "' should exist after the 4th run.",
+                   collectorFile.exists());
+        //TODO: these two statements fail
+        //buildRule.executeTarget("A.test02");assertNotContains("4th run: should not run A.test02", buildRule.getOutput());
+        //buildRule.executeTarget("A.test03");assertNotContains("4th run: should not run A.test03", buildRule.getOutput());
+        buildRule.executeTarget("B.test04");
+        assertContains("4th run: should run B.test04", buildRule.getOutput());
+        buildRule.executeTarget("D.test10");
+        assertContains("4th run: should run D.test10", buildRule.getOutput());
+
     }
 
+    @Test
     public void testBatchTestForkOnceCustomFormatter() {
         assertResultFilesExist("testBatchTestForkOnceCustomFormatter", "foo");
     }
 
     // Bugzilla Issue 45411
+    @Test
     public void testMultilineAssertsNoFork() {
-        expectLogNotContaining("testMultilineAssertsNoFork", "messed up)");
-        assertLogNotContaining("crashed)");
+        buildRule.executeTarget("testMultilineAssertsNoFork");
+        assertNotContains("messaged up", buildRule.getLog());
+        assertNotContains("crashed)", buildRule.getLog());
     }
 
     // Bugzilla Issue 45411
+    @Test
     public void testMultilineAssertsFork() {
-        expectLogNotContaining("testMultilineAssertsFork", "messed up)");
-        assertLogNotContaining("crashed)");
+        buildRule.executeTarget("testMultilineAssertsFork");
+        assertNotContains("messaged up", buildRule.getLog());
+        assertNotContains("crashed)", buildRule.getLog());
     }
 
     private void assertResultFilesExist(String target, String extension) {
-        executeTarget(target);
+        buildRule.executeTarget(target);
         assertResultFileExists("JUnitClassLoader", extension);
         assertResultFileExists("JUnitTestRunner", extension);
         assertResultFileExists("JUnitVersionHelper", extension);
@@ -242,19 +280,20 @@ public class JUnitTaskTest extends Build
 
     private void assertResultFileExists(String classNameFragment, String ext) {
         assertTrue("result for " + classNameFragment + "Test" + ext + " exists",
-                   new File(getOutputDir(), "TEST-org.apache.tools.ant."
+
+                   new File(buildRule.getOutputDir(), "TEST-org.apache.tools.ant."
                                             + "taskdefs.optional.junit."
                                             + classNameFragment + "Test" + ext)
                    .exists());
     }
 
     private void assertNoPrint(String result, String where) {
-        assertTrue(where + " '" + result + "' must not contain print statement",
-                   result.indexOf("print to System.") == -1);
+        assertNotContains(where + " '" + result + "' must not contain print statement",
+                   "print to System.", result);
     }
 
     private void assertOutput() throws IOException {
-        FileReader inner = new FileReader(new File(getOutputDir(),
+        FileReader inner = new FileReader(new File(buildRule.getOutputDir(),
                                           "testlog.txt"));
         BufferedReader reader = new BufferedReader(inner);
         try {
@@ -297,12 +336,13 @@ public class JUnitTaskTest extends Build
         assertEquals(search, line);
     }
 
+    @Test
     public void testJUnit4Skip() throws Exception {
-        executeTarget("testSkippableTests");
+        buildRule.executeTarget("testSkippableTests");
 
         DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
         DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
-        Document doc = dBuilder.parse(new File(getOutputDir(), "TEST-org.example.junit.JUnit4Skippable.xml"));
+        Document doc = dBuilder.parse(new File(buildRule.getOutputDir(), "TEST-org.example.junit.JUnit4Skippable.xml"));
 
         assertEquals("Incorrect number of nodes created", 8, doc.getElementsByTagName("testcase").getLength());
 
@@ -322,32 +362,36 @@ public class JUnitTaskTest extends Build
 
     }
 
+    @Test
     public void testTestMethods() throws Exception {
-        executeTarget("testTestMethods");
+        buildRule.executeTarget("testTestMethods");
     }
 
+    @Test
     public void testNonTestsSkipped() throws Exception {
-        executeTarget("testNonTests");
-        assertFalse("Test result should not exist as test was skipped - TEST-org.example.junit.NonTestMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.NonTestMissed.xml").exists());
-        assertFalse("Test result should not exist as test was skipped - TEST-org.example.junit.JUnit3NonTestMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.JUnit3TestMissed.xml").exists());
-        assertFalse("Test result should not exist as test was skipped - TEST-org.example.junit.AbstractTestMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.AbstractTestMissed.xml").exists());
-        assertFalse("Test result should not exist as test was skipped - TEST-org.example.junit.AbstractJUnit3TestMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.AbstractJUnit3TestMissed.xml").exists());
-        assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.AbstractTestNotMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.AbstractTestNotMissed.xml").exists());
-        assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.AbstractJUnit3TestNotMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.AbstractJUnit3TestNotMissed.xml").exists());
-        assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.TestNotMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.TestNotMissed.xml").exists());
-        assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.JUnit3TestNotMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.JUnit3TestNotMissed.xml").exists());
-        assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.TestWithSuiteNotMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.TestWithSuiteNotMissed.xml").exists());
-
-        executeTarget("testNonTestsRun");
-        assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.NonTestMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.NonTestMissed.xml").exists());
-        assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.JUnit3NonTestMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.JUnit3NonTestMissed.xml").exists());
-        assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.TestNotMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.TestNotMissed.xml").exists());
-        assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.JUnit3TestNotMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.JUnit3TestNotMissed.xml").exists());
-        assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.AbstractTestMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.AbstractTestMissed.xml").exists());
-        assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.AbstractTestNotMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.AbstractTestNotMissed.xml").exists());
-        assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.AbstractJUnit3TestMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.AbstractJUnit3TestMissed.xml").exists());
-        assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.JUnit3NonTestMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.JUnit3NonTestMissed.xml").exists());
-        assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.TestWithSuiteNotMissed.xml", new File(getOutputDir(), "TEST-org.example.junit.TestWithSuiteNotMissed.xml").exists());
+
+        buildRule.executeTarget("testNonTests");
+        assertFalse("Test result should not exist as test was skipped - TEST-org.example.junit.NonTestMissed.xml", new File(buildRule.getOutputDir(), "TEST-org.example.junit.NonTestMissed.xml").exists());
+        assertFalse("Test result should not exist as test was skipped - TEST-org.example.junit.JUnit3NonTestMissed.xml", new File(buildRule.getOutputDir(), "TEST-org.example.junit.JUnit3TestMissed.xml").exists());
+        assertFalse("Test result should not exist as test was skipped - TEST-org.example.junit.AbstractTestMissed.xml", new File(buildRule.getOutputDir(), "TEST-org.example.junit.AbstractTestMissed.xml").exists());
+        assertFalse("Test result should not exist as test was skipped - TEST-org.example.junit.AbstractJUnit3TestMissed.xml", new File(buildRule.getOutputDir(), "TEST-org.example.junit.AbstractJUnit3TestMissed.xml").exists());
+        assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.AbstractTestNotMissed.xml", new File(buildRule.getOutputDir(), "TEST-org.example.junit.AbstractTestNotMissed.xml").exists());
+        assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.AbstractJUnit3TestNotMissed.xml", new File(buildRule.getOutputDir(), "TEST-org.example.junit.AbstractJUnit3TestNotMissed.xml").exists());
+        assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.TestNotMissed.xml", new File(buildRule.getOutputDir(), "TEST-org.example.junit.TestNotMissed.xml").exists());
+        assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.JUnit3TestNotMissed.xml", new File(buildRule.getOutputDir(), "TEST-org.example.junit.JUnit3TestNotMissed.xml").exists());
+        assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.TestWithSuiteNotMissed.xml", new File(buildRule.getOutputDir(), "TEST-org.example.junit.TestWithSuiteNotMissed.xml").exists());
+
+        buildRule.executeTarget("testNonTestsRun");
+        assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.NonTestMissed.xml", new File(buildRule.getOutputDir(), "TEST-org.example.junit.NonTestMissed.xml").exists());
+        assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.JUnit3NonTestMissed.xml", new File(buildRule.getOutputDir(), "TEST-org.example.junit.JUnit3NonTestMissed.xml").exists());
+        assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.TestNotMissed.xml", new File(buildRule.getOutputDir(), "TEST-org.example.junit.TestNotMissed.xml").exists());
+        assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.JUnit3TestNotMissed.xml", new File(buildRule.getOutputDir(), "TEST-org.example.junit.JUnit3TestNotMissed.xml").exists());
+        assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.AbstractTestMissed.xml", new File(buildRule.getOutputDir(), "TEST-org.example.junit.AbstractTestMissed.xml").exists());
+        assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.AbstractTestNotMissed.xml", new File(buildRule.getOutputDir(), "TEST-org.example.junit.AbstractTestNotMissed.xml").exists());
+        assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.AbstractJUnit3TestMissed.xml", new File(buildRule.getOutputDir(), "TEST-org.example.junit.AbstractJUnit3TestMissed.xml").exists());
+        assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.JUnit3NonTestMissed.xml", new File(buildRule.getOutputDir(), "TEST-org.example.junit.JUnit3NonTestMissed.xml").exists());
+        assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.TestWithSuiteNotMissed.xml", new File(buildRule.getOutputDir(), "TEST-org.example.junit.TestWithSuiteNotMissed.xml").exists());
+
 
     }
 

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestListenerTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestListenerTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestListenerTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestListenerTest.java Fri Apr 18 21:00:38 2014
@@ -18,9 +18,18 @@
 
 package org.apache.tools.ant.taskdefs.optional.junit;
 
-import org.apache.tools.ant.BuildFileTest;
+import static org.apache.tools.ant.AntAssert.assertContains;
+import static org.apache.tools.ant.AntAssert.assertNotContains;
 
-public class JUnitTestListenerTest extends BuildFileTest {
+import org.apache.tools.ant.BuildFileRule;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class JUnitTestListenerTest{
+	
+	@Rule
+	public BuildFileRule buildRule = new BuildFileRule();
 
     // The captureToSummary test writes to stdout and stderr, good for
     // verifying that the TestListener support doesn't break anything.
@@ -29,78 +38,74 @@ public class JUnitTestListenerTest exten
     // testNoCrash is the test invoked by the captureToSummary's junit task
     private static final String PASS_TEST = "testNoCrash";
 
-    public JUnitTestListenerTest(String name) {
-        super(name);
-    }
-
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/optional/junit.xml");
+        buildRule.configureProject("src/etc/testcases/taskdefs/optional/junit.xml");
     }
 
+
+    @Test
     public void testFullLogOutput() {
-        getProject().setProperty("enableEvents", "true");
-        executeTarget(PASS_TEST_TARGET);
-        assertTrue("expecting full log to have BuildListener events", 
-                   hasBuildListenerEvents(getFullLog()));
+        buildRule.getProject().setProperty("enableEvents", "true");
+        buildRule.executeTarget(PASS_TEST_TARGET);
+        assertContains("expecting full log to have BuildListener events", 
+        		JUnitTask.TESTLISTENER_PREFIX, buildRule.getFullLog());
     }
     
+    @Test
     public void testNoLogOutput() {
-        getProject().setProperty("enableEvents", "true");
-        executeTarget(PASS_TEST_TARGET);
-        assertFalse("expecting log to not have BuildListener events", 
-                    hasBuildListenerEvents(getLog()));
+        buildRule.getProject().setProperty("enableEvents", "true");
+        buildRule.executeTarget(PASS_TEST_TARGET);
+        assertNotContains("expecting log to not have BuildListener events", 
+        		JUnitTask.TESTLISTENER_PREFIX, buildRule.getLog());
     }
 
+    @Test
     public void testTestCountFired() {
-        getProject().setProperty("enableEvents", "true");
-        executeTarget(PASS_TEST_TARGET);
-	assertTrue("expecting test count message",
-		   hasEventMessage(JUnitTask.TESTLISTENER_PREFIX + 
-				   "tests to run: "));
+        buildRule.getProject().setProperty("enableEvents", "true");
+        buildRule.executeTarget(PASS_TEST_TARGET);
+	    assertContains("expecting test count message", JUnitTask.TESTLISTENER_PREFIX + 
+				   "tests to run: ", buildRule.getFullLog());
     }
     
+    @Test
     public void testStartTestFired() {
-        getProject().setProperty("enableEvents", "true");
-        executeTarget(PASS_TEST_TARGET);
-	assertTrue("expecting test started message",
-		   hasEventMessage(JUnitTask.TESTLISTENER_PREFIX + 
-				   "startTest(" + PASS_TEST + ")"));
+        buildRule.getProject().setProperty("enableEvents", "true");
+        buildRule.executeTarget(PASS_TEST_TARGET);
+        assertContains("expecting test started message", JUnitTask.TESTLISTENER_PREFIX + 
+				   "startTest(" + PASS_TEST + ")", buildRule.getFullLog());
     }
     
+    @Test
     public void testEndTestFired() {
-        getProject().setProperty("enableEvents", "true");
-        executeTarget(PASS_TEST_TARGET);
-	assertTrue("expecting test ended message",
-		   hasEventMessage(JUnitTask.TESTLISTENER_PREFIX + 
-				   "endTest(" + PASS_TEST + ")"));
+        buildRule.getProject().setProperty("enableEvents", "true");
+        buildRule.executeTarget(PASS_TEST_TARGET);
+        assertContains("expecting test ended message", JUnitTask.TESTLISTENER_PREFIX + 
+				   "endTest(" + PASS_TEST + ")", buildRule.getFullLog());
     }
     
+    @Test
     public void testNoFullLogOutputByDefault() {
-        executeTarget(PASS_TEST_TARGET);
-        assertFalse("expecting full log to not have BuildListener events", 
-                    hasBuildListenerEvents(getFullLog()));
+        buildRule.executeTarget(PASS_TEST_TARGET);
+        assertNotContains("expecting full log to not have BuildListener events", 
+        		JUnitTask.TESTLISTENER_PREFIX, buildRule.getFullLog());
     }
     
+    @Test
     public void testFullLogOutputMagicProperty() {
-        getProject().setProperty(JUnitTask.ENABLE_TESTLISTENER_EVENTS, "true");
-        executeTarget(PASS_TEST_TARGET);
-        assertTrue("expecting full log to have BuildListener events", 
-                   hasBuildListenerEvents(getFullLog()));
+        buildRule.getProject().setProperty(JUnitTask.ENABLE_TESTLISTENER_EVENTS, "true");
+        buildRule.executeTarget(PASS_TEST_TARGET);
+        assertContains("expecting full log to have BuildListener events", 
+        		JUnitTask.TESTLISTENER_PREFIX, buildRule.getFullLog());
     }
     
+    @Test
     public void testNoFullLogOutputMagicPropertyWins() {
-        getProject().setProperty(JUnitTask.ENABLE_TESTLISTENER_EVENTS, "false");
-        getProject().setProperty("enableEvents", "true");
-        executeTarget(PASS_TEST_TARGET);
-        assertFalse("expecting full log to not have BuildListener events", 
-                    hasBuildListenerEvents(getFullLog()));
+        buildRule.getProject().setProperty(JUnitTask.ENABLE_TESTLISTENER_EVENTS, "false");
+        buildRule.getProject().setProperty("enableEvents", "true");
+        buildRule.executeTarget(PASS_TEST_TARGET);
+        assertNotContains("expecting full log to not have BuildListener events", 
+        		JUnitTask.TESTLISTENER_PREFIX, buildRule.getFullLog());
     }
     
-    private boolean hasBuildListenerEvents(String log) {
-        return log.indexOf(JUnitTask.TESTLISTENER_PREFIX) >= 0;
-    }
-
-    private boolean hasEventMessage(String eventPrefix) {
-	return getFullLog().indexOf(eventPrefix) >= 0;
-    }
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunnerTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunnerTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunnerTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunnerTest.java Fri Apr 18 21:00:38 2014
@@ -17,23 +17,31 @@
  */
 package org.apache.tools.ant.taskdefs.optional.junit;
 
-import java.io.*;
-import junit.framework.*;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
 import org.apache.tools.ant.BuildException;
+import org.junit.Test;
 
 /**
  * Small testcase for the runner, tests are very very very basics.
  * They must be enhanced with time.
  *
  */
-public class JUnitTestRunnerTest extends TestCase {
+public class JUnitTestRunnerTest{
 
-    // mandatory constructor
-    public JUnitTestRunnerTest(String name){
-        super(name);
-    }
+  
 
     // check that a valid method name generates no errors
+    @Test
     public void testValidMethod(){
         TestRunner runner = createRunnerForTestMethod(ValidMethodTestCase.class,"testA");
         runner.run();
@@ -41,6 +49,7 @@ public class JUnitTestRunnerTest extends
     }
 
     // check that having an invalid method name generates an error
+    @Test
     public void testInvalidMethod(){
         TestRunner runner = createRunnerForTestMethod(InvalidMethodTestCase.class,"testInvalid");
         runner.run();
@@ -50,6 +59,7 @@ public class JUnitTestRunnerTest extends
     }    
     
     // check that having no suite generates no errors
+    @Test
     public void testNoSuite(){
         TestRunner runner = createRunner(NoSuiteTestCase.class);
         runner.run();
@@ -57,6 +67,7 @@ public class JUnitTestRunnerTest extends
     }
 
     // check that a suite generates no errors
+    @Test
     public void testSuite(){
         TestRunner runner = createRunner(SuiteTestCase.class);
         runner.run();
@@ -64,6 +75,7 @@ public class JUnitTestRunnerTest extends
     }
 
     // check that an invalid suite generates an error.
+    @Test
     public void testInvalidSuite(){
         TestRunner runner = createRunner(InvalidSuiteTestCase.class);
         runner.run();
@@ -74,6 +86,7 @@ public class JUnitTestRunnerTest extends
 
     // check that something which is not a testcase generates no errors
     // at first even though this is incorrect.
+    @Test
     public void testNoTestCase(){
         TestRunner runner = createRunner(NoTestCase.class);
         runner.run();
@@ -88,6 +101,7 @@ public class JUnitTestRunnerTest extends
     }
 
     // check that an exception in the constructor is noticed
+    @Test
     public void testInvalidTestCase(){
         TestRunner runner = createRunner(InvalidTestCase.class);
         runner.run();
@@ -102,12 +116,12 @@ public class JUnitTestRunnerTest extends
         //assertTrue(error, error.indexOf("thrown on purpose") != -1);
     }
 
-    protected TestRunner createRunner(Class clazz){
+    protected TestRunner createRunner(Class<?> clazz){
         return new TestRunner(new JUnitTest(clazz.getName()), null, 
                                             true, true, true);
     }
 
-    protected TestRunner createRunnerForTestMethod(Class clazz, String method){
+    protected TestRunner createRunnerForTestMethod(Class<?> clazz, String method){
         return new TestRunner(new JUnitTest(clazz.getName()), new String[] {method},
                                             true, true, true);
     }    
@@ -137,11 +151,10 @@ public class JUnitTestRunnerTest extends
         public void startTestSuite(JUnitTest suite) throws BuildException{}
         public void endTestSuite(JUnitTest suite) throws BuildException{}
         public void setOutput(java.io.OutputStream out){}
-        public void startTest(Test t) {}
-        public void endTest(Test test) {}
-        public void addFailure(Test test, Throwable t) { }
-        public void addFailure(Test test, AssertionFailedError t) { }
-        public void addError(Test test, Throwable t) {
+        public void startTest(junit.framework.Test t) {}
+        public void endTest(junit.framework.Test test) {}
+        public void addFailure(junit.framework.Test test, AssertionFailedError t) { }
+        public void addError(junit.framework.Test test, Throwable t) {
             error = t;
         }
         String getError(){
@@ -189,19 +202,16 @@ public class JUnitTestRunnerTest extends
 
     public static class SuiteTestCase extends NoSuiteTestCase {
         public SuiteTestCase(String name){ super(name); }
-        public static Test suite(){
+        public static junit.framework.Test suite(){
             return new TestSuite(SuiteTestCase.class);
         }
     }
 
     public static class InvalidSuiteTestCase extends NoSuiteTestCase {
         public InvalidSuiteTestCase(String name){ super(name); }
-        public static Test suite(){
+        public static junit.framework.Test suite(){
             throw new NullPointerException("thrown on purpose");
         }
     }
-    public static void main(String[] args){
-        junit.textui.TestRunner.run(JUnitTestRunnerTest.class);
-    }
 }
 

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelperTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelperTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelperTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelperTest.java Fri Apr 18 21:00:38 2014
@@ -17,53 +17,65 @@
  */
 package org.apache.tools.ant.taskdefs.optional.junit;
 
-import junit.framework.Test;
+import static org.junit.Assert.assertEquals;
+import junit.framework.JUnit4TestAdapterCache;
 import junit.framework.TestCase;
 import junit.framework.TestResult;
 
+import org.junit.Test;
+import org.junit.runner.Description;
+
 /**
  */
-public class JUnitVersionHelperTest extends TestCase {
-
-    public JUnitVersionHelperTest(String name) {
-        super(name);
-    }
+public class JUnitVersionHelperTest {
 
+	@Test
     public void testMyOwnName() {
         assertEquals("testMyOwnName",
-                     JUnitVersionHelper.getTestCaseName(this));
+        		JUnitVersionHelper.getTestCaseName(
+                    JUnit4TestAdapterCache.getDefault().asTest(
+                    		Description.createTestDescription(JUnitVersionHelperTest.class, "testMyOwnName")
+                    )
+                )
+        );
     }
 
+	@Test
     public void testNonTestCaseName() {
         assertEquals("I'm a foo",
                      JUnitVersionHelper.getTestCaseName(new Foo1()));
     }
 
+	@Test
     public void testNoStringReturn() {
         assertEquals("unknown",
                      JUnitVersionHelper.getTestCaseName(new Foo2()));
     }
 
+	@Test
     public void testNoGetName() {
         assertEquals("unknown",
                      JUnitVersionHelper.getTestCaseName(new Foo3()));
     }
 
+	@Test
     public void testNameNotGetName() {
         assertEquals("I'm a foo, too",
                      JUnitVersionHelper.getTestCaseName(new Foo4()));
     }
 
+	@Test
     public void testNull() {
         assertEquals("unknown", JUnitVersionHelper.getTestCaseName(null));
     }
 
+	@Test
     public void testTestCaseSubClass() {
         assertEquals("overridden getName",
                      JUnitVersionHelper.getTestCaseName(new Foo5()));
     }
 
-    public static class Foo implements Test {
+    public static class Foo implements junit.framework.Test {
         public int countTestCases() {return 0;}
         public void run(TestResult result) {}
     }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/NoVmCrash.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/NoVmCrash.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/NoVmCrash.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/NoVmCrash.java Fri Apr 18 21:00:38 2014
@@ -17,16 +17,13 @@
  */
 package org.apache.tools.ant.taskdefs.optional.junit;
 
-import junit.framework.TestCase;
+import org.junit.Test;
 
 /**
  */
-public class NoVmCrash extends TestCase {
-
-    public NoVmCrash(String name) {
-        super(name);
-    }
+public class NoVmCrash {
 
+    @Test
     public void testNoCrash() {
     }
 

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/Printer.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/Printer.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/Printer.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/Printer.java Fri Apr 18 21:00:38 2014
@@ -17,14 +17,13 @@
  */
 package org.apache.tools.ant.taskdefs.optional.junit;
 
-import junit.framework.TestCase;
+import org.junit.Test;
 
 /**
  */
-public class Printer extends TestCase {
+public class Printer {
 
-    public Printer(String name) {
-        super(name);
+    public Printer() {
         System.err.println("constructor print to System.err");
         System.out.println("constructor print to System.out");
     }
@@ -34,6 +33,7 @@ public class Printer extends TestCase {
         System.out.println("static print to System.out");
     }
 
+    @Test
     public void testNoCrash() {
         System.err.println("method print to System.err");
         System.out.println("method print to System.out");

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/Sleeper.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/Sleeper.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/Sleeper.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/Sleeper.java Fri Apr 18 21:00:38 2014
@@ -17,21 +17,14 @@
  */
 package org.apache.tools.ant.taskdefs.optional.junit;
 
-import junit.framework.TestCase;
 
-/**
- */
-public class Sleeper extends TestCase {
+import org.junit.Test;
 
-    public Sleeper(String name) {
-        super(name);
-    }
+public class Sleeper {
 
-    public void testSleep() {
-        try {
-            Thread.sleep(5 * 1000);
-        } catch (InterruptedException e) {
-        } // end of try-catch
+    @Test
+    public void testSleep() throws InterruptedException {
+        Thread.sleep(5 * 1000);
     }
 
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/TearDownOnVmCrashTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/TearDownOnVmCrashTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/TearDownOnVmCrashTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/TearDownOnVmCrashTest.java Fri Apr 18 21:00:38 2014
@@ -18,21 +18,36 @@
 
 package org.apache.tools.ant.taskdefs.optional.junit;
 
-import org.apache.tools.ant.BuildFileTest;
-
-public class TearDownOnVmCrashTest extends BuildFileTest {
+import static org.apache.tools.ant.AntAssert.assertContains;
+import static org.apache.tools.ant.AntAssert.assertNotContains;
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tools.ant.BuildFileRule;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class TearDownOnVmCrashTest {
+	
+	@Rule
+	public BuildFileRule buildRule = new BuildFileRule();
 
+	@Before
     public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/optional/junit/teardownlistener.xml");
+        buildRule.configureProject("src/etc/testcases/taskdefs/optional/junit/teardownlistener.xml");
     }
 
+	@Test
     public void testNoTeardown() {
-        expectPropertySet("testNoTeardown", "error");
-        assertOutputNotContaining(null, "tearDown called on Timeout");
+        buildRule.executeTarget("testNoTeardown");
+        assertEquals("true", buildRule.getProject().getProperty("error"));
+        assertNotContains("tearDown called on Timeout", buildRule.getOutput());
     }
 
+	@Test
     public void testTeardown() {
-        expectPropertySet("testTeardown", "error");
-        assertOutputContaining("tearDown called on Timeout");
+		buildRule.executeTarget("testTeardown");
+		assertEquals("true", buildRule.getProject().getProperty("error"));
+		assertContains("tearDown called on Timeout", buildRule.getOutput());
     }
 }
\ No newline at end of file

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/VmCrash.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/VmCrash.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/VmCrash.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/VmCrash.java Fri Apr 18 21:00:38 2014
@@ -17,16 +17,13 @@
  */
 package org.apache.tools.ant.taskdefs.optional.junit;
 
-import junit.framework.TestCase;
+import org.junit.Test;
 
 /**
  */
-public class VmCrash extends TestCase {
-
-    public VmCrash(String name) {
-        super(name);
-    }
+public class VmCrash {
 
+    @Test
     public void testCrash() {
         System.exit(0);
     }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/XMLFormatterWithCDATAOnSystemOut.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/XMLFormatterWithCDATAOnSystemOut.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/XMLFormatterWithCDATAOnSystemOut.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/XMLFormatterWithCDATAOnSystemOut.java Fri Apr 18 21:00:38 2014
@@ -20,16 +20,21 @@ package org.apache.tools.ant.taskdefs.op
 import java.io.File;
 import java.io.FileReader;
 import java.io.IOException;
-import org.apache.tools.ant.BuildFileTest;
+
+import org.apache.tools.ant.BuildFileRule;
 import org.apache.tools.ant.util.FileUtils;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
 
-public class XMLFormatterWithCDATAOnSystemOut extends BuildFileTest {
+public class XMLFormatterWithCDATAOnSystemOut {
 
-    private static String DIR = "src/etc/testcases/taskdefs/optional/junit";
-    private static String REPORT =
+    private static final String DIR = "src/etc/testcases/taskdefs/optional/junit";
+    private static final String REPORT =
         "TEST-" + XMLFormatterWithCDATAOnSystemOut.class.getName() + ".xml";
 
-    private static String TESTDATA =
+    private static final String TESTDATA =
         "<ERROR>" +
         "<![CDATA[<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
         "  <RESPONSE>" +
@@ -45,20 +50,21 @@ public class XMLFormatterWithCDATAOnSyst
         "]]>" +
         "</ERROR>";
 
-    public XMLFormatterWithCDATAOnSystemOut(String name) {
-        super(name);
-    }
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
+    @Test
     public void testOutput() {
         System.out.println(TESTDATA);
     }
 
+    @Test
     public void testBuildfile() throws IOException {
-        configureProject(DIR + "/cdataoutput.xml");
-        if (getProject().getProperty("cdata.inner") == null) {
+        buildRule.configureProject(DIR + "/cdataoutput.xml");
+        if (buildRule.getProject().getProperty("cdata.inner") == null) {
             // avoid endless loop
-            executeTarget("run-junit");
-            File f = getProject().resolveFile(REPORT);
+            buildRule.executeTarget("run-junit");
+            File f = buildRule.getProject().resolveFile(REPORT);
             FileReader reader = null;
             try {
                 reader = new FileReader(f);

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregatorTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregatorTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregatorTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregatorTest.java Fri Apr 18 21:00:38 2014
@@ -18,28 +18,29 @@
 
 package org.apache.tools.ant.taskdefs.optional.junit;
 
+import static org.junit.Assert.assertTrue;
+
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.PrintWriter;
 import java.security.Permission;
-import junit.framework.TestCase;
+
 import org.apache.tools.ant.DefaultLogger;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.taskdefs.Delete;
 import org.apache.tools.ant.types.FileSet;
+import org.junit.Assume;
+import org.junit.Test;
 
-public class XMLResultAggregatorTest extends TestCase {
-
-    public XMLResultAggregatorTest(String name) {
-        super(name);
-    }
+public class XMLResultAggregatorTest {
 
+	@Test
     public void testFrames() throws Exception {
         // For now, skip this test on JDK 6 (and below); see below for why:
         try {
             Class.forName("java.nio.file.Files");
         } catch (ClassNotFoundException x) {
-            return;
+            Assume.assumeNoException("Skip test on JDK 6 and below", x);
         }
         final File d = new File(System.getProperty("java.io.tmpdir"), "XMLResultAggregatorTest");
         if (d.exists()) {



Mime
View raw message