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 [10/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...

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/EchoPropertiesTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/EchoPropertiesTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/EchoPropertiesTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/EchoPropertiesTest.java Fri Apr 18 21:00:38 2014
@@ -18,25 +18,37 @@
 
 package org.apache.tools.ant.taskdefs.optional;
 
-import org.apache.tools.ant.BuildFileTest;
-import org.apache.tools.ant.util.regexp.RegexpMatcherFactory;
+import static org.apache.tools.ant.AntAssert.assertContains;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeTrue;
 
-import java.io.IOException;
-import java.io.File;
-import java.io.InputStream;
 import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileReader;
-import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
 import java.util.Properties;
 
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
+import org.apache.tools.ant.util.regexp.RegexpMatcherFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
 /**
  * Tests the EchoProperties task.
  *
  * @created   17-Jan-2002
  * @since     Ant 1.5
  */
-public class EchoPropertiesTest extends BuildFileTest {
+public class EchoPropertiesTest {
 
     private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/";
     private static final String GOOD_OUTFILE = "test.properties";
@@ -44,144 +56,166 @@ public class EchoPropertiesTest extends 
     private static final String PREFIX_OUTFILE = "test-prefix.properties";
     private static final String TEST_VALUE = "isSet";
 
-    public EchoPropertiesTest(String name) {
-        super(name);
-    }
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
 
+    @Before
     public void setUp() {
-        configureProject(TASKDEFS_DIR + "echoproperties.xml");
-        project.setProperty( "test.property", TEST_VALUE );
+        buildRule.configureProject(TASKDEFS_DIR + "echoproperties.xml");
+        buildRule.getProject().setProperty("test.property", TEST_VALUE);
     }
 
 
+    @After
     public void tearDown() {
-        executeTarget("cleanup");
+        buildRule.executeTarget("cleanup");
     }
 
 
+    @Test
     public void testEchoToLog() {
-        expectLogContaining("testEchoToLog", "test.property="+TEST_VALUE);
+    	buildRule.executeTarget("testEchoToLog");
+    	assertContains("test.property=" + TEST_VALUE, buildRule.getLog());
     }
 
+    @Test
     public void testEchoWithEmptyPrefixToLog() {
-        expectLogContaining("testEchoWithEmptyPrefixToLog", "test.property="+TEST_VALUE);
+    	buildRule.executeTarget("testEchoWithEmptyPrefixToLog");
+    	assertContains("test.property="+TEST_VALUE, buildRule.getLog());
     }
 
 
+    @Test
     public void testReadBadFile() {
-        expectBuildExceptionContaining( "testReadBadFile",
-            "srcfile is a directory", "srcfile is a directory!" );
+    	try {
+    		buildRule.executeTarget("testReadBadFile");
+    		fail("BuildException should have been thrown on bad file");
+    	}
+    	catch(BuildException ex) {
+    		assertContains("srcfile is a directory","srcfile is a directory!", ex.getMessage());
+    	}
     }
 
-
-    public void testReadBadFileFail() {
-        expectBuildExceptionContaining( "testReadBadFile",
-            "srcfile is a directory", "srcfile is a directory!" );
-    }
-
-
+    @Test
     public void testReadBadFileNoFail() {
-        expectLog( "testReadBadFileNoFail", "srcfile is a directory!" );
+        buildRule.executeTarget("testReadBadFileNoFail");
+        assertContains("srcfile is a directory!", buildRule.getLog());
     }
 
 
+    @Test
     public void testEchoToBadFile() {
-        expectBuildExceptionContaining( "testEchoToBadFile",
-            "destfile is a directory", "destfile is a directory!" );
-    }
-
-
-    public void testEchoToBadFileFail() {
-        expectBuildExceptionContaining( "testEchoToBadFileFail",
-            "destfile is a directory", "destfile is a directory!" );
+    	try {
+    		buildRule.executeTarget("testEchoToBadFile");
+            fail("BuildException should have been thrown on destination file being a directory");
+    	} catch(BuildException ex) {
+    		assertContains("destfile is a directory", "destfile is a directory!", ex.getMessage());
+    	}
     }
 
 
+    @Test
     public void testEchoToBadFileNoFail() {
-        expectLog( "testEchoToBadFileNoFail", "destfile is a directory!");
+    	buildRule.executeTarget("testEchoToBadFileNoFail");
+    	assertContains("destfile is a directory!", buildRule.getLog());
     }
 
 
+    @Test
     public void testEchoToGoodFile() throws Exception {
-        executeTarget( "testEchoToGoodFile" );
+        buildRule.executeTarget("testEchoToGoodFile");
         assertGoodFile();
     }
 
 
+    @Test
     public void testEchoToGoodFileXml() throws Exception {
-        executeTarget( "testEchoToGoodFileXml" );
+        buildRule.executeTarget("testEchoToGoodFileXml");
 
         // read in the file
-        File f = createRelativeFile( GOOD_OUTFILE_XML );
-        FileReader fr = new FileReader( f );
+        File f = createRelativeFile(GOOD_OUTFILE_XML);
+        FileReader fr = new FileReader(f);
+        BufferedReader br = new BufferedReader(fr);
         try {
-            BufferedReader br = new BufferedReader( fr );
             String read = null;
-            while ( (read = br.readLine()) != null) {
+            while ((read = br.readLine()) != null) {
                 if (read.indexOf("<property name=\"test.property\" value=\""+TEST_VALUE+"\" />") >= 0) {
                     // found the property we set - it's good.
                     return;
                 }
             }
-            fail( "did not encounter set property in generated file." );
+            fail("did not encounter set property in generated file.");
         } finally {
             try {
                 fr.close();
             } catch(IOException e) {}
+            try {
+                br.close();
+            } catch(IOException e) {}
         }
     }
 
 
+    @Test
     public void testEchoToGoodFileFail() throws Exception {
-        executeTarget( "testEchoToGoodFileFail" );
+        buildRule.executeTarget("testEchoToGoodFileFail");
         assertGoodFile();
     }
 
 
+    @Test
     public void testEchoToGoodFileNoFail() throws Exception {
-        executeTarget( "testEchoToGoodFileNoFail" );
+        buildRule.executeTarget("testEchoToGoodFileNoFail");
         assertGoodFile();
     }
 
-
+    @Test
     public void testEchoPrefix() throws Exception {
         testEchoPrefixVarious("testEchoPrefix");
     }
 
+    @Test
     public void testEchoPrefixAsPropertyset() throws Exception {
         testEchoPrefixVarious("testEchoPrefixAsPropertyset");
     }
 
+    @Test
     public void testEchoPrefixAsNegatedPropertyset() throws Exception {
         testEchoPrefixVarious("testEchoPrefixAsNegatedPropertyset");
     }
 
+    @Test
     public void testEchoPrefixAsDoublyNegatedPropertyset() throws Exception {
         testEchoPrefixVarious("testEchoPrefixAsDoublyNegatedPropertyset");
     }
 
+    @Test
     public void testWithPrefixAndRegex() throws Exception {
-        expectSpecificBuildException("testWithPrefixAndRegex",
-                "The target must fail with prefix and regex attributes set",
-                "Please specify either prefix or regex, but not both");
+    	try {
+    		buildRule.executeTarget("testWithPrefixAndRegex");
+    		fail("BuildException should have been thrown on Prefix and RegEx beng set");
+    	} catch (BuildException ex) {
+    		assertEquals("The target must fail with prefix and regex attributes set", "Please specify either prefix or regex, but not both", ex.getMessage());
+    	}
     }
 
+    @Test
     public void testWithEmptyPrefixAndRegex() throws Exception {
-        expectLogContaining("testEchoWithEmptyPrefixToLog", "test.property="+TEST_VALUE);
+    	buildRule.executeTarget("testEchoWithEmptyPrefixToLog");
+    	assertContains("test.property="+TEST_VALUE, buildRule.getLog());
     }
 
+    @Test
     public void testWithRegex() throws Exception {
-        if (!RegexpMatcherFactory.regexpMatcherPresent(project)) {
-            System.out.println("Test 'testWithRegex' skipped because no regexp matcher is present.");
-            return;
-        }
-        executeTarget("testWithRegex");
-        assertDebuglogContaining("ant.home=");
+        assumeTrue("Test skipped because no regexp matcher is present.", RegexpMatcherFactory.regexpMatcherPresent(buildRule.getProject()));
+        buildRule.executeTarget("testWithRegex");
+        // the following line has been changed from checking ant.home to ant.version so the test will still work when run outside of an ant script
+        assertContains("ant.version=", buildRule.getFullLog());
     }
 
     private void testEchoPrefixVarious(String target) throws Exception {
-        executeTarget(target);
+        buildRule.executeTarget(target);
         Properties props = loadPropFile(PREFIX_OUTFILE);
         assertEquals("prefix didn't include 'a.set' property",
             "true", props.getProperty("a.set"));
@@ -191,7 +225,7 @@ public class EchoPropertiesTest extends 
 
     protected Properties loadPropFile(String relativeFilename)
             throws IOException {
-        File f = createRelativeFile( relativeFilename );
+        File f = createRelativeFile(relativeFilename);
         Properties props=new Properties();
         InputStream in=null;
         try  {
@@ -206,47 +240,27 @@ public class EchoPropertiesTest extends 
     }
 
     protected void assertGoodFile() throws Exception {
-        File f = createRelativeFile( GOOD_OUTFILE );
-        assertTrue(
-            "Did not create "+f.getAbsolutePath(),
-            f.exists() );
+        File f = createRelativeFile(GOOD_OUTFILE);
+        assertTrue("Did not create "+f.getAbsolutePath(),
+            f.exists());
         Properties props=loadPropFile(GOOD_OUTFILE);
         props.list(System.out);
         assertEquals("test property not found ",
                      TEST_VALUE, props.getProperty("test.property"));
-/*
-        // read in the file
-        FileReader fr = new FileReader( f );
-        try {
-            BufferedReader br = new BufferedReader( fr );
-            String read = null;
-            while ( (read = br.readLine()) != null)
-            {
-                if (read.indexOf("test.property" + TEST_VALUE) >= 0)
-                {
-                    // found the property we set - it's good.
-                    return;
-                }
-            }
-            fail( "did not encounter set property in generated file." );
-        } finally {
-            try { fr.close(); } catch(IOException e) {}
-        }
-*/
     }
 
 
-    protected String toAbsolute( String filename ) {
-        return createRelativeFile( filename ).getAbsolutePath();
+    protected String toAbsolute(String filename) {
+        return createRelativeFile(filename).getAbsolutePath();
     }
 
 
-    protected File createRelativeFile( String filename ) {
-        if (filename.equals( "." )) {
-            return getProjectDir();
+    protected File createRelativeFile(String filename) {
+        if (filename.equals(".")) {
+            return buildRule.getProject().getBaseDir();
         }
         // else
-        return new File( getProjectDir(), filename );
+        return new File(buildRule.getProject().getBaseDir(), filename);
     }
 }
 

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JavahTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JavahTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JavahTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JavahTest.java Fri Apr 18 21:00:38 2014
@@ -17,32 +17,44 @@
  */
 package org.apache.tools.ant.taskdefs.optional;
 
-import org.apache.tools.ant.BuildFileTest;
+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;
 
-public class JavahTest extends BuildFileTest {
+import static org.junit.Assert.assertTrue;
+
+public class JavahTest {
 
     private final static String BUILD_XML = 
         "src/etc/testcases/taskdefs/optional/javah/build.xml";
 
-    public JavahTest(String name) {
-        super(name);
-    }
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
+    @Before
     public void setUp() {
-        configureProject(BUILD_XML);
+        buildRule.configureProject(BUILD_XML);
+    }
+
+    @After
+    public void tearDown() {
+        buildRule.executeTarget("tearDown");
     }
 
+    @Test
     public void testSimpleCompile() {
-        executeTarget("simple-compile");
-        assertTrue(new File(getProject().getProperty("output"), "org_example_Foo.h")
+        buildRule.executeTarget("simple-compile");
+        assertTrue(new File(buildRule.getProject().getProperty("output"), "org_example_Foo.h")
                 .exists());
     }
 
+    @Test
     public void testCompileFileset() {
-        executeTarget("test-fileset");
-        assertTrue(new File(getProject().getProperty("output"), "org_example_Foo.h")
-                   .exists());
+        buildRule.executeTarget("test-fileset");
+        assertTrue(new File(buildRule.getProject().getProperty("output"), "org_example_Foo.h").exists());
     }
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JspcTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JspcTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JspcTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JspcTest.java Fri Apr 18 21:00:38 2014
@@ -19,64 +19,56 @@ package org.apache.tools.ant.taskdefs.op
 
 import java.io.File;
 
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
 import org.apache.tools.ant.taskdefs.optional.jsp.Jasper41Mangler;
 import org.apache.tools.ant.taskdefs.optional.jsp.JspMangler;
 import org.apache.tools.ant.taskdefs.optional.jsp.JspNameMangler;
 import org.apache.tools.ant.taskdefs.optional.jsp.compilers.JspCompilerAdapter;
 import org.apache.tools.ant.taskdefs.optional.jsp.compilers.JspCompilerAdapterFactory;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 /**
  * Tests the Jspc task.
  *
- * @created 07 March 2002
+ * created 07 March 2002
  * @since Ant 1.5
  */
-public class JspcTest extends BuildFileTest {
+public class JspcTest {
 
-    /**
-     * Description of the Field
-     */
     private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/";
 
 
-    /**
-     * Constructor for the JspcTest object
-     *
-     * @param name Description of Parameter
-     */
-    public JspcTest(String name) {
-        super(name);
-    }
-
-
-    /**
-     * The JUnit setup method
-     */
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
+    
+    @Before
     public void setUp() {
-        configureProject(TASKDEFS_DIR + "jspc.xml");
-    }
+        buildRule.configureProject(TASKDEFS_DIR + "jspc.xml");
+     }
 
 
-    /**
-     * A unit test for JUnit
-     */
-    public void testSimple() throws Exception {
+
+    @Test
+    public void testSimple() {
         executeJspCompile("testSimple", "simple_jsp.java");
     }
 
 
-    /**
-     * A unit test for JUnit
-     */
+    @Test
     public void testUriroot() throws Exception {
         executeJspCompile("testUriroot", "uriroot_jsp.java");
     }
 
 
-    /**
-     * A unit test for JUnit
-     */
+    @Test
     public void testXml() throws Exception {
         executeJspCompile("testXml", "xml_jsp.java");
     }
@@ -85,6 +77,7 @@ public class JspcTest extends BuildFileT
     /**
      * try a keyword in a file
      */
+    @Test
     public void testKeyword() throws Exception {
         executeJspCompile("testKeyword", "default_jsp.java");
     }
@@ -93,51 +86,47 @@ public class JspcTest extends BuildFileT
     /**
      * what happens to 1nvalid-classname
      */
+    @Test
     public void testInvalidClassname() throws Exception {
         executeJspCompile("testInvalidClassname",
                 "_1nvalid_0002dclassname_jsp.java");
     }
 
 
-    /**
-     * A unit test for JUnit
-     */
+    @Test
     public void testNoTld() throws Exception {
-//         expectBuildExceptionContaining("testNoTld",
-//                 "Jasper found an error in a file",
-//                 "Java returned: 9");
-         expectBuildExceptionContaining("testNoTld",
-                 "not found",
-                 "Java returned: 9");
+        try {
+            buildRule.executeTarget("testNoTld");
+            fail("Not found");
+        } catch (BuildException ex) {
+            assertEquals("Java returned: 9", ex.getMessage());
+        }
     }
 
 
-    /**
-     * A unit test for JUnit
-     */
+    @Test
     public void testNotAJspFile()  throws Exception {
-        executeTarget("testNotAJspFile");
+        buildRule.executeTarget("testNotAJspFile");
     }
 
     /**
      * webapp test is currently broken, because it picks up
      * on the missing_tld file, and bails.
      */
-/*
+    @Ignore("picks up on the missing_tld file, and incorrectly bails")
+    @Test
     public void testWebapp()  throws Exception {
-        executeTarget("testWebapp");
+        buildRule.executeTarget("testWebapp");
     }
-*/
+
     /**
      * run a target then verify the named file gets created
      *
      * @param target Description of Parameter
      * @param javafile Description of Parameter
-     * @exception Exception trouble
      */
-    protected void executeJspCompile(String target, String javafile)
-        throws Exception {
-        executeTarget(target);
+    protected void executeJspCompile(String target, String javafile) {
+        buildRule.executeTarget(target);
         assertJavaFileCreated(javafile);
     }
 
@@ -146,10 +135,8 @@ public class JspcTest extends BuildFileT
      * verify that a named file was created
      *
      * @param filename Description of Parameter
-     * @exception Exception trouble
      */
-    protected void assertJavaFileCreated(String filename)
-        throws Exception {
+    protected void assertJavaFileCreated(String filename) {
         File file = getOutputFile(filename);
         assertTrue("file " + filename + " not found", file.exists());
         assertTrue("file " + filename + " is empty", file.length() > 0);
@@ -162,12 +149,13 @@ public class JspcTest extends BuildFileT
      * @return The OutputFile value
      */
     protected File getOutputFile(String subpath) {
-        return new File(getOutputDir(), subpath);
+        return new File(buildRule.getProject().getProperty("output"), subpath);
     }
 
     /**
      * verify that we select the appropriate mangler
      */
+    @Test
     public void testJasperNameManglerSelection() {
         JspCompilerAdapter adapter=
                 JspCompilerAdapterFactory.getCompiler("jasper", null,null);
@@ -178,6 +166,7 @@ public class JspcTest extends BuildFileT
         assertTrue(mangler instanceof Jasper41Mangler);
     }
 
+    @Test
     public void testJasper41() {
         JspMangler mangler = new Jasper41Mangler();
         //java keywords are not special

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/Native2AsciiTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/Native2AsciiTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/Native2AsciiTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/Native2AsciiTest.java Fri Apr 18 21:00:38 2014
@@ -19,26 +19,39 @@
 package org.apache.tools.ant.taskdefs.optional;
 
 import java.io.File;
-import org.apache.tools.ant.BuildFileTest;
+
+import org.apache.tools.ant.BuildFileRule;
 import org.apache.tools.ant.util.FileUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
 
-public class Native2AsciiTest extends BuildFileTest {
+public class Native2AsciiTest {
 
     private final static String BUILD_XML = 
         "src/etc/testcases/taskdefs/optional/native2ascii/build.xml";
 
-    public Native2AsciiTest(String name) {
-        super(name);
-    }
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
+    @Before
     public void setUp() {
-        configureProject(BUILD_XML);
+        buildRule.configureProject(BUILD_XML);
+    }
+
+    @After
+    public void tearDown() {
+        buildRule.executeTarget("tearDown");
     }
 
+    @Test
     public void testIso8859_1() throws java.io.IOException {
-        executeTarget("testIso8859-1");
-        File in = getProject().resolveFile("expected/iso8859-1.test");
-        File out = new File(getProject().getProperty("output"), "iso8859-1.test");
+        buildRule.executeTarget("testIso8859-1");
+        File in = buildRule.getProject().resolveFile("expected/iso8859-1.test");
+        File out = new File(buildRule.getProject().getProperty("output"), "iso8859-1.test");
         assertTrue(FileUtils.getFileUtils().contentEquals(in, out, true));
     }
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PropertyFileTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PropertyFileTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PropertyFileTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PropertyFileTest.java Fri Apr 18 21:00:38 2014
@@ -20,41 +20,49 @@ package org.apache.tools.ant.taskdefs.op
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
+import java.io.IOException;
 import java.util.Properties;
 
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.BuildFileRule;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 /**
  *  JUnit testcase that exercises the optional PropertyFile task in ant.
  *  (this is really more of a functional test so far.., but it's enough to let
  *   me start refactoring...)
  *
- *@created    October 2, 2001
+ *created    October 2, 2001
  */
 
-public class PropertyFileTest extends BuildFileTest {
-
-    public PropertyFileTest(String name) {
-        super(name);
-    }
+public class PropertyFileTest {
 
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
-    /**
-     *  The JUnit setup method
-     */
+    @Before
     public void setUp() throws Exception {
-        configureProject(projectFilePath);
-        executeTarget("setUp");
+        buildRule.configureProject(projectFilePath);
+        buildRule.executeTarget("setUp");
         initTestPropFile();
         initBuildPropFile();
-        configureProject(projectFilePath);
-        project.setProperty(valueDoesNotGetOverwrittenPropertyFileKey,valueDoesNotGetOverwrittenPropertyFile);
+        buildRule.configureProject(projectFilePath);
+        buildRule.getProject().setProperty(valueDoesNotGetOverwrittenPropertyFileKey,
+                valueDoesNotGetOverwrittenPropertyFile);
     }
 
 
+    @Test
     public void testNonExistingFile() {
         PropertyFile props = new PropertyFile();
-        props.setProject( getProject() );
+        props.setProject( buildRule.getProject() );
         File file = new File("this-file-does-not-exist.properties");
         props.setFile(file);
         assertFalse("Properties file exists before test.", file.exists());
@@ -67,6 +75,7 @@ public class PropertyFileTest extends Bu
      *  A unit test for JUnit- Exercises the propertyfile tasks ability to
      *  update properties that are already defined-
      */
+    @Test
     public void testUpdatesExistingProperties() throws Exception {
         Properties beforeUpdate = getTestProperties();
         assertEquals(FNAME, beforeUpdate.getProperty(FNAME_KEY));
@@ -77,7 +86,7 @@ public class PropertyFileTest extends Bu
         assertEquals(null, beforeUpdate.getProperty(DATE_KEY));
 
         // ask ant to update the properties...
-        executeTarget("update-existing-properties");
+        buildRule.executeTarget("update-existing-properties");
 
         Properties afterUpdate = getTestProperties();
         assertEquals(NEW_FNAME, afterUpdate.getProperty(FNAME_KEY));
@@ -87,7 +96,8 @@ public class PropertyFileTest extends Bu
         assertEquals(NEW_AGE, afterUpdate.getProperty(AGE_KEY));
         assertEquals(NEW_DATE, afterUpdate.getProperty(DATE_KEY));
     }
-    
+
+    @Test
     public void testDeleteProperties() throws Exception {
         Properties beforeUpdate = getTestProperties();
         assertEquals("Property '" + FNAME_KEY + "' should exist before deleting",
@@ -95,7 +105,7 @@ public class PropertyFileTest extends Bu
         assertEquals("Property '" + LNAME_KEY + "' should exist before deleting",
             LNAME, beforeUpdate.getProperty(LNAME_KEY));
         
-        executeTarget("delete-properties");
+        buildRule.executeTarget("delete-properties");
         Properties afterUpdate = getTestProperties();
 
         assertEquals("Property '" + LNAME_KEY + "' should exist after deleting",
@@ -104,49 +114,77 @@ public class PropertyFileTest extends Bu
             afterUpdate.getProperty(FNAME_KEY));
     }
 
+    @Test
     public void testExerciseDefaultAndIncrement() throws Exception {
-        executeTarget("exercise");
-        assertEquals("3",project.getProperty("int.with.default"));
-        assertEquals("1",project.getProperty("int.without.default"));
-        assertEquals("-->",project.getProperty("string.with.default"));
-        assertEquals(".",project.getProperty("string.without.default"));
-        assertEquals("2002/01/21 12:18", project.getProperty("ethans.birth"));
-        assertEquals("2003/01/21", project.getProperty("first.birthday"));
-        assertEquals("0124", project.getProperty("olderThanAWeek"));
-        assertEquals("37", project.getProperty("existing.prop"));
-        assertEquals("6",project.getProperty("int.without.value"));
+        buildRule.executeTarget("exercise");
+        assertEquals("3",buildRule.getProject().getProperty("int.with.default"));
+        assertEquals("1",buildRule.getProject().getProperty("int.without.default"));
+        assertEquals("-->",buildRule.getProject().getProperty("string.with.default"));
+        assertEquals(".",buildRule.getProject().getProperty("string.without.default"));
+        assertEquals("2002/01/21 12:18", buildRule.getProject().getProperty("ethans.birth"));
+        assertEquals("2003/01/21", buildRule.getProject().getProperty("first.birthday"));
+        assertEquals("0124", buildRule.getProject().getProperty("olderThanAWeek"));
+        assertEquals("37", buildRule.getProject().getProperty("existing.prop"));
+        assertEquals("6",buildRule.getProject().getProperty("int.without.value"));
     }
 
+    @Test
     public void testValueDoesNotGetOverwritten() {
         // this test shows that the bug report 21505 is fixed
-        executeTarget("bugDemo1");
-        executeTarget("bugDemo2");
-        assertEquals("5", project.getProperty("foo"));
+        buildRule.executeTarget("bugDemo1");
+        buildRule.executeTarget("bugDemo2");
+        assertEquals("5", buildRule.getProject().getProperty("foo"));
     }
 
+
+    @Test
+    @Ignore("Previously commented out")
+    public void testDirect() throws Exception {
+        PropertyFile pf = new PropertyFile();
+        pf.setProject(buildRule.getProject());
+        pf.setFile(new File(System.getProperty("root"), testPropsFilePath));
+        PropertyFile.Entry entry = pf.createEntry();
+
+        entry.setKey("date");
+        entry.setValue("123");
+        PropertyFile.Entry.Type type = new PropertyFile.Entry.Type();
+        type.setValue("date");
+        entry.setType(type);
+
+        entry.setPattern("yyyy/MM/dd");
+
+        PropertyFile.Entry.Operation operation = new PropertyFile.Entry.Operation();
+        operation.setValue("+");
+        pf.execute();
+
+        Properties props = getTestProperties();
+        assertEquals("yeehaw", props.getProperty("date"));
+    }
+
+
     private Properties getTestProperties() throws Exception {
         Properties testProps = new Properties();
-        FileInputStream propsFile = new FileInputStream(new File(getOutputDir(), testPropsFilePath));
+        FileInputStream propsFile = new FileInputStream(new File(buildRule.getOutputDir(), testPropsFilePath));
         testProps.load(propsFile);
         propsFile.close();
         return testProps;
     }
 
 
-    private void initTestPropFile() throws Exception {
+    private void initTestPropFile() throws IOException {
         Properties testProps = new Properties();
         testProps.put(FNAME_KEY, FNAME);
         testProps.put(LNAME_KEY, LNAME);
         testProps.put(EMAIL_KEY, EMAIL);
         testProps.put("existing.prop", "37");
 
-        FileOutputStream fos = new FileOutputStream(new File(getOutputDir(), testPropsFilePath));
+        FileOutputStream fos = new FileOutputStream(new File(buildRule.getOutputDir(), testPropsFilePath));
         testProps.store(fos, "defaults");
         fos.close();
     }
 
 
-    private void initBuildPropFile() throws Exception {
+    private void initBuildPropFile() throws IOException {
         Properties buildProps = new Properties();
         buildProps.put(testPropertyFileKey, testPropertyFile);
         buildProps.put(FNAME_KEY, NEW_FNAME);
@@ -156,14 +194,11 @@ public class PropertyFileTest extends Bu
         buildProps.put(AGE_KEY, NEW_AGE);
         buildProps.put(DATE_KEY, NEW_DATE);
 
-        FileOutputStream fos = new FileOutputStream(new File(getOutputDir(), buildPropsFilePath));
+        FileOutputStream fos = new FileOutputStream(new File(buildRule.getOutputDir(), buildPropsFilePath));
         buildProps.store(fos, null);
         fos.close();
     }
 
-
-
-
     private static final String
         projectFilePath     = "src/etc/testcases/taskdefs/optional/propertyfile.xml",
 

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PvcsTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PvcsTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PvcsTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PvcsTest.java Fri Apr 18 21:00:38 2014
@@ -18,41 +18,62 @@
 
 package org.apache.tools.ant.taskdefs.optional;
 
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
 
-/**
- */
-public class PvcsTest extends BuildFileTest {
+import static org.junit.Assert.fail;
 
-    public PvcsTest(String name) {
-        super(name);
-    }
+public class PvcsTest {
+
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/optional/pvcs.xml");
+        buildRule.configureProject("src/etc/testcases/taskdefs/optional/pvcs.xml");
     }
 
+    @Test
     public void test1() {
-        expectBuildException("test1", "Required argument repository not specified");
+        try {
+            buildRule.executeTarget("test1");
+            fail("Required argument repository not specified");
+        }  catch (BuildException ex) {
+            //TODO check exception message
+        }
     }
 
+    @Test
     public void test2() {
-        executeTarget("test2");
+        buildRule.executeTarget("test2");
     }
 
+    @Test
     public void test3() {
-        executeTarget("test3");
+        buildRule.executeTarget("test3");
     }
 
+    @Test
     public void test4() {
-        executeTarget("test4");
+        buildRule.executeTarget("test4");
     }
 
+    @Test
     public void test5() {
-        executeTarget("test5");
+        buildRule.executeTarget("test5");
     }
 
+    @Test
     public void test6() {
-        expectBuildException("test6", "Failed executing: /never/heard/of/a/directory/structure/like/this/pcli lvf -z -aw -pr//ct4serv2/pvcs/monitor /. Exception: /never/heard/of/a/directory/structure/like/this/pcli: not found");
+        try {
+            buildRule.executeTarget("test6");
+            fail("Failed executing: /never/heard/of/a/directory/structure/like/this/pcli lvf -z " +
+                    "-aw -pr//ct4serv2/pvcs/monitor /. Exception: /never/heard/of/a/directory/structure/like/this/pcli: not found");
+        } catch(BuildException ex) {
+            //TODO assert exception message
+        }
     }
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ReplaceRegExpTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ReplaceRegExpTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ReplaceRegExpTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ReplaceRegExpTest.java Fri Apr 18 21:00:38 2014
@@ -17,35 +17,44 @@
  */
 package org.apache.tools.ant.taskdefs.optional;
 
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.BuildFileRule;
+import org.apache.tools.ant.FileUtilities;
 import org.apache.tools.ant.util.FileUtils;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
 
 import java.util.Properties;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assume.assumeTrue;
+
 /**
  * JUnit Testcase for the optional replaceregexp task.
  *
  */
-public class ReplaceRegExpTest extends BuildFileTest {
+public class ReplaceRegExpTest {
     private static final String PROJECT_PATH = "src/etc/testcases/taskdefs/optional";
-    private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
     
-    public ReplaceRegExpTest(String name) {
-        super(name);
-    }
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
+    @Before
     public void setUp() {
-        configureProject(PROJECT_PATH + "/replaceregexp.xml");
+        buildRule.configureProject(PROJECT_PATH + "/replaceregexp.xml");
     }
 
+    @Test
     public void testReplace() throws IOException {
         Properties original = new Properties();
         FileInputStream propsFile = null;
         try {
-            propsFile = new FileInputStream(new File(project.getBaseDir() + "/replaceregexp.properties"));
+            propsFile = new FileInputStream(new File(buildRule.getProject().getBaseDir() + "/replaceregexp.properties"));
             original.load(propsFile);
         } finally {
             if (propsFile != null) {
@@ -56,62 +65,68 @@ public class ReplaceRegExpTest extends B
 
         assertEquals("Def", original.get("OldAbc"));
 
-        executeTarget("testReplace");
+        buildRule.executeTarget("testReplace");
 
         Properties after = new Properties();
         try {
-            propsFile = new FileInputStream(new File(getOutputDir(), "test.properties"));
+            propsFile = new FileInputStream(new File(buildRule.getOutputDir(), "test.properties"));
             after.load(propsFile);
         } finally {
             if (propsFile != null) {
                 propsFile.close();
-                propsFile = null;
             }
         }
 
         assertNull(after.get("OldAbc"));
         assertEquals("AbcDef", after.get("NewProp"));
     }
+
     // inspired by bug 22541
+    @Test
     public void testDirectoryDateDoesNotChange() {
-        executeTarget("touchDirectory");
-        File myFile = getOutputDir();
+        buildRule.executeTarget("touchDirectory");
+        File myFile = buildRule.getOutputDir();
         long timeStampBefore = myFile.lastModified();
-        executeTarget("testDirectoryDateDoesNotChange");
+        buildRule.executeTarget("testDirectoryDateDoesNotChange");
         long timeStampAfter = myFile.lastModified();
         assertEquals("directory date should not change",
             timeStampBefore, timeStampAfter);
     }
+
+    @Test
     public void testDontAddNewline1() throws IOException {
-        executeTarget("testDontAddNewline1");
-        assertTrue("Files match",
-                   FILE_UTILS
-                   .contentEquals(new File(getOutputDir(), "test.properties"),
-                                  new File(getProjectDir(), "replaceregexp2.result.properties")));
+        buildRule.executeTarget("testDontAddNewline1");
+        assertEquals(FileUtilities.getFileContents(new File(buildRule.getOutputDir(), "test.properties")),
+                FileUtilities.getFileContents(new File(buildRule.getProject().getBaseDir(), "replaceregexp2.result.properties")));
     }
 
+    @Test
     public void testDontAddNewline2() throws IOException {
-        executeTarget("testDontAddNewline2");
-        assertTrue("Files match",
-                   FILE_UTILS
-                   .contentEquals(new File(getOutputDir(), "test.properties"),
-                                  new File(getProjectDir(), "replaceregexp2.result.properties")));
+        buildRule.executeTarget("testDontAddNewline2");
+        assertEquals(FileUtilities.getFileContents(new File(buildRule.getOutputDir(), "test.properties")),
+                FileUtilities.getFileContents(new File(buildRule.getProject().getBaseDir(), "replaceregexp2.result.properties")));
     }
 
+    @Test
     public void testNoPreserveLastModified() throws Exception {
-        executeTarget("lastModifiedSetup");
-        long ts1 = new File(getOutputDir(), "test.txt").lastModified();
-        Thread.sleep(3000);
-        executeTarget("testNoPreserve");
-        assertTrue(ts1 < new File(getOutputDir(), "test.txt").lastModified());
+        buildRule.executeTarget("lastModifiedSetup");
+        File testFile = new File(buildRule.getOutputDir(), "test.txt");
+        assumeTrue(testFile.setLastModified(testFile.lastModified()
+                - (FileUtils.getFileUtils().getFileTimestampGranularity() * 3)));
+        long ts1 = testFile.lastModified();
+        buildRule.executeTarget("testNoPreserve");
+        assertTrue(ts1 < testFile.lastModified());
     }
 
+    @Test
     public void testPreserveLastModified() throws Exception {
-        executeTarget("lastModifiedSetup");
-        long ts1 = new File(getOutputDir(), "test.txt").lastModified();
-        Thread.sleep(3000);
-        executeTarget("testPreserve");
-        assertTrue(ts1 == new File(getOutputDir(), "test.txt").lastModified());
+        buildRule.executeTarget("lastModifiedSetup");
+        File testFile = new File(buildRule.getOutputDir(), "test.txt");
+        assumeTrue(testFile.setLastModified(testFile.lastModified()
+                - (FileUtils.getFileUtils().getFileTimestampGranularity() * 3)));
+        long ts1 = testFile.lastModified();
+        buildRule.executeTarget("testPreserve");
+        assertEquals(ts1 , testFile.lastModified());
     }
 
 }// ReplaceRegExpTest

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/RhinoReferenceTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/RhinoReferenceTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/RhinoReferenceTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/RhinoReferenceTest.java Fri Apr 18 21:00:38 2014
@@ -17,28 +17,29 @@
  */
 package org.apache.tools.ant.taskdefs.optional;
 
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.BuildFileRule;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
 
 /**
  * Tests using an undefined reference.
  *
  * @since Ant 1.6
  */
-public class RhinoReferenceTest extends BuildFileTest {
+public class RhinoReferenceTest {
 
-    public RhinoReferenceTest(String name) {
-        super(name);
-    }
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
-    /**
-     * The JUnit setup method
-     */
+    @Before
     public void setUp() {
-        configureProject(
-            "src/etc/testcases/taskdefs/optional/script_reference.xml");
+        buildRule.configureProject(
+                "src/etc/testcases/taskdefs/optional/script_reference.xml");
     }
 
+    @Test
     public void testScript() {
-        executeTarget("script");
+        buildRule.executeTarget("script");
     }
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/RhinoScriptTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/RhinoScriptTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/RhinoScriptTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/RhinoScriptTest.java Fri Apr 18 21:00:38 2014
@@ -17,47 +17,50 @@
  */
 package org.apache.tools.ant.taskdefs.optional;
 
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.BuildFileRule;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
 
 /**
  * Tests the examples of the &lt;script&gt; task docs.
  *
  * @since Ant 1.5.2
  */
-public class RhinoScriptTest extends BuildFileTest {
-
-    public RhinoScriptTest(String name) {
-        super(name);
-    }
+public class RhinoScriptTest {
 
-    /**
-     * The JUnit setup method
-     */
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
+    
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/optional/script.xml");
+        buildRule.configureProject("src/etc/testcases/taskdefs/optional/script.xml");
     }
 
+    @Test
     public void testExample1() {
-        executeTarget("example1");
-        int index = getLog().indexOf("1");
+        buildRule.executeTarget("example1");
+        int index = buildRule.getLog().indexOf("1");
         assertTrue(index > -1);
-        index = getLog().indexOf("4", index);
+        index = buildRule.getLog().indexOf("4", index);
         assertTrue(index > -1);
-        index = getLog().indexOf("9", index);
+        index = buildRule.getLog().indexOf("9", index);
         assertTrue(index > -1);
-        index = getLog().indexOf("16", index);
+        index = buildRule.getLog().indexOf("16", index);
         assertTrue(index > -1);
-        index = getLog().indexOf("25", index);
+        index = buildRule.getLog().indexOf("25", index);
         assertTrue(index > -1);
-        index = getLog().indexOf("36", index);
+        index = buildRule.getLog().indexOf("36", index);
         assertTrue(index > -1);
-        index = getLog().indexOf("49", index);
+        index = buildRule.getLog().indexOf("49", index);
         assertTrue(index > -1);
-        index = getLog().indexOf("64", index);
+        index = buildRule.getLog().indexOf("64", index);
         assertTrue(index > -1);
-        index = getLog().indexOf("81", index);
+        index = buildRule.getLog().indexOf("81", index);
         assertTrue(index > -1);
-        index = getLog().indexOf("100", index);
+        index = buildRule.getLog().indexOf("100", index);
         assertTrue(index > -1);
     }
 

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/RpmTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/RpmTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/RpmTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/RpmTest.java Fri Apr 18 21:00:38 2014
@@ -21,10 +21,15 @@ import org.apache.tools.ant.BuildExcepti
 import org.apache.tools.ant.taskdefs.Execute;
 import org.apache.tools.ant.taskdefs.ExecuteStreamHandler;
 import org.apache.tools.ant.types.Commandline;
-import junit.framework.TestCase;
 
-public class RpmTest extends TestCase {
+import org.junit.Test;
 
+import static org.junit.Assert.fail;
+import static org.apache.tools.ant.AntAssert.assertContains;
+
+public class RpmTest {
+
+    @Test
     public void testShouldThrowExceptionWhenRpmFails() throws Exception {
         Rpm rpm = new MyRpm();
         rpm.setProject(new org.apache.tools.ant.Project());
@@ -34,11 +39,11 @@ public class RpmTest extends TestCase {
             rpm.execute();
             fail("should have thrown a build exception");
         } catch (BuildException ex) {
-            assertTrue(ex.getMessage()
-                       .indexOf("' failed with exit code 2") != -1);
+            assertContains("' failed with exit code 2", ex.getMessage());
         }
     }
 
+    @Test
     public void testShouldNotThrowExceptionWhenRpmFails() throws Exception {
         Rpm rpm = new MyRpm();
         rpm.execute();

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/SchemaValidateTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/SchemaValidateTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/SchemaValidateTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/SchemaValidateTest.java Fri Apr 18 21:00:38 2014
@@ -17,13 +17,20 @@
  */
 package org.apache.tools.ant.taskdefs.optional;
 
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.AntAssert;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.fail;
 
 /**
  * Test schema validation
  */
 
-public class SchemaValidateTest extends BuildFileTest {
+public class SchemaValidateTest {
 
     /**
      * where tasks run
@@ -31,69 +38,91 @@ public class SchemaValidateTest extends 
     private final static String TASKDEFS_DIR =
             "src/etc/testcases/taskdefs/optional/";
 
-    /**
-     * Constructor
-     *
-     * @param name testname
-     */
-    public SchemaValidateTest(String name) {
-        super(name);
-    }
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
-    /**
-     * The JUnit setup method
-     */
+    @Before
     public void setUp() {
-        configureProject(TASKDEFS_DIR + "schemavalidate.xml");
+        buildRule.configureProject(TASKDEFS_DIR + "schemavalidate.xml");
     }
 
     /**
      * test with no namespace
      */
+    @Test
     public void testNoNamespace() throws Exception {
-        executeTarget("testNoNamespace");
+        buildRule.executeTarget("testNoNamespace");
     }
 
     /**
      * add namespace awareness.
      */
+    @Test
     public void testNSMapping() throws Exception {
-        executeTarget("testNSMapping");
+        buildRule.executeTarget("testNSMapping");
     }
 
+    @Test
     public void testNoEmptySchemaNamespace() throws Exception {
-        expectBuildExceptionContaining("testNoEmptySchemaNamespace",
-                "empty namespace URI",SchemaValidate.SchemaLocation.ERROR_NO_URI);
+        try {
+            buildRule.executeTarget("testNoEmptySchemaNamespace");
+            fail("Empty namespace URI");
+        } catch (BuildException ex) {
+            AntAssert.assertContains(SchemaValidate.SchemaLocation.ERROR_NO_URI, ex.getMessage());
+        }
     }
 
+    @Test
     public void testNoEmptySchemaLocation() throws Exception {
-        expectBuildExceptionContaining("testNoEmptySchemaLocation",
-                "empty schema location",
-                SchemaValidate.SchemaLocation.ERROR_NO_LOCATION);
+        try {
+            buildRule.executeTarget("testNoEmptySchemaLocation");
+            fail("Empty schema location");
+        } catch (BuildException ex) {
+            AntAssert.assertContains(SchemaValidate.SchemaLocation.ERROR_NO_LOCATION,
+                    ex.getMessage());
+        }
     }
 
+    @Test
     public void testNoFile() throws Exception {
-        expectBuildExceptionContaining("testNoFile",
-                "no file at file attribute",
-                SchemaValidate.SchemaLocation.ERROR_NO_FILE);
+        try {
+            buildRule.executeTarget("testNoFile");
+            fail("No file at file attribute");
+        } catch (BuildException ex) {
+            AntAssert.assertContains(SchemaValidate.SchemaLocation.ERROR_NO_FILE,
+                    ex.getMessage());
+        }
     }
 
+    @Test
     public void testNoDoubleSchemaLocation() throws Exception {
-        expectBuildExceptionContaining("testNoDoubleSchemaLocation",
-                "two locations for schemas",
-                SchemaValidate.SchemaLocation.ERROR_TWO_LOCATIONS);
+        try {
+            buildRule.executeTarget("testNoDoubleSchemaLocation");
+            fail("Two locations for schemas");
+        } catch (BuildException ex) {
+            AntAssert.assertContains(SchemaValidate.SchemaLocation.ERROR_TWO_LOCATIONS,
+                    ex.getMessage());
+        }
     }
+
+    @Test
     public void testNoDuplicateSchema() throws Exception {
-        expectBuildExceptionContaining("testNoDuplicateSchema",
-                "duplicate schemas with different values",
-                SchemaValidate.ERROR_DUPLICATE_SCHEMA);
+        try {
+            buildRule.executeTarget("testNoDuplicateSchema");
+            fail("duplicate schemas with different values");
+        } catch (BuildException ex) {
+            AntAssert.assertContains(SchemaValidate.ERROR_DUPLICATE_SCHEMA,
+                    ex.getMessage());
+        }
     }
 
+    @Test
     public void testEqualsSchemasOK() throws Exception {
-        executeTarget("testEqualsSchemasOK");
+        buildRule.executeTarget("testEqualsSchemasOK");
     }
 
+    @Test
     public void testFileset() throws Exception {
-        executeTarget("testFileset");
+        buildRule.executeTarget("testFileset");
     }
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java Fri Apr 18 21:00:38 2014
@@ -1,9 +1,6 @@
 package org.apache.tools.ant.taskdefs.optional;
 
-import org.apache.tools.ant.taskdefs.XSLTLiaison;
-import org.apache.tools.ant.taskdefs.XSLTLogger;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.util.JAXPUtils;
+import static org.junit.Assert.assertTrue;
 
 import java.io.ByteArrayInputStream;
 import java.io.File;
@@ -12,6 +9,14 @@ import java.security.Permission;
 
 import junit.framework.AssertionFailedError;
 
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.taskdefs.XSLTLiaison;
+import org.apache.tools.ant.taskdefs.XSLTLogger;
+import org.apache.tools.ant.util.JAXPUtils;
+import org.junit.After;
+import org.junit.Assume;
+import org.junit.Test;
+
 /*
  *  Licensed to the Apache Software Foundation (ASF) under one or more
  *  contributor license agreements.  See the NOTICE file distributed with
@@ -36,10 +41,8 @@ import junit.framework.AssertionFailedEr
 public class TraXLiaisonTest extends AbstractXSLTLiaisonTest
     implements XSLTLogger {
 
-    public TraXLiaisonTest(String name){
-        super(name);
-    }
 
+	@After
     public void tearDown() {
         File f = new File("xalan2-redirect-out.tmp");
         if (f.exists()) {
@@ -53,16 +56,12 @@ public class TraXLiaisonTest extends Abs
         return l;
     }
 
+    @Test
     public void testXalan2Redirect() throws Exception {
-    	Class clazz = null;
     	try {
-    		clazz = getClass().getClassLoader().loadClass("org.apache.xalan.lib.Redirect");
+    		getClass().getClassLoader().loadClass("org.apache.xalan.lib.Redirect");
     	} catch (Exception exc) {
-    		// ignore
-    	}
-    	if (clazz == null) {
-    		System.out.println("xalan redirect is not on the classpath");
-    		return;
+    		Assume.assumeNoException("xalan redirect is not on the classpath", exc);
     	}
         File xsl = getFile("/taskdefs/optional/xalan-redirect-in.xsl");
         liaison.setStylesheet(xsl);
@@ -91,6 +90,7 @@ public class TraXLiaisonTest extends Abs
         }
     }
 
+    @Test
     public void testMultipleTransform() throws Exception {
         File xsl = getFile("/taskdefs/optional/xsltliaison-in.xsl");
         liaison.setStylesheet(xsl);
@@ -109,6 +109,7 @@ public class TraXLiaisonTest extends Abs
         }
     }
 
+    @Test
     public void testSystemId(){
         File file = null;
         if ( File.separatorChar == '\\' ){

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateCatalogTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateCatalogTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateCatalogTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateCatalogTest.java Fri Apr 18 21:00:38 2014
@@ -17,7 +17,10 @@
  */
 package org.apache.tools.ant.taskdefs.optional;
 
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.BuildFileRule;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
 
 /**
  * Tests the XMLValidate optional task with nested external catalogs.
@@ -25,48 +28,32 @@ import org.apache.tools.ant.BuildFileTes
  * @see XmlValidateTest
  * @since Ant 1.6
  */
-public class XmlValidateCatalogTest extends BuildFileTest {
+public class XmlValidateCatalogTest {
 
     /**
      * where tasks run
      */
     private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/";
 
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
-    /**
-     * Constructor
-     *
-     * @param name testname
-     */
-    public XmlValidateCatalogTest(String name) {
-        super(name);
-    }
-
-
-    /**
-     * The JUnit setup method
-     */
+    @Before
     public void setUp() {
-        configureProject(TASKDEFS_DIR + "xmlvalidate.xml");
+        buildRule.configureProject(TASKDEFS_DIR + "xmlvalidate.xml");
     }
 
 
     /**
-     * The teardown method for JUnit
-     */
-    public void tearDown() {
-
-    }
-
-    /**
      * catalogfiles fileset should be ignored
      * if resolver.jar is not present, but will
      * be used if it is.  either way, test should
      * work b/c we have a nested dtd with the same
      * entity
      */
+    @Test
     public void testXmlCatalogFiles() {
-        executeTarget("xmlcatalogfiles");
+        buildRule.executeTarget("xmlcatalogfiles");
     }
 
     /**
@@ -76,8 +63,9 @@ public class XmlValidateCatalogTest exte
      * way, test should work b/c we have a nested
      * dtd with the same entity
      */
+    @Test
     public void testXmlCatalogPath() {
-        executeTarget("xmlcatalogpath");
+        buildRule.executeTarget("xmlcatalogpath");
     }
 
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java Fri Apr 18 21:00:38 2014
@@ -18,7 +18,14 @@
 package org.apache.tools.ant.taskdefs.optional;
 
 import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.BuildFileRule;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.internal.AssumptionViolatedException;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 /**
  * Tests the XMLValidate optional task, by running targets in the test script
@@ -28,7 +35,7 @@ import org.apache.tools.ant.BuildFileTes
  * @see XmlValidateCatalogTest
  * @since Ant 1.5
  */
-public class XmlValidateTest extends BuildFileTest {
+public class XmlValidateTest {
 
     /**
      * where tasks run
@@ -36,61 +43,47 @@ public class XmlValidateTest extends Bui
     private final static String TASKDEFS_DIR =
         "src/etc/testcases/taskdefs/optional/";
 
-    /**
-     * Constructor
-     *
-     * @param name testname
-     */
-    public XmlValidateTest(String name) {
-        super(name);
-    }
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
-    /**
-     * The JUnit setup method
-     */
+    @Before
     public void setUp() {
-        configureProject(TASKDEFS_DIR + "xmlvalidate.xml");
+        buildRule.configureProject(TASKDEFS_DIR + "xmlvalidate.xml");
     }
 
     /**
-     * The teardown method for JUnit
-     */
-    public void tearDown() {}
-
-    /**
      * Basic inline 'dtd' element test.
      */
+    @Test
     public void testValidate() throws Exception {
-        executeTarget("testValidate");
+        buildRule.executeTarget("testValidate");
     }
 
     /**
      * Test indirect validation.
      */
+    @Test
     public void testDeepValidate() throws Exception {
-        executeTarget("testDeepValidate");
+        buildRule.executeTarget("testDeepValidate");
     }
 
-    /**
-     *
-     */
+    @Test
     public void testXmlCatalog() {
-        executeTarget("xmlcatalog");
+        buildRule.executeTarget("xmlcatalog");
     }
 
-    /**
-     *
-     */
+    @Test
     public void testXmlCatalogViaRefid() {
-        executeTarget("xmlcatalogViaRefid");
+        buildRule.executeTarget("xmlcatalogViaRefid");
     }
 
     /**
      * Test that the nested dtd element is used when resolver.jar is not
      * present.  This test should pass either way.
      */
+    @Test
     public void testXmlCatalogFiles() {
-        executeTarget("xmlcatalogfiles-override");
+        buildRule.executeTarget("xmlcatalogfiles-override");
     }
 
     /**
@@ -98,30 +91,33 @@ public class XmlValidateTest extends Bui
      * Test that the nested dtd element is used when resolver.jar is not
      * present.  This test should pass either way.
      */
+    @Test
     public void testXmlCatalogPath() {
-        executeTarget("xmlcatalogpath-override");
+        buildRule.executeTarget("xmlcatalogpath-override");
     }
 
     /**
      * Test nested xmlcatalog definitions
      */
+    @Test
     public void testXmlCatalogNested() {
-        executeTarget("xmlcatalognested");
+        buildRule.executeTarget("xmlcatalognested");
     }
 
     /**
      * Test xml schema validation
      */
+    @Test
     public void testXmlSchemaGood() throws BuildException {
         try {
-            executeTarget("testSchemaGood");
+            buildRule.executeTarget("testSchemaGood");
         } catch (BuildException e) {
             if (e
                 .getMessage()
                 .endsWith(" doesn't recognize feature http://apache.org/xml/features/validation/schema")
                 || e.getMessage().endsWith(
                     " doesn't support feature http://apache.org/xml/features/validation/schema")) {
-                System.err.println(" skipped, parser doesn't support schema");
+                throw new AssumptionViolatedException("parser doesn't support schema");
             } else {
                 throw e;
             }
@@ -130,22 +126,19 @@ public class XmlValidateTest extends Bui
     /**
      * Test xml schema validation
      */
+    @Test
     public void testXmlSchemaBad() {
         try {
-            executeTarget("testSchemaBad");
+            buildRule.executeTarget("testSchemaBad");
             fail("Should throw BuildException because 'Bad Schema Validation'");
 
-            expectBuildExceptionContaining(
-                "testSchemaBad",
-                "Bad Schema Validation",
-                "not a valid XML document");
         } catch (BuildException e) {
             if (e
                 .getMessage()
                 .endsWith(" doesn't recognize feature http://apache.org/xml/features/validation/schema")
                 || e.getMessage().endsWith(
                     " doesn't support feature http://apache.org/xml/features/validation/schema")) {
-                System.err.println(" skipped, parser doesn't support schema");
+                throw new AssumptionViolatedException("parser doesn't support schema");
             } else {
                 assertTrue(
                     e.getMessage().indexOf("not a valid XML document") > -1);
@@ -159,8 +152,9 @@ public class XmlValidateTest extends Bui
      *
      * Bug 11279
      */
+    @Test
     public void testIso2022Jp() {
-        executeTarget("testIso2022Jp");
+        buildRule.executeTarget("testIso2022Jp");
     }
 
     /**
@@ -170,20 +164,30 @@ public class XmlValidateTest extends Bui
      *
      * Bug 11279
      */
+    @Test
     public void testUtf8() {
-        expectBuildException("testUtf8", "invalid characters in file");
+        try {
+            buildRule.executeTarget("testUtf8");
+            fail("Invalid characters in file");
+        } catch(BuildException ex) {
+          //TODO assert exception message
+        }
     }
 
     // Tests property element, using XML schema properties as an example.
-
+    @Test
     public void testPropertySchemaForValidXML() {
-        executeTarget("testProperty.validXML");
+        buildRule.executeTarget("testProperty.validXML");
     }
 
+    @Test
     public void testPropertySchemaForInvalidXML() {
-        expectBuildException(
-            "testProperty.invalidXML",
-            "XML file does not satisfy schema.");
+        try {
+            buildRule.executeTarget("testProperty.invalidXML");
+            fail("XML file does not satisfy schema");
+        } catch(BuildException ex) {
+            //TODO assert exception message
+        }
     }
 
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java Fri Apr 18 21:00:38 2014
@@ -17,71 +17,68 @@
  */
 package org.apache.tools.ant.taskdefs.optional;
 
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.fail;
 
 /**
- * Tests the {@link XSLTProcess} task.
- * TODO merge with {@link StyleTest}?
+ * Tests the {@link org.apache.tools.ant.taskdefs.XSLTProcess} task.
+ * TODO merge with {@link org.apache.tools.ant.taskdefs.StyleTest}?
  * @since Ant 1.5
  */
-public class XsltTest extends BuildFileTest {
+public class XsltTest {
 
     /**
      * where tasks run
      */
     private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/";
 
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
-    /**
-     * Constructor
-     *
-     * @param name testname
-     */
-    public XsltTest(String name) {
-        super(name);
-    }
-
-
-    /**
-     * The JUnit setup method
-     */
+    @Before
     public void setUp() {
-        configureProject(TASKDEFS_DIR + "xslt.xml");
+        buildRule.configureProject(TASKDEFS_DIR + "xslt.xml");
     }
 
 
-
-    /**
-     * A unit test for JUnit
-     */
-    public void testCatchNoDtd() throws Exception {
-        expectBuildExceptionContaining("testCatchNoDtd",
-                                       "expected failure",
-                                       /* actually: "chemical" */null);
+    @Test
+    public void testCatchNoDtd() {
+        try {
+            buildRule.executeTarget("testCatchNoDtd");
+            fail("Expected failure");
+        } catch(BuildException ex) {
+            //TODO assert exception message
+        }
     }
 
-    /**
-     * A unit test for JUnit
-     */
+    @Test
     public void testCatalog() throws Exception {
-         executeTarget("testCatalog");
+         buildRule.executeTarget("testCatalog");
     }
 
+    @Test
     public void testOutputProperty() throws Exception {
-      executeTarget("testOutputProperty");
+      buildRule.executeTarget("testOutputProperty");
     }
 
+    @Test
     public void testXMLWithEntitiesInNonAsciiPath() throws Exception {
-        executeTarget("testXMLWithEntitiesInNonAsciiPath");
+        buildRule.executeTarget("testXMLWithEntitiesInNonAsciiPath");
     }
 
     /**
      * check that the system id gets set properly on stylesheets.
      * @throws Exception if something goes wrong.
      */
+    @Test
     public void testStyleSheetWithInclude() throws Exception {
-        executeTarget("testStyleSheetWithInclude");
-        if (getLog().indexOf("java.io.FileNotFoundException") != -1) {
+        buildRule.executeTarget("testStyleSheetWithInclude");
+        if (buildRule.getLog().indexOf("java.io.FileNotFoundException") != -1) {
             fail("xsl:include was not found");
         }
     }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/depend/DependTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/depend/DependTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/depend/DependTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/depend/DependTest.java Fri Apr 18 21:00:38 2014
@@ -18,35 +18,53 @@
 
 package org.apache.tools.ant.taskdefs.optional.depend;
 
+import java.io.File;
 import java.util.Hashtable;
 
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
 import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.FileUtilities;
 import org.apache.tools.ant.types.FileSet;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.apache.tools.ant.AntAssert.assertContains;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 /**
  * Testcase for the Depend optional task.
  *
  */
-public class DependTest extends BuildFileTest {
+public class DependTest {
     public static final String RESULT_FILESET = "result";
 
     public static final String TEST_BUILD_FILE
         = "src/etc/testcases/taskdefs/optional/depend/depend.xml";
 
-    public DependTest(String name) {
-        super(name);
-    }
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
+    @Before
     public void setUp() {
-        configureProject(TEST_BUILD_FILE);
+        buildRule.configureProject(TEST_BUILD_FILE);
     }
 
     /**
      * Test direct dependency removal
      */
+    @Test
     public void testDirect() {
-        executeTarget("testdirect");
+        buildRule.executeTarget("src1setup");
+        buildRule.executeTarget("compile");
+
+        FileUtilities.rollbackTimetamps(new File(buildRule.getProject().getProperty("tempsrc.dir")), 5);
+        FileUtilities.rollbackTimetamps(new File(buildRule.getProject().getProperty("classes.dir")), 5);
+
+        buildRule.executeTarget("testdirect");
         Hashtable files = getResultFiles();
         assertEquals("Depend did not leave correct number of files", 3,
             files.size());
@@ -59,8 +77,15 @@ public class DependTest extends BuildFil
     /**
      * Test dependency traversal (closure)
      */
+    @Test
     public void testClosure() {
-        executeTarget("testclosure");
+        buildRule.executeTarget("src1setup");
+        buildRule.executeTarget("compile");
+
+        FileUtilities.rollbackTimetamps(new File(buildRule.getProject().getProperty("tempsrc.dir")), 5);
+        FileUtilities.rollbackTimetamps(new File(buildRule.getProject().getProperty("classes.dir")), 5);
+
+        buildRule.executeTarget("testclosure");
         Hashtable files = getResultFiles();
         assertTrue("Depend did not leave correct number of files", 
             files.size() <= 2);
@@ -71,8 +96,16 @@ public class DependTest extends BuildFil
     /**
      * Test that inner class dependencies trigger deletion of the outer class
      */
+    @Test
     public void testInner() {
-        executeTarget("testinner");
+        buildRule.executeTarget("src2setup");
+        buildRule.executeTarget("compile");
+
+        FileUtilities.rollbackTimetamps(new File(buildRule.getProject().getProperty("tempsrc.dir")), 5);
+        FileUtilities.rollbackTimetamps(new File(buildRule.getProject().getProperty("classes.dir")), 5);
+
+
+        buildRule.executeTarget("testinner");
         assertEquals("Depend did not leave correct number of files", 0,
             getResultFiles().size());
     }
@@ -81,8 +114,15 @@ public class DependTest extends BuildFil
      * Test that multi-leve inner class dependencies trigger deletion of
      * the outer class
      */
+    @Test
     public void testInnerInner() {
-        executeTarget("testinnerinner");
+        buildRule.executeTarget("src3setup");
+        buildRule.executeTarget("compile");
+
+        FileUtilities.rollbackTimetamps(new File(buildRule.getProject().getProperty("tempsrc.dir")), 5);
+        FileUtilities.rollbackTimetamps(new File(buildRule.getProject().getProperty("classes.dir")), 5);
+
+        buildRule.executeTarget("testinnerinner");
         assertEquals("Depend did not leave correct number of files", 0,
             getResultFiles().size());
     }
@@ -90,17 +130,27 @@ public class DependTest extends BuildFil
     /**
      * Test that an exception is thrown when there is no source
      */
+    @Test
     public void testNoSource() {
-        expectBuildExceptionContaining("testnosource",
-            "No source specified", "srcdir attribute must be set");
+        try {
+            buildRule.executeTarget("testnosource");
+            fail("Build exception expected: No source specified");
+        } catch(BuildException ex) {
+            assertContains("srcdir attribute must be set", ex.getMessage());
+        }
     }
 
     /**
      * Test that an exception is thrown when the source attribute is empty
      */
+    @Test
     public void testEmptySource() {
-        expectBuildExceptionContaining("testemptysource",
-            "No source specified", "srcdir attribute must be non-empty");
+        try {
+            buildRule.executeTarget("testemptysource");
+            fail("Build exception expected: No source specified");
+        } catch(BuildException ex) {
+            assertContains("srcdir attribute must be non-empty", ex.getMessage());
+        }
     }
 
     /**
@@ -110,8 +160,8 @@ public class DependTest extends BuildFil
      * fileset
      */
     private Hashtable getResultFiles() {
-        FileSet resultFileSet = (FileSet) project.getReference(RESULT_FILESET);
-        DirectoryScanner scanner = resultFileSet.getDirectoryScanner(project);
+        FileSet resultFileSet = (FileSet) buildRule.getProject().getReference(RESULT_FILESET);
+        DirectoryScanner scanner = resultFileSet.getDirectoryScanner(buildRule.getProject());
         String[] scannedFiles = scanner.getIncludedFiles();
         Hashtable files = new Hashtable();
         for (int i = 0; i < scannedFiles.length; ++i) {
@@ -125,8 +175,9 @@ public class DependTest extends BuildFil
      * Test mutual dependency between inner and outer do not cause both to be
      * deleted
      */
+    @Test
     public void testInnerClosure() {
-        executeTarget("testinnerclosure");
+        buildRule.executeTarget("testinnerclosure");
         assertEquals("Depend did not leave correct number of files", 4,
             getResultFiles().size());
     }
@@ -134,21 +185,29 @@ public class DependTest extends BuildFil
     /**
      * Test the operation of the cache
      */
+    @Test
     public void testCache() {
-        executeTarget("testcache");
+        buildRule.executeTarget("testcache");
     }
 
     /**
      * Test the detection and warning of non public classes
      */
+    @Test
     public void testNonPublic() {
-        executeTarget("testnonpublic");
-        String log = getLog();
-        assertTrue("Expected warning about APrivate",
-            log.indexOf("The class APrivate in file") != -1);
-        assertTrue("but has not been deleted because its source file "
+        buildRule.executeTarget("src5setup");
+        buildRule.executeTarget("compile");
+
+        FileUtilities.rollbackTimetamps(new File(buildRule.getProject().getProperty("tempsrc.dir")), 5);
+        FileUtilities.rollbackTimetamps(new File(buildRule.getProject().getProperty("classes.dir")), 5);
+
+        buildRule.executeTarget("testnonpublic");
+        String log = buildRule.getLog();
+        assertContains("Expected warning about APrivate",
+            "The class APrivate in file", log);
+        assertContains("but has not been deleted because its source file "
             + "could not be determined",
-            log.indexOf("The class APrivate in file") != -1);
+            "The class APrivate in file", log);
     }
 
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/i18n/TranslateTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/i18n/TranslateTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/i18n/TranslateTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/i18n/TranslateTest.java Fri Apr 18 21:00:38 2014
@@ -18,73 +18,70 @@
 
 package org.apache.tools.ant.taskdefs.optional.i18n;
 
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.BuildFileRule;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
 
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 
+import static org.junit.Assert.assertTrue;
+
 /**
  * Tests the Translate task.
  *
  * @since     Ant 1.6
  */
-public class TranslateTest extends BuildFileTest {
+public class TranslateTest {
+
+    @Rule
+    public final BuildFileRule buildRule = new BuildFileRule();
+
     static private final int BUF_SIZE = 32768;
 
     private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/i18n/translate";
 
-    public TranslateTest(String name) {
-        super(name);
-    }
 
 
+    @Before
     public void setUp() {
-        configureProject(TASKDEFS_DIR + "/translate.xml");
+        buildRule.configureProject(TASKDEFS_DIR + "/translate.xml");
     }
 
-    public void test1() {
-        executeTarget("test1");
-        assertTrue("translation of "+ TASKDEFS_DIR + "/input/template.txt",compareFiles(new File(getProjectDir(), "expected/de/template.txt"),
-                new File(getOutputDir(), "de/template.txt")));
+    @Test
+    public void test1() throws IOException {
+        buildRule.executeTarget("test1");
+        assertTrue("translation of "+ TASKDEFS_DIR + "/input/template.txt",compareFiles(new File(buildRule.getProject().getBaseDir(), "expected/de/template.txt"),
+                new File(buildRule.getOutputDir(), "de/template.txt")));
     }
-    private boolean compareFiles(File file1, File file2) {
-        try {
-            if (!file1.exists() || !file2.exists()) {
-                System.out.println("One or both files do not exist:" + file1.getAbsoluteFile() + ", " + file2.getAbsoluteFile());
-                return false;
-            }
+    private boolean compareFiles(File file1, File file2) throws IOException {
+        if (!file1.exists() || !file2.exists()) {
+            return false;
+        }
 
-            if (file1.length() != file2.length()) {
-                System.out.println("File size mismatch:" + file1.getAbsoluteFile() + "(" + file1.length() + "), " +
-                                   file2.getAbsoluteFile()  + "(" + file2.length() + ")");
-                return false;
-            }
+        if (file1.length() != file2.length()) {
+            return false;
+        }
 
-            // byte - byte compare
-            byte[] buffer1 = new byte[BUF_SIZE];
-            byte[] buffer2 = new byte[BUF_SIZE];
-
-            FileInputStream fis1 = new FileInputStream(file1);
-            FileInputStream fis2 = new FileInputStream(file2);
-            int index = 0;
-            int read = 0;
-            while ((read = fis1.read(buffer1)) != -1) {
-                fis2.read(buffer2);
-                for (int i = 0; i < read; ++i, ++index) {
-                    if (buffer1[i] != buffer2[i]) {
-                        System.out.println("Bytes mismatch:" + file1.getAbsoluteFile() + ", " + file2.getAbsoluteFile() +
-                                           " at byte " + index);
-                        return false;
-                    }
+        // byte - byte compare
+        byte[] buffer1 = new byte[BUF_SIZE];
+        byte[] buffer2 = new byte[BUF_SIZE];
+
+        FileInputStream fis1 = new FileInputStream(file1);
+        FileInputStream fis2 = new FileInputStream(file2);
+        int index = 0;
+        int read = 0;
+        while ((read = fis1.read(buffer1)) != -1) {
+            fis2.read(buffer2);
+            for (int i = 0; i < read; ++i, ++index) {
+                if (buffer1[i] != buffer2[i]) {
+                    return false;
                 }
             }
-            return true;
-        }
-        catch (IOException e) {
-            System.out.println("IOException comparing files: " + file1.getAbsoluteFile() + ", " + file2.getAbsoluteFile());
-            return false;
         }
+        return true;
     }
 }
 

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java Fri Apr 18 21:00:38 2014
@@ -18,18 +18,26 @@
 
 package org.apache.tools.ant.taskdefs.optional.image;
 
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.AntAssert;
+import org.apache.tools.ant.BuildFileRule;
 import org.apache.tools.ant.util.FileUtils;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
 
 import java.io.File;
 
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeTrue;
+
 
 /**
  * Tests the Image task.
  *
  * @since     Ant 1.5
  */
-public class ImageTest extends BuildFileTest {
+public class ImageTest {
 
     private final static String TASKDEFS_DIR = 
         "src/etc/testcases/taskdefs/optional/image/";
@@ -37,69 +45,80 @@ public class ImageTest extends BuildFile
 
     private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
 
-    public ImageTest(String name) {
-        super(name);
-    }
-
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
+    @Before
     public void setUp() {
-        configureProject(TASKDEFS_DIR + "image.xml");
+        buildRule.configureProject(TASKDEFS_DIR + "image.xml");
     }
 
 
+    @Test
     public void testEchoToLog() {
-        expectLogContaining("testEchoToLog", "Processing File");
+        buildRule.executeTarget("testEchoToLog");
+        AntAssert.assertContains("Processing File", buildRule.getLog());
     }
 
+    @Test
     public void testSimpleScale(){
-        expectLogContaining("testSimpleScale", "Processing File");
-        File f = new File(getOutputDir(), LARGEIMAGE);
+        buildRule.executeTarget("testSimpleScale");
+        AntAssert.assertContains("Processing File", buildRule.getLog());
+
+        File f = new File(buildRule.getOutputDir(), LARGEIMAGE);
         assertTrue(
                    "Did not create "+f.getAbsolutePath(),
                    f.exists());
 
     }
 
-    public void testOverwriteTrue() {
-        expectLogContaining("testSimpleScale", "Processing File");
-        File f = new File(getOutputDir(), LARGEIMAGE);
+    @Test
+    public void testOverwriteTrue() throws InterruptedException {
+        buildRule.executeTarget("testSimpleScale");
+        AntAssert.assertContains("Processing File", buildRule.getLog());
+        File f = new File(buildRule.getOutputDir(), LARGEIMAGE);
+        assumeTrue("Could not change file modificaiton date",
+                f.setLastModified(f.lastModified() - (FILE_UTILS.getFileTimestampGranularity() * 2)));
         long lastModified = f.lastModified();
-        try {
-            Thread.sleep(FILE_UTILS
-                         .getFileTimestampGranularity());
-        }
-        catch (InterruptedException e) {}
-        expectLogContaining("testOverwriteTrue", "Processing File");
-        f = new File(getOutputDir(), LARGEIMAGE);
+        buildRule.executeTarget("testOverwriteTrue");
+        AntAssert.assertContains("Processing File", buildRule.getLog());
+        f = new File(buildRule.getOutputDir(), LARGEIMAGE);
         long overwrittenLastModified = f.lastModified();
         assertTrue("File was not overwritten.",
                    lastModified < overwrittenLastModified);
     }
 
+    @Test
     public void testOverwriteFalse() {
-        expectLogContaining("testSimpleScale", "Processing File");
-        File f = new File(getOutputDir(), LARGEIMAGE);
+        buildRule.executeTarget("testSimpleScale");
+        AntAssert.assertContains("Processing File", buildRule.getLog());
+        File f = new File(buildRule.getOutputDir(), LARGEIMAGE);
         long lastModified = f.lastModified();
-        expectLogContaining("testOverwriteFalse", "Processing File");
-        f = new File(getOutputDir(), LARGEIMAGE);
+        buildRule.executeTarget("testOverwriteFalse");
+        AntAssert.assertContains("Processing File", buildRule.getLog());
+        f = new File(buildRule.getOutputDir(), LARGEIMAGE);
         long overwrittenLastModified = f.lastModified();
         assertTrue("File was overwritten.",
                    lastModified == overwrittenLastModified);
     }
 
+    @Test
     public void testSimpleScaleWithMapper() {
-        expectLogContaining("testSimpleScaleWithMapper", "Processing File");
-        File f = new File(getOutputDir(), "scaled-" + LARGEIMAGE);
+        buildRule.executeTarget("testSimpleScaleWithMapper");
+        AntAssert.assertContains("Processing File", buildRule.getLog());
+        File f = new File(buildRule.getOutputDir(), "scaled-" + LARGEIMAGE);
         assertTrue(
                    "Did not create "+f.getAbsolutePath(),
                    f.exists());
 
     }
 
-    public void off_testFailOnError() {
+    @Test
+    @Ignore("Previously named in a manner to prevent execution")
+    public void testFailOnError() {
         try {
-            expectLogContaining("testFailOnError", 
-                                "Unable to process image stream");
+            buildRule.executeTarget("testFailOnError");
+            AntAssert.assertContains("Unable to process image stream", buildRule.getLog());
         }
         catch (RuntimeException re){
             assertTrue("Run time exception should say "
@@ -109,5 +128,6 @@ public class ImageTest extends BuildFile
                        .indexOf("Unable to process image stream") > -1);
         }
     }
+
 }