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 [4/16] - in /ant/core/trunk: ./ manual/ manual/Types/ src/etc/testcases/taskdefs/ src/etc/testcases/taskdefs/optional/ src/etc/testcases/taskdefs/optional/antlr/ src/etc/testcases/taskdefs/optional/depend/ src/etc/testcases/taskdef...

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AvailableTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AvailableTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AvailableTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AvailableTest.java Fri Apr 18 21:00:38 2014
@@ -18,102 +18,140 @@
 
 package org.apache.tools.ant.taskdefs;
 
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 /**
  * JUnit test for the Available task/condition.
  */
-public class AvailableTest extends BuildFileTest {
-
-    public AvailableTest(String name) {
-        super(name);
-    }
+public class AvailableTest {
 
+    
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
+    
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/available.xml");
-        executeTarget("setUp");
+        buildRule.configureProject("src/etc/testcases/taskdefs/available.xml");
+        buildRule.executeTarget("setUp");
     }
 
     // Nothing specified -> Fail
+    @Test
     public void test1() {
-        expectBuildException("test1", "required argument not specified");
+        try {
+            buildRule.executeTarget("test1");
+            fail("Required argument not specified");
+        } catch (BuildException ex) {
+            //TODO assert exception message
+        }
     }
 
     // Only property specified -> Fail
+    @Test
     public void test2() {
-        expectBuildException("test2", "required argument not specified");
+        try {
+            buildRule.executeTarget("test2");
+            fail("Required argument not specified");
+        } catch (BuildException ex) {
+            //TODO assert exception message
+        }
     }
 
     // Only file specified -> Fail
+    @Test
     public void test3() {
-        expectBuildException("test3", "required argument not specified");
+        try {
+            buildRule.executeTarget("test3");
+            fail("Required argument not specified");
+        } catch (BuildException ex) {
+            //TODO assert exception message
+        }
     }
 
     // file doesn't exist -> property 'test' == null
+    @Test
     public void test4() {
-        executeTarget("test4");
-        assertTrue(project.getProperty("test") == null);
+        buildRule.executeTarget("test4");
+        assertTrue(buildRule.getProject().getProperty("test") == null);
     }
 
     // file does exist -> property 'test' == 'true'
     public void test5() {
-        executeTarget("test5");
-        assertEquals("true", project.getProperty("test"));
+        buildRule.executeTarget("test5");
+        assertEquals("true", buildRule.getProject().getProperty("test"));
     }
 
     // resource doesn't exist -> property 'test' == null
+    @Test
     public void test6() {
-        executeTarget("test6");
-        assertTrue(project.getProperty("test") == null);
+        buildRule.executeTarget("test6");
+        assertTrue(buildRule.getProject().getProperty("test") == null);
     }
 
     // resource does exist -> property 'test' == 'true'
+    @Test
     public void test7() {
-        executeTarget("test7");
-        assertEquals("true", project.getProperty("test"));
+        buildRule.executeTarget("test7");
+        assertEquals("true", buildRule.getProject().getProperty("test"));
     }
 
     // class doesn't exist -> property 'test' == null
+    @Test
     public void test8() {
-        executeTarget("test8");
-        assertTrue(project.getProperty("test") == null);
+        buildRule.executeTarget("test8");
+        assertTrue(buildRule.getProject().getProperty("test") == null);
     }
 
     // class does exist -> property 'test' == 'true'
+    @Test
     public void test9() {
-        executeTarget("test9");
-        assertEquals("true", project.getProperty("test"));
+        buildRule.executeTarget("test9");
+        assertEquals("true", buildRule.getProject().getProperty("test"));
     }
 
     // All three specified and all three exist -> true
+    @Test
     public void test10() {
-        executeTarget("test10");
-        assertEquals("true", project.getProperty("test"));
+        buildRule.executeTarget("test10");
+        assertEquals("true", buildRule.getProject().getProperty("test"));
     }
 
     // All three specified but class missing -> null
+    @Test
     public void test11() {
-        executeTarget("test11");
-        assertNull(project.getProperty("test"));
+        buildRule.executeTarget("test11");
+        assertNull(buildRule.getProject().getProperty("test"));
     }
 
     // Specified property-name is "" -> true
+    @Test
     public void test12() {
-        executeTarget("test12");
-        assertNull(project.getProperty("test"));
-        assertEquals("true", project.getProperty(""));
+        buildRule.executeTarget("test12");
+        assertNull(buildRule.getProject().getProperty("test"));
+        assertEquals("true", buildRule.getProject().getProperty(""));
     }
 
     // Specified file is "" -> invalid files do not exist
+    @Test
     public void test13() {
-        executeTarget("test13");
-        assertNull(project.getProperty("test"));
+        buildRule.executeTarget("test13");
+        assertNull(buildRule.getProject().getProperty("test"));
     }
 
     // Specified file is "" actually a directory, so it should pass
+    @Test
     public void test13b() {
-        executeTarget("test13b");
-        assertEquals("true", project.getProperty("test"));
+        buildRule.executeTarget("test13b");
+        assertEquals("true", buildRule.getProject().getProperty("test"));
     }
 
     // Specified resource is "" -> can such a thing exist?
@@ -121,94 +159,114 @@ public class AvailableTest extends Build
      * returns non null IBM JDK 1.3 Linux
      */
 //    public void test14() {
-//        executeTarget("test14");
-//        assertEquals(project.getProperty("test"), null);
+//        buildRule.executeTarget("test14");
+//        assertEquals(buildRule.getProject().getProperty("test"), null);
 //    }
 
     // Specified class is "" -> can not exist
+    @Test
     public void test15() {
-        executeTarget("test15");
-        assertNull(project.getProperty("test"));
+        buildRule.executeTarget("test15");
+        assertNull(buildRule.getProject().getProperty("test"));
     }
 
     // Specified dir is "" -> this is the current directory and should
     // always exist
+    @Test
     public void test16() {
-        executeTarget("test16");
-        assertEquals("true", project.getProperty("test"));
+        buildRule.executeTarget("test16");
+        assertEquals("true", buildRule.getProject().getProperty("test"));
     }
 
     // Specified dir is "../taskdefs" -> should exist since it's the
     // location of the buildfile used...
+    @Test
     public void test17() {
-        executeTarget("test17");
-        assertEquals("true", project.getProperty("test"));
+        buildRule.executeTarget("test17");
+        assertEquals("true", buildRule.getProject().getProperty("test"));
     }
 
     // Specified dir is "../this_dir_should_never_exist" -> null
+    @Test
     public void test18() {
-        executeTarget("test18");
-        assertNull(project.getProperty("test"));
+        buildRule.executeTarget("test18");
+        assertNull(buildRule.getProject().getProperty("test"));
     }
 
     // Invalid type specified
+    @Test
     public void test19() {
-        expectBuildException("test19", "Invalid value for type attribute.");
+        try {
+            buildRule.executeTarget("test19");
+            fail("Invalid value for type attribute");
+        } catch (BuildException ex) {
+            //TODO assert exception message
+        }
     }
 
     // Core class that exists in system classpath is ignored
+    @Test
     public void test20() {
-        executeTarget("test20");
-        assertNull(project.getProperty("test"));
+        buildRule.executeTarget("test20");
+        assertNull(buildRule.getProject().getProperty("test"));
     }
 
     // Core class that exists in system classpath is ignored, but found in specified classpath
+    @Test
     public void test21() {
-        executeTarget("test21");
-        assertEquals("true", project.getProperty("test"));
+        buildRule.executeTarget("test21");
+        assertEquals("true", buildRule.getProject().getProperty("test"));
     }
 
     // Core class that exists in system classpath is not ignored with ignoresystemclass="false"
+    @Test
     public void test22() {
-        executeTarget("test22");
-        assertEquals("true", project.getProperty("test"));
+        buildRule.executeTarget("test22");
+        assertEquals("true", buildRule.getProject().getProperty("test"));
     }
 
     // Core class that exists in system classpath is not ignored with default ignoresystemclasses value
+    @Test
     public void test23() {
-        executeTarget("test23");
-        assertEquals("true", project.getProperty("test"));
+        buildRule.executeTarget("test23");
+        assertEquals("true", buildRule.getProject().getProperty("test"));
     }
 
     // Class is found in specified classpath
+    @Test
     public void test24() {
-        executeTarget("test24");
-        assertEquals("true", project.getProperty("test"));
+        buildRule.executeTarget("test24");
+        assertEquals("true", buildRule.getProject().getProperty("test"));
     }
 
     // File is not found in specified filepath
+    @Test
     public void testSearchInPathNotThere() {
-        executeTarget("searchInPathNotThere");
-        assertNull(project.getProperty("test"));
+        buildRule.executeTarget("searchInPathNotThere");
+        assertNull(buildRule.getProject().getProperty("test"));
     }
 
     // File is not found in specified filepath
+    @Test
     public void testSearchInPathIsThere() {
-        executeTarget("searchInPathIsThere");
-        assertEquals("true", project.getProperty("test"));
+        buildRule.executeTarget("searchInPathIsThere");
+        assertEquals("true", buildRule.getProject().getProperty("test"));
     }
 
     // test when file begins with basedir twice
+    @Test
     public void testDoubleBasedir() {
-        executeTarget("testDoubleBasedir");
+        buildRule.executeTarget("testDoubleBasedir");
     }
 
     // test for searching parents
+    @Test
     public void testSearchParents() {
-        executeTarget("search-parents");
+        buildRule.executeTarget("search-parents");
     }
     // test for not searching parents
+    @Test
     public void testSearchParentsNot() {
-        executeTarget("search-parents-not");
+        buildRule.executeTarget("search-parents-not");
     }
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/BUnzip2Test.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/BUnzip2Test.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/BUnzip2Test.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/BUnzip2Test.java Fri Apr 18 21:00:38 2014
@@ -18,45 +18,49 @@
 
 package org.apache.tools.ant.taskdefs;
 
-import org.apache.tools.ant.BuildFileTest;
-import org.apache.tools.ant.util.FileUtils;
+import org.apache.tools.ant.BuildFileRule;
+import org.apache.tools.ant.FileUtilities;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
 
+import static org.junit.Assert.assertEquals;
 
-/**
- */
-public class BUnzip2Test extends BuildFileTest {
 
-    /** Utilities used for file operations */
-    private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
+public class BUnzip2Test {
 
-    public BUnzip2Test(String name) {
-        super(name);
-    }
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/bunzip2.xml");
-        executeTarget("prepare");
+        buildRule.configureProject("src/etc/testcases/taskdefs/bunzip2.xml");
+        buildRule.executeTarget("prepare");
     }
 
+    @Test
     public void tearDown() {
-        executeTarget("cleanup");
+        buildRule.executeTarget("cleanup");
     }
 
+    @Test
     public void testRealTest() throws java.io.IOException {
         testRealTest("realTest");
     }
 
+    @Test
     public void testRealTestWithResource() throws java.io.IOException {
         testRealTest("realTestWithResource");
     }
 
     private void testRealTest(String target) throws java.io.IOException {
-        executeTarget(target);
-        assertTrue("File content mismatch after bunzip2",
-            FILE_UTILS.contentEquals(project.resolveFile("expected/asf-logo-huge.tar"),
-                                    project.resolveFile("asf-logo-huge.tar")));
+        buildRule.executeTarget(target);
+        assertEquals("File content mismatch after bunzip2",
+                FileUtilities.getFileContents(buildRule.getProject().resolveFile("expected/asf-logo-huge.tar")),
+                FileUtilities.getFileContents(buildRule.getProject().resolveFile("asf-logo-huge.tar")));
     }
 
+    @Test
     public void testDocumentationClaimsOnCopy() throws java.io.IOException {
         testRealTest("testDocumentationClaimsOnCopy");
     }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/BZip2Test.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/BZip2Test.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/BZip2Test.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/BZip2Test.java Fri Apr 18 21:00:38 2014
@@ -18,34 +18,44 @@
 
 package org.apache.tools.ant.taskdefs;
 
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.BuildFileRule;
 import org.apache.tools.bzip2.CBZip2InputStream;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
 
 import java.io.BufferedInputStream;
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.InputStream;
 import java.io.IOException;
+import java.io.InputStream;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 /**
  */
-public class BZip2Test extends BuildFileTest {
+public class BZip2Test {
 
-    public BZip2Test(String name) {
-        super(name);
-    }
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/bzip2.xml");
-        executeTarget("prepare");
+        buildRule.configureProject("src/etc/testcases/taskdefs/bzip2.xml");
+        buildRule.executeTarget("prepare");
     }
 
+    @After
     public void tearDown() {
-        executeTarget("cleanup");
+        buildRule.executeTarget("cleanup");
     }
 
+    @Test
     public void testRealTest() throws IOException {
-        executeTarget("realTest");
+        buildRule.executeTarget("realTest");
 
         // doesn't work: Depending on the compression engine used,
         // compressed bytes may differ. False errors would be
@@ -57,8 +67,8 @@ public class BZip2Test extends BuildFile
         // We have to compare the decompressed content instead:
 
         File originalFile =
-            project.resolveFile("expected/asf-logo-huge.tar.bz2");
-        File actualFile   = project.resolveFile("asf-logo-huge.tar.bz2");
+            buildRule.getProject().resolveFile("expected/asf-logo-huge.tar.bz2");
+        File actualFile   = buildRule.getProject().resolveFile("asf-logo-huge.tar.bz2");
 
         InputStream originalIn =
             new BufferedInputStream(new FileInputStream(originalFile));
@@ -92,13 +102,15 @@ public class BZip2Test extends BuildFile
         actualIn.close();
     }
 
+    @Test
     public void testResource(){
-        executeTarget("realTestWithResource");
+        buildRule.executeTarget("realTestWithResource");
     }
 
+    @Test
     public void testDateCheck(){
-        executeTarget("testDateCheck");
-        String log = getLog();
+        buildRule.executeTarget("testDateCheck");
+        String log = buildRule.getLog();
         assertTrue(
             "Expecting message ending with 'asf-logo.gif.bz2 is up to date.' but got '" + log + "'",
             log.endsWith("asf-logo.gif.bz2 is up to date."));

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/BasenameTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/BasenameTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/BasenameTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/BasenameTest.java Fri Apr 18 21:00:38 2014
@@ -18,65 +18,96 @@
 
 package org.apache.tools.ant.taskdefs;
 
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
 
 /**
  */
-public class BasenameTest extends BuildFileTest {
+public class BasenameTest {
 
-    public BasenameTest(String name) {
-        super(name);
-    }
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/basename.xml");
+        buildRule.configureProject("src/etc/testcases/taskdefs/basename.xml");
     }
 
+    @Test
     public void test1() {
-        expectBuildException("test1", "required attribute missing");
+        try {
+            buildRule.executeTarget("test1");
+            fail("Required attribute missing");
+        } catch (BuildException ex) {
+            //TODO assert exception message
+        }
     }
 
+    @Test
     public void test2() {
-        expectBuildException("test2", "required attribute missing");
+        try {
+            buildRule.executeTarget("test2");
+            fail("Required attribute missing");
+        } catch (BuildException ex) {
+            //TODO assert exception message
+        }
     }
 
+    @Test
     public void test3() {
-        expectBuildException("test3", "required attribute missing");
+        try {
+            buildRule.executeTarget("test3");
+            fail("Required attribute missing");
+        } catch (BuildException ex) {
+            //TODO assert exception message
+        }
     }
 
+    @Test
     public void test4() {
-        executeTarget("test4");
-        String checkprop = project.getProperty("file.w.suf");
+        buildRule.executeTarget("test4");
+        String checkprop = buildRule.getProject().getProperty("file.w.suf");
         assertEquals("foo.txt", checkprop);
     }
 
+    @Test
     public void test5() {
-        executeTarget("test5");
-        String checkprop = project.getProperty("file.wo.suf");
+        buildRule.executeTarget("test5");
+        String checkprop = buildRule.getProject().getProperty("file.wo.suf");
         assertEquals("foo", checkprop);
     }
 
+    @Test
     public void testMultipleDots() {
-        executeTarget("testMultipleDots");
-        String checkprop = project.getProperty("file.wo.suf");
+        buildRule.executeTarget("testMultipleDots");
+        String checkprop = buildRule.getProject().getProperty("file.wo.suf");
         assertEquals("foo.bar", checkprop);
     }
 
+    @Test
     public void testNoDots() {
-        executeTarget("testNoDots");
-        String checkprop = project.getProperty("file.wo.suf");
+        buildRule.executeTarget("testNoDots");
+        String checkprop = buildRule.getProject().getProperty("file.wo.suf");
         assertEquals("foo.bar", checkprop);
     }
 
+    @Test
     public void testValueEqualsSuffixWithDot() {
-        executeTarget("testValueEqualsSuffixWithDot");
-        String checkprop = project.getProperty("file.wo.suf");
+        buildRule.executeTarget("testValueEqualsSuffixWithDot");
+        String checkprop = buildRule.getProject().getProperty("file.wo.suf");
         assertEquals("", checkprop);
     }
 
+    @Test
     public void testValueEqualsSuffixWithoutDot() {
-        executeTarget("testValueEqualsSuffixWithoutDot");
-        String checkprop = project.getProperty("file.wo.suf");
+        buildRule.executeTarget("testValueEqualsSuffixWithoutDot");
+        String checkprop = buildRule.getProject().getProperty("file.wo.suf");
         assertEquals("", checkprop);
     }
 

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/CVSPassTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/CVSPassTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/CVSPassTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/CVSPassTest.java Fri Apr 18 21:00:38 2014
@@ -19,14 +19,24 @@
 package org.apache.tools.ant.taskdefs;
 
 import java.io.*;
-import org.apache.tools.ant.*;
-import org.apache.tools.ant.BuildFileTest;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
+import org.apache.tools.ant.FileUtilities;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 /**
  * Tests CVSLogin task.
  *
  */
-public class CVSPassTest extends BuildFileTest {
+public class CVSPassTest {
     private final String EOL = System.getProperty("line.separator");
     private static final String JAKARTA_URL =
         ":pserver:anoncvs@jakarta.apache.org:/home/cvspublic Ay=0=h<Z";
@@ -34,63 +44,69 @@ public class CVSPassTest extends BuildFi
         ":pserver:anoncvs@xml.apache.org:/home/cvspublic Ay=0=h<Z";
     private static final String TIGRIS_URL =
         ":pserver:guest@cvs.tigris.org:/cvs AIbdZ,";
+    
+    @Rule
+    public final BuildFileRule buildRule = new BuildFileRule();
 
 
-    public CVSPassTest(String name) {
-        super(name);
-    }
-
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/cvspass.xml");
+        buildRule.configureProject("src/etc/testcases/taskdefs/cvspass.xml");
     }
 
+    @Test
     public void testNoCVSRoot() {
         try{
-            executeTarget("test1");
+            buildRule.executeTarget("test1");
             fail("BuildException not thrown");
         }catch(BuildException e){
             assertEquals("cvsroot is required", e.getMessage());
         }
     }
 
+    @Test
     public void testNoPassword() {
         try{
-            executeTarget("test2");
+            buildRule.executeTarget("test2");
             fail("BuildException not thrown");
         }catch(BuildException e){
             assertEquals("password is required", e.getMessage());
         }
     }
 
+    @After
     public void tearDown() {
-        executeTarget("cleanup");
+        buildRule.executeTarget("cleanup");
     }
 
+    @Test
     public void testPassFile() throws Exception {
-        executeTarget("test3");
-        File f = new File(getProjectDir(), "testpassfile.tmp");
+        buildRule.executeTarget("test3");
+        File f = new File(buildRule.getProject().getBaseDir(), "testpassfile.tmp");
 
         assertTrue( "Passfile "+f+" not created", f.exists());
 
-        assertEquals(JAKARTA_URL+EOL, readFile(f));
+        assertEquals(JAKARTA_URL+EOL, FileUtilities.getFileContents(f));
 
     }
 
+    @Test
     public void testPassFileDuplicateEntry() throws Exception {
-        executeTarget("test4");
-        File f = new File(getProjectDir(), "testpassfile.tmp");
+        buildRule.executeTarget("test4");
+        File f = new File(buildRule.getProject().getBaseDir(), "testpassfile.tmp");
 
         assertTrue( "Passfile "+f+" not created", f.exists());
 
         assertEquals(
             JAKARTA_URL+ EOL+
             TIGRIS_URL+ EOL,
-            readFile(f));
+            FileUtilities.getFileContents(f));
     }
 
+    @Test
     public void testPassFileMultipleEntry() throws Exception {
-        executeTarget("test5");
-        File f = new File(getProjectDir(), "testpassfile.tmp");
+        buildRule.executeTarget("test5");
+        File f = new File(buildRule.getProject().getBaseDir(), "testpassfile.tmp");
 
         assertTrue( "Passfile "+f+" not created", f.exists());
 
@@ -98,25 +114,6 @@ public class CVSPassTest extends BuildFi
             JAKARTA_URL+ EOL+
             XML_URL+ EOL+
             TIGRIS_URL+ EOL,
-            readFile(f));
-    }
-
-    private String readFile(File f) throws Exception {
-        BufferedReader reader = null;
-
-        try {
-            reader = new BufferedReader(new FileReader(f));
-
-            StringBuffer buf = new StringBuffer();
-            String line=null;
-            while((line=reader.readLine())!=null){
-                buf.append(line + EOL);
-            }
-            return buf.toString();
-        } finally {
-            if (reader != null) {
-                reader.close();
-            }
-        }
+            FileUtilities.getFileContents(f));
     }
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/CallTargetTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/CallTargetTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/CallTargetTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/CallTargetTest.java Fri Apr 18 21:00:38 2014
@@ -18,53 +18,75 @@
 
 package org.apache.tools.ant.taskdefs;
 
+import org.apache.tools.ant.AntAssert;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
 import java.util.Vector;
 
-import org.apache.tools.ant.BuildFileTest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
 
 /**
  */
-public class CallTargetTest extends BuildFileTest {
+public class CallTargetTest {
 
-    public CallTargetTest(String name) {
-        super(name);
-    }
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/calltarget.xml");
-        executeTarget("setUp");
+        buildRule.configureProject("src/etc/testcases/taskdefs/calltarget.xml");
+        buildRule.executeTarget("setUp");
     }
 
     // see bugrep 21724 (references not passing through with antcall)
+    @Test
     public void testInheritRefFileSet() {
-        expectLogContaining("testinheritreffileset", "calltarget.xml");
+        buildRule.executeTarget("testinheritreffileset");
+        AntAssert.assertContains("calltarget.xml", buildRule.getLog());
     }
 
     // see bugrep 21724 (references not passing through with antcall)
+    @Test
     public void testInheritFilterset() {
-        project.executeTarget("testinheritreffilterset");
+        buildRule.getProject().executeTarget("testinheritreffilterset");
     }
 
     // see bugrep 11418 (In repeated calls to the same target,
     // params will not be passed in)
+    @Test
     public void testMultiCall() {
-        Vector v = new Vector();
+        Vector<String> v = new Vector<String>();
         v.add("call-multi");
         v.add("call-multi");
-        project.executeTargets(v);
-        assertLogContaining("multi is SETmulti is SET");
+        buildRule.getProject().executeTargets(v);
+        AntAssert.assertContains("multi is SETmulti is SET", buildRule.getLog());
     }
 
+    @Test
     public void testBlankTarget() {
-        expectBuildException("blank-target", "target name must not be empty");
+        try {
+            buildRule.executeTarget("blank-target");
+            fail("target name must not be empty");
+        } catch (BuildException ex) {
+            //TODO assert exception contents
+        }
     }
 
+    @Test
     public void testMultipleTargets() {
-        expectLog("multiple-targets", "tadadctbdbtc");
+        buildRule.executeTarget("multiple-targets");
+        assertEquals("tadadctbdbtc", buildRule.getLog());
     }
 
+    @Test
     public void testMultipleTargets2() {
-        expectLog("multiple-targets-2", "dadctb");
+        buildRule.executeTarget("multiple-targets-2");
+        assertEquals("dadctb", buildRule.getLog());
     }
 
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ChecksumTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ChecksumTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ChecksumTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ChecksumTest.java Fri Apr 18 21:00:38 2014
@@ -18,76 +18,92 @@
 
 package org.apache.tools.ant.taskdefs;
 
-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.IOException;
 
-/**
- */
-public class ChecksumTest extends BuildFileTest {
-
-    public ChecksumTest(String name) {
-        super(name);
-    }
+public class ChecksumTest {
 
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
+    
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/checksum.xml");
+        buildRule.configureProject("src/etc/testcases/taskdefs/checksum.xml");
     }
 
+    @After
     public void tearDown() {
-        executeTarget("cleanup");
+        buildRule.executeTarget("cleanup");
     }
 
+    @Test
     public void testCreateMd5() throws IOException {
-        executeTarget("createMd5");
+        buildRule.executeTarget("createMd5");
     }
 
+    @Test
     public void testCreateMD5SUMformat() throws IOException {
-        executeTarget("createMD5SUMformat");
+        buildRule.executeTarget("createMD5SUMformat");
     }
-    
+
+    @Test
     public void testCreateSVFformat() throws IOException {
-        executeTarget("createSVFformat");
+        buildRule.executeTarget("createSVFformat");
     }
-    
+
+    @Test
     public void testCreatePattern() throws IOException {
-        executeTarget("createPattern");
+        buildRule.executeTarget("createPattern");
     }
 
+    @Test
     public void testSetProperty() {
-        executeTarget("setProperty");
+        buildRule.executeTarget("setProperty");
     }
 
+    @Test
     public void testVerifyTotal() {
-        executeTarget("verifyTotal");
+        buildRule.executeTarget("verifyTotal");
     }
 
+    @Test
     public void testVerifyTotalRC() {
-        executeTarget("verifyTotalRC");
+        buildRule.executeTarget("verifyTotalRC");
     }
 
+    @Test
     public void testVerifyChecksumdir() {
-        executeTarget("verifyChecksumdir");
+        buildRule.executeTarget("verifyChecksumdir");
     }
 
+    @Test
     public void testVerifyAsTask() {
-        executeTarget("verifyAsTask");
+        buildRule.executeTarget("verifyAsTask");
     }
 
+    @Test
     public void testVerifyMD5SUMAsTask() {
-        executeTarget("verifyMD5SUMAsTask");
+        buildRule.executeTarget("verifyMD5SUMAsTask");
     }
 
+    @Test
     public void testVerifyAsCondition() {
-        executeTarget("verifyAsCondition");
+        buildRule.executeTarget("verifyAsCondition");
     }
 
+    @Test
     public void testVerifyFromProperty() {
-        executeTarget("verifyFromProperty");
+        buildRule.executeTarget("verifyFromProperty");
     }
 
+    @Test
     public void testVerifyChecksumdirNoTotal() {
-        executeTarget("verifyChecksumdirNoTotal");
+        buildRule.executeTarget("verifyChecksumdirNoTotal");
     }
 
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ConcatTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ConcatTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ConcatTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ConcatTest.java Fri Apr 18 21:00:38 2014
@@ -18,21 +18,28 @@
 
 package org.apache.tools.ant.taskdefs;
 
-import org.apache.tools.ant.BuildFileTest;
-import org.apache.tools.ant.util.FileUtils;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
+import org.apache.tools.ant.FileUtilities;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
 
 import java.io.File;
-import java.io.FileReader;
 import java.io.IOException;
-import java.io.Reader;
+
+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;
 
 /**
  * A test class for the 'concat' task, used to concatenate a series of
  * files into a single stream.
  *
  */
-public class ConcatTest
-    extends BuildFileTest {
+public class ConcatTest {
 
     /**
      * The name of the temporary file.
@@ -44,57 +51,68 @@ public class ConcatTest
      */
     private static final String tempFile2 = "concat.tmp.2";
 
-    /** Utilities used for file operations */
-    private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
 
-    /**
-     * Required constructor.
-     */
-    public ConcatTest(String name) {
-        super(name);
-    }
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
+
 
     /**
      * Test set up, called by the unit test framework prior to each
      * test.
      */
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/concat.xml");
+        buildRule.configureProject("src/etc/testcases/taskdefs/concat.xml");
     }
 
     /**
      * Test tear down, called by the unit test framework prior to each
      * test.
      */
+    @After
     public void tearDown() {
-        executeTarget("cleanup");
+        buildRule.executeTarget("cleanup");
     }
 
     /**
      * Expect an exception when insufficient information is provided.
      */
+    @Test
     public void test1() {
-        expectBuildException("test1", "Insufficient information.");
+        try {
+            buildRule.executeTarget("test1");
+            fail("BuildException should have been thrown - Insufficient information");
+        } catch (BuildException ex) {
+            //TODO assert value
+        }
+
     }
 
     /**
      * Expect an exception when the destination file is invalid.
      */
+    @Test
     public void test2() {
-        expectBuildException("test2", "Invalid destination file.");
+        try {
+            buildRule.executeTarget("test2");
+            fail("BuildException should have been thrown - Invalid destination file");
+        } catch(BuildException ex) {
+            //TODO assert value
+        }
     }
 
     /**
      * Cats the string 'Hello, World!' to a temporary file.
      */
+    @Test
     public void test3() {
 
-        File file = new File(getProjectDir(), tempFile);
+        File file = new File(buildRule.getProject().getBaseDir(), tempFile);
         if (file.exists()) {
             file.delete();
         }
 
-        executeTarget("test3");
+        buildRule.executeTarget("test3");
 
         assertTrue(file.exists());
     }
@@ -102,15 +120,16 @@ public class ConcatTest
     /**
      * Cats the file created in test3 three times.
      */
+    @Test
     public void test4() {
         test3();
 
-        File file = new File(getProjectDir(), tempFile);
+        File file = new File(buildRule.getProject().getBaseDir(), tempFile);
         final long origSize = file.length();
 
-        executeTarget("test4");
+        buildRule.executeTarget("test4");
 
-        File file2 = new File(getProjectDir(), tempFile2);
+        File file2 = new File(buildRule.getProject().getBaseDir(), tempFile2);
         final long newSize = file2.length();
 
         assertEquals(origSize * 3, newSize);
@@ -119,170 +138,178 @@ public class ConcatTest
     /**
      * Cats the string 'Hello, World!' to the console.
      */
+    @Test
     public void test5() {
-        expectLog("test5", "Hello, World!");
+        buildRule.executeTarget("test5");
+        assertEquals("Hello, World!", buildRule.getLog());
     }
 
+    @Test
     public void test6() {
         String filename = "src/etc/testcases/taskdefs/thisfiledoesnotexist"
             .replace('/', File.separatorChar);
-        expectLogContaining("test6", filename +" does not exist.");
+        buildRule.executeTarget("test6");
+        assertContains(filename + " does not exist", buildRule.getLog());
     }
 
+    @Test
     public void testConcatNoNewline() {
-        expectLog("testConcatNoNewline", "ab");
+        buildRule.executeTarget("testConcatNoNewline");
+        assertEquals("ab", buildRule.getLog());
     }
 
+    @Test
     public void testConcatNoNewlineEncoding() {
-        expectLog("testConcatNoNewlineEncoding", "ab");
+        buildRule.executeTarget("testConcatNoNewlineEncoding");
+        assertEquals("ab", buildRule.getLog());
     }
 
+    @Test
     public void testPath() {
         test3();
 
-        File file = new File(getProjectDir(), tempFile);
+        File file = new File(buildRule.getProject().getBaseDir(), tempFile);
         final long origSize = file.length();
 
-        executeTarget("testPath");
+        buildRule.executeTarget("testPath");
 
-        File file2 = new File(getProjectDir(), tempFile2);
+        File file2 = new File(buildRule.getProject().getBaseDir(), tempFile2);
         final long newSize = file2.length();
 
         assertEquals(origSize, newSize);
 
     }
+
+    @Test
     public void testAppend() {
         test3();
 
-        File file = new File(getProjectDir(), tempFile);
+        File file = new File(buildRule.getProject().getBaseDir(), tempFile);
         final long origSize = file.length();
 
-        executeTarget("testAppend");
+        buildRule.executeTarget("testAppend");
 
-        File file2 = new File(getProjectDir(), tempFile2);
+        File file2 = new File(buildRule.getProject().getBaseDir(), tempFile2);
         final long newSize = file2.length();
 
         assertEquals(origSize*2, newSize);
 
     }
 
+    @Test
     public void testFilter() {
-        executeTarget("testfilter");
-        assertTrue(getLog().indexOf("REPLACED") > -1);
+        buildRule.executeTarget("testfilter");
+        assertTrue(buildRule.getLog().indexOf("REPLACED") > -1);
     }
 
+    @Test
     public void testNoOverwrite() {
-        executeTarget("testnooverwrite");
-        File file2 = new File(getProjectDir(), tempFile2);
+        buildRule.executeTarget("testnooverwrite");
+        File file2 = new File(buildRule.getProject().getBaseDir(), tempFile2);
         long size = file2.length();
         assertEquals(size, 0);
     }
 
+    @Test
     public void testOverwrite() {
-        executeTarget("testoverwrite");
-        File file2 = new File(getProjectDir(), tempFile2);
+        buildRule.executeTarget("testoverwrite");
+        File file2 = new File(buildRule.getProject().getBaseDir(), tempFile2);
         long size = file2.length();
         assertTrue(size > 0);
     }
 
+    @Test
     public void testheaderfooter() {
         test3();
-        expectLog("testheaderfooter", "headerHello, World!footer");
+        buildRule.executeTarget("testheaderfooter");
+        assertEquals("headerHello, World!footer", buildRule.getLog());
     }
 
+    @Test
     public void testfileheader() {
         test3();
-        expectLog("testfileheader", "Hello, World!Hello, World!");
+        buildRule.executeTarget("testfileheader");
+        assertEquals("Hello, World!Hello, World!", buildRule.getLog());
     }
 
     /**
      * Expect an exception when attempting to cat an file to itself
      */
+    @Test
     public void testsame() {
-        expectBuildException("samefile", "output file same as input");
+        try {
+            buildRule.executeTarget("samefile");
+            fail("Build exception should have been thrown - output file same as input");
+        } catch(BuildException ex) {
+            //TODO assert value
+        }
     }
 
     /**
      * Check if filter inline works
      */
+    @Test
     public void testfilterinline() {
-        executeTarget("testfilterinline");
-        assertTrue(getLog().indexOf("REPLACED") > -1);
+        buildRule.executeTarget("testfilterinline");
+        assertTrue(buildRule.getLog().indexOf("REPLACED") > -1);
     }
 
     /**
      * Check if multireader works
      */
+    @Test
     public void testmultireader() {
-        executeTarget("testmultireader");
-        assertTrue(getLog().indexOf("Bye") > -1);
-        assertTrue(getLog().indexOf("Hello") == -1);
+        buildRule.executeTarget("testmultireader");
+        assertTrue(buildRule.getLog().indexOf("Bye") > -1);
+        assertTrue(buildRule.getLog().indexOf("Hello") == -1);
     }
     /**
      * Check if fixlastline works
      */
+    @Test
     public void testfixlastline()
         throws IOException
     {
-        expectFileContains(
-            "testfixlastline", "concat.line4",
-            "end of line" + System.getProperty("line.separator")
-            + "This has");
+        buildRule.executeTarget("testfixlastline");
+        assertContains("end of line" + System.getProperty("line.separator") + "This has",
+                FileUtilities.getFileContents(buildRule.getProject(), "concat.line4"));
     }
 
     /**
      * Check if fixlastline works with eol
      */
+    @Test
     public void testfixlastlineeol()
         throws IOException
     {
-        expectFileContains(
-            "testfixlastlineeol", "concat.linecr",
-            "end of line\rThis has");
+        buildRule.executeTarget("testfixlastlineeol");
+        assertContains("end of line\rThis has", FileUtilities.getFileContents(buildRule.getProject(), "concat.linecr"));
     }
 
-    // ------------------------------------------------------
-    //   Helper methods - should be in BuildFileTest
-    // -----------------------------------------------------
-
-    private String getFileString(String filename)
-        throws IOException
-    {
-        Reader r = null;
-        try {
-            r = new FileReader(getProject().resolveFile(filename));
-            return  FileUtils.readFully(r);
-        }
-        finally {
-            FileUtils.close(r);
-        }
-
-    }
 
-    private String getFileString(String target, String filename)
-        throws IOException
-    {
-        executeTarget(target);
-        return getFileString(filename);
+    @Test
+    public void testTranscoding() throws IOException {
+        buildRule.executeTarget("testTranscoding");
+        File f1 = buildRule.getProject().resolveFile("copy/expected/utf-8");
+        File f2 = buildRule.getProject().resolveFile("concat.utf8");
+        assertEquals(f1.toString() + " differs from " + f2.toString(),
+                FileUtilities.getFileContents(f1), FileUtilities.getFileContents(f2));
     }
 
-    private void expectFileContains(
+    // ------------------------------------------------------
+    //   Helper methods - should be in a utility class
+    // -----------------------------------------------------
+    private void expectFileContainsx(
         String target, String filename, String contains)
         throws IOException
     {
-        String content = getFileString(target, filename);
+        buildRule.executeTarget(target);
+        String content = FileUtilities.getFileContents(buildRule.getProject(), filename);
         assertTrue(
             "expecting file " + filename + " to contain " +
             contains +
             " but got " + content, content.indexOf(contains) > -1);
     }
 
-    public void testTranscoding() throws IOException {
-        executeTarget("testTranscoding");
-        File f1 = getProject().resolveFile("copy/expected/utf-8");
-        File f2 = getProject().resolveFile("concat.utf8");
-        assertTrue(f1.toString() + " differs from " + f2.toString(),
-                FILE_UTILS.contentEquals(f1, f2));
-    }
 
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ConditionTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ConditionTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ConditionTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ConditionTest.java Fri Apr 18 21:00:38 2014
@@ -17,259 +17,363 @@
  */
 package org.apache.tools.ant.taskdefs;
 
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
 
-/**
- * @created 13 January 2002
- */
-public class ConditionTest extends BuildFileTest {
+public class ConditionTest {
 
-    /**
-     * Constructor for the ConditionTest object
-     *
-     * @param name we dont know
-     */
-    public ConditionTest(String name) {
-        super(name);
-    }
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
 
     /**
      * The JUnit setup method
      */
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/condition.xml");
+        buildRule.configureProject("src/etc/testcases/taskdefs/condition.xml");
     }
 
 
     /**
      * The teardown method for JUnit
      */
+    @After
     public void tearDown() {
-        executeTarget("cleanup");
+        buildRule.executeTarget("cleanup");
     }
 
+    @Test
     public void testBasic() {
-       expectPropertySet("basic","basic");
+       buildRule.executeTarget("basic");
+       assertEquals("true", buildRule.getProject().getProperty("basic"));
     }
 
+    @Test
     public void testConditionIncomplete() {
-        expectSpecificBuildException("condition-incomplete",
-                                     "property attribute has been omitted",
-                                     "The property attribute is required.");
+        try {
+            buildRule.executeTarget("condition-incomplete");
+            fail("BuildException should have been thrown - property attribute has been omitted");
+        } catch (BuildException ex) {
+            assertEquals("The property attribute is required.", ex.getMessage());
+        }
     }
 
+    @Test
     public void testConditionEmpty() {
-        expectSpecificBuildException("condition-empty",
-                                     "no conditions",
-                                     "You must nest a condition into <condition>");
+        try {
+            buildRule.executeTarget("condition-empty");
+            fail("BuildException should have been thrown - no conditions");
+        }  catch(BuildException ex) {
+            assertEquals("You must nest a condition into <condition>", ex.getMessage());
+        }
     }
 
+    @Test
     public void testShortcut() {
-        expectPropertySet("shortcut","shortcut","set");
+        buildRule.executeTarget("shortcut");
+        assertEquals("set", buildRule.getProject().getProperty("shortcut"));
     }
 
+    @Test
     public void testUnset() {
-        expectPropertyUnset("dontset","dontset");
+        buildRule.executeTarget("dontset");
+        assertNull(buildRule.getProject().getProperty("dontset"));
     }
 
+    @Test
     public void testSetValue() {
-        expectPropertySet("setvalue","setvalue","woowoo");
+        buildRule.executeTarget("setvalue");
+        assertEquals("woowoo", buildRule.getProject().getProperty("setvalue"));
     }
 
+    @Test
     public void testNegation() {
-        expectPropertySet("negation","negation");
+        buildRule.executeTarget("negation");
+        assertEquals("true", buildRule.getProject().getProperty("negation"));
     }
 
+    @Test
     public void testNegationFalse() {
-        expectPropertyUnset("negationfalse","negationfalse");
+        buildRule.executeTarget("negationfalse");
+        assertNull(buildRule.getProject().getProperty("negationfalse"));
     }
 
+    @Test
     public void testNegationIncomplete() {
-        expectSpecificBuildException("negationincomplete",
-                                     "no conditions in <not>",
-                                     "You must nest a condition into <not>");
+        try {
+            buildRule.executeTarget("negationincomplete");
+            fail("BuildException should have been thrown - no conditions in <not>");
+        } catch (BuildException ex) {
+            assertEquals("You must nest a condition into <not>", ex.getMessage());
+        }
     }
 
+    @Test
     public void testAnd() {
-        expectPropertySet("and","and");
+        buildRule.executeTarget("and");
+        assertEquals("true", buildRule.getProject().getProperty("and"));
     }
 
+    @Test
     public void testAndFails() {
-        expectPropertyUnset("andfails","andfails");
+        buildRule.executeTarget("andfails");
+        assertNull(buildRule.getProject().getProperty("andfails"));
     }
 
+    @Test
     public void testAndIncomplete() {
-        expectPropertyUnset("andincomplete","andincomplete");
+        buildRule.executeTarget("andincomplete");
+        assertNull(buildRule.getProject().getProperty("andincomplete"));
     }
 
+    @Test
     public void testAndempty() {
-        expectPropertySet("andempty","andempty");
+        buildRule.executeTarget("andempty");
+        assertEquals("true", buildRule.getProject().getProperty("andempty"));
     }
 
+    @Test
     public void testOr() {
-        expectPropertySet("or","or");
+        buildRule.executeTarget("or");
+        assertEquals("true", buildRule.getProject().getProperty("or"));
     }
 
+    @Test
     public void testOrincomplete() {
-        expectPropertySet("or","or");
+        buildRule.executeTarget("or");
+        assertEquals("true", buildRule.getProject().getProperty("or"));
     }
 
+    @Test
     public void testOrFails() {
-        expectPropertyUnset("orfails","orfails");
+        buildRule.executeTarget("orfails");
+        assertNull(buildRule.getProject().getProperty("orfails"));
     }
 
+    @Test
     public void testOrboth() {
-        expectPropertySet("orboth","orboth");
+        buildRule.executeTarget("orboth");
+        assertEquals("true", buildRule.getProject().getProperty("orboth"));
     }
 
+    @Test
     public void testFilesmatchIdentical() {
-        expectPropertySet("filesmatch-identical","filesmatch-identical");
+        buildRule.executeTarget("filesmatch-identical");
+        assertEquals("true", buildRule.getProject().getProperty("filesmatch-identical"));
     }
 
-
+    @Test
     public void testFilesmatchIncomplete() {
-        expectSpecificBuildException("filesmatch-incomplete",
-                                     "Missing file2 attribute",
-                                     "both file1 and file2 are required in filesmatch");
+        try {
+            buildRule.executeTarget("filesmatch-incomplete");
+            fail("Build exception should have been thrown - Missing file2 attirbute");
+        } catch (BuildException ex) {
+            assertEquals("both file1 and file2 are required in filesmatch", ex.getMessage());
+        }
     }
 
+    @Test
     public void testFilesmatchOddsizes() {
-        expectPropertyUnset("filesmatch-oddsizes","filesmatch-oddsizes");
+        buildRule.executeTarget("filesmatch-oddsizes");
+        assertNull(buildRule.getProject().getProperty("filesmatch-oddsizes"));
     }
 
+    @Test
     public void testFilesmatchExistence() {
-        expectPropertyUnset("filesmatch-existence", "filesmatch-existence");
+        buildRule.executeTarget("filesmatch-existence");
+        assertNull(buildRule.getProject().getProperty("filesmatch-existence"));
     }
 
+    @Test
     public void testFilesmatchDifferent() {
-        expectPropertyUnset("filesmatch-different","filesmatch-different");
+        buildRule.executeTarget("filesmatch-different");
+        assertNull(buildRule.getProject().getProperty("filesmatch-different"));
     }
 
+    @Test
     public void testFilesmatchMatch() {
-        expectPropertySet("filesmatch-match","filesmatch-match");
+        buildRule.executeTarget("filesmatch-match");
+        assertEquals("true", buildRule.getProject().getProperty("filesmatch-match"));
     }
 
+    @Test
     public void testFilesmatchDifferentSizes() {
-        expectPropertyUnset("filesmatch-different-sizes",
-            "filesmatch-different-sizes");
+        buildRule.executeTarget("filesmatch-different-sizes");
+        assertNull(buildRule.getProject().getProperty("filesmatch-different-sizes"));
     }
 
+    @Test
     public void testFilesmatchDifferentOnemissing() {
-        expectPropertyUnset("filesmatch-different-onemissing",
-            "filesmatch-different-onemissing");
+        buildRule.executeTarget("filesmatch-different-onemissing");
+        assertNull(buildRule.getProject().getProperty("filesmatch-different-onemissing"));
     }
 
+    @Test
     public void testFilesmatchDifferentEol() {
-        executeTarget("filesmatch-different-eol");
+        buildRule.executeTarget("filesmatch-different-eol");
     }
 
+    @Test
     public void testFilesmatchSameEol() {
-        executeTarget("filesmatch-same-eol");
+        buildRule.executeTarget("filesmatch-same-eol");
     }
 
+    @Test
     public void testFilesmatchNeitherExist() {
-        executeTarget("filesmatch-neitherexist");
+        buildRule.executeTarget("filesmatch-neitherexist");
     }
 
+    @Test
     public void testContains() {
-        expectPropertySet("contains","contains");
+        buildRule.executeTarget("contains");
+        assertEquals("true", buildRule.getProject().getProperty("contains"));
     }
 
-
+    @Test
     public void testContainsDoesnt() {
-        expectPropertyUnset("contains-doesnt","contains-doesnt");
+        buildRule.executeTarget("contains-doesnt");
+        assertNull(buildRule.getProject().getProperty("contains-doesnt"));
     }
 
+    @Test
     public void testContainsAnycase() {
-        expectPropertySet("contains-anycase","contains-anycase");
+        buildRule.executeTarget("contains-anycase");
+        assertEquals("true", buildRule.getProject().getProperty("contains-anycase"));
     }
 
-
+    @Test
     public void testContainsIncomplete1() {
-        expectSpecificBuildException("contains-incomplete1",
-                    "Missing contains attribute",
-                    "both string and substring are required in contains");
+        try {
+            buildRule.executeTarget("contains-incomplete1");
+            fail("BuildException should have been thrown - Missing contains attribute");
+        }  catch(BuildException ex) {
+            assertEquals("both string and substring are required in contains", ex.getMessage());
+        }
     }
 
+    @Test
     public void testContainsIncomplete2() {
-        expectSpecificBuildException("contains-incomplete2",
-                    "Missing contains attribute",
-                    "both string and substring are required in contains");
+        try {
+            buildRule.executeTarget("contains-incomplete2");
+            fail("BuildException should have been thrown - Missing contains attribute");
+        }  catch(BuildException ex) {
+            assertEquals("both string and substring are required in contains", ex.getMessage());
+        }
     }
 
+    @Test
     public void testIstrue() {
-        expectPropertySet("istrue","istrue");
+        buildRule.executeTarget("istrue");
+        assertEquals("true", buildRule.getProject().getProperty("istrue"));
     }
 
+    @Test
     public void testIstrueNot() {
-        expectPropertyUnset("istrue-not","istrue-not");
+        buildRule.executeTarget("istrue-not");
+        assertNull(buildRule.getProject().getProperty("istrue-not"));
     }
 
+    @Test
     public void testIstrueFalse() {
-        expectPropertyUnset("istrue-false","istrue-false");
+        buildRule.executeTarget("istrue-false");
+        assertNull(buildRule.getProject().getProperty("istrue-false"));
     }
 
-
+    @Test
     public void testIstrueIncomplete1() {
-        expectSpecificBuildException("istrue-incomplete",
-                    "Missing attribute",
-                    "Nothing to test for truth");
+        try {
+            buildRule.executeTarget("istrue-incomplete");
+            fail("BuildException should have been thrown - Missing attribute");
+        }  catch(BuildException ex) {
+            assertEquals("Nothing to test for truth", ex.getMessage());
+        }
     }
 
+    @Test
     public void testIsfalseTrue() {
-        expectPropertyUnset("isfalse-true","isfalse-true");
+        buildRule.executeTarget("isfalse-true");
+        assertNull(buildRule.getProject().getProperty("isfalse-true"));
     }
 
+    @Test
     public void testIsfalseNot() {
-        expectPropertySet("isfalse-not","isfalse-not");
+        buildRule.executeTarget("isfalse-not");
+        assertEquals("true", buildRule.getProject().getProperty("isfalse-not"));
     }
 
+    @Test
     public void testIsfalseFalse() {
-        expectPropertySet("isfalse-false","isfalse-false");
-    }
 
+        buildRule.executeTarget("isfalse-false");
+        assertEquals("true", buildRule.getProject().getProperty("isfalse-false"));
+    }
 
+    @Test
     public void testIsfalseIncomplete1() {
-        expectSpecificBuildException("isfalse-incomplete",
-                    "Missing attribute",
-                    "Nothing to test for falsehood");
+        try {
+            buildRule.executeTarget("isfalse-incomplete");
+            fail("BuildException should have been thrown - Missing attribute");
+        }  catch(BuildException ex) {
+            assertEquals("Nothing to test for falsehood", ex.getMessage());
+        }
     }
 
+    @Test
     public void testElse() {
-        executeTarget("testElse");
+        buildRule.executeTarget("testElse");
     }
 
+    @Test
     public void testResourcesmatchError() {
-        expectBuildException("resourcesmatch-error",
-            "should fail because no resources specified");
+        try {
+            buildRule.executeTarget("resourcematch-error");
+            fail("BuildException should have been thrown - no resources specified");
+        } catch (BuildException ex) {
+            //TODO assert value
+        }
     }
 
+    @Test
     public void testResourcesmatchEmpty() {
-        executeTarget("resourcesmatch-match-empty");
+        buildRule.executeTarget("resourcesmatch-match-empty");
     }
 
+    @Test
     public void testResourcesmatchOne() {
-        executeTarget("resourcesmatch-match-one");
+        buildRule.executeTarget("resourcesmatch-match-one");
     }
 
+    @Test
     public void testResourcesmatchBinary() {
-        executeTarget("resourcesmatch-match-binary");
+        buildRule.executeTarget("resourcesmatch-match-binary");
     }
 
+    @Test
     public void testResourcesmatchMultipleBinary() {
-        executeTarget("resourcesmatch-match-multiple-binary");
+        buildRule.executeTarget("resourcesmatch-match-multiple-binary");
     }
 
+    @Test
     public void testResourcesmatchDiffer() {
-        executeTarget("resourcesmatch-differ");
+        buildRule.executeTarget("resourcesmatch-differ");
     }
 
+    @Test
     public void testResourcesmatchText() {
-        executeTarget("resourcesmatch-match-text");
+        buildRule.executeTarget("resourcesmatch-match-text");
     }
 
+    @Test
     public void testResourcesmatchNoneExist() {
-        executeTarget("resourcesmatch-noneexist");
+        buildRule.executeTarget("resourcesmatch-noneexist");
     }
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/CopyTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/CopyTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/CopyTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/CopyTest.java Fri Apr 18 21:00:38 2014
@@ -18,55 +18,72 @@
 
 package org.apache.tools.ant.taskdefs;
 
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
+import org.apache.tools.ant.FileUtilities;
 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 java.io.FileReader;
 import java.io.IOException;
 
+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;
+
 /**
  * Tests FileSet using the Copy task.
  *
  */
-public class CopyTest extends BuildFileTest {
+public class CopyTest {
 
-    /** Utilities used for file operations */
-    private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
+    @Rule
+    public final BuildFileRule buildRule = new BuildFileRule();
 
-    public CopyTest(String name) {
-        super(name);
-    }
 
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/copy.xml");
-        executeTarget("setUp");
+        buildRule.configureProject("src/etc/testcases/taskdefs/copy.xml");
+        buildRule.executeTarget("setUp");
     }
 
+    @Test
     public void test1() {
-        executeTarget("test1");
-        File f = new File(getOutputDir(), "copytest1.tmp");
+        buildRule.executeTarget("test1");
+        File f = new File(buildRule.getProject().getProperty("output"), "copytest1.tmp");
         if ( !f.exists()) {
             fail("Copy failed");
         }
     }
 
+    @Test
     public void test2() {
-        executeTarget("test2");
-        File f = new File(getOutputDir(), "copytest1dir/copy.xml");
+        buildRule.executeTarget("test2");
+        File f = new File(buildRule.getProject().getProperty("output"), "copytest1dir/copy.xml");
         if ( !f.exists()) {
             fail("Copy failed");
         }
     }
 
+    @Test
     public void test3() {
-        executeTarget("test3");
-        File file3  = new File(getOutputDir(), "copytest3.tmp");
+        buildRule.executeTarget("test3");
+        File file3  = new File(buildRule.getProject().getProperty("output"), "copytest3.tmp");
+        //rollback file timestamp instead of delaying test
+        FileUtilities.rollbackTimetamps(file3, 3);
+        buildRule.executeTarget("test3Part2");
         assertTrue(file3.exists());
-        File file3a = new File(getOutputDir(), "copytest3a.tmp");
+
+        File file3a = new File(buildRule.getProject().getProperty("output"), "copytest3a.tmp");
         assertTrue(file3a.exists());
-        File file3b = new File(getOutputDir(), "copytest3b.tmp");
+        File file3b = new File(buildRule.getProject().getProperty("output"), "copytest3b.tmp");
         assertTrue(file3b.exists());
-        File file3c = new File(getOutputDir(), "copytest3c.tmp");
+        File file3c = new File(buildRule.getProject().getProperty("output"), "copytest3c.tmp");
         assertTrue(file3c.exists());
 
         //file length checks rely on touch generating a zero byte file
@@ -86,96 +103,120 @@ public class CopyTest extends BuildFileT
 
     }
 
+    @Test
     public void testFilterTest() {
-        executeTarget("filtertest");
-        assertTrue(getOutput().indexOf("loop in tokens") == -1);
+        buildRule.executeTarget("filtertest");
+        assertTrue(buildRule.getLog().indexOf("loop in tokens") == -1);
     }
 
+    @Test
     public void testInfiniteFilter() {
-        executeTarget("infinitetest");
-        assertTrue(getOutput().indexOf("loop in tokens") != -1);
+        buildRule.executeTarget("infinitetest");
+        assertContains("loop in tokens", buildRule.getOutput());
     }
 
+    @Test
     public void testFilterSet() throws IOException {
-        executeTarget("testFilterSet");
-        File tmp  = new File(getOutputDir(), "copy.filterset.tmp");
-        File check  = new File(getProjectDir(), "expected/copy.filterset.filtered");
+        buildRule.executeTarget("testFilterSet");
+        File tmp  = new File(buildRule.getProject().getProperty("output"), "copy.filterset.tmp");
+        File check  = new File(buildRule.getProject().getBaseDir(), "expected/copy.filterset.filtered");
         assertTrue(tmp.exists());
-        assertTrue(FILE_UTILS.contentEquals(tmp, check));
+        assertEquals(FileUtilities.getFileContents(tmp), FileUtilities.getFileContents(check));
     }
 
+    @Test
     public void testFilterChain() throws IOException {
-        executeTarget("testFilterChain");
-        File tmp  = new File(getOutputDir(), "copy.filterchain.tmp");
-        File check  = new File(getProjectDir(), "expected/copy.filterset.filtered");
+        buildRule.executeTarget("testFilterChain");
+        File tmp  = new File(buildRule.getProject().getProperty("output"), "copy.filterchain.tmp");
+        File check  = new File(buildRule.getProject().getBaseDir(), "expected/copy.filterset.filtered");
         assertTrue(tmp.exists());
-        assertTrue(FILE_UTILS.contentEquals(tmp, check));
+        assertEquals(FileUtilities.getFileContents(tmp), FileUtilities.getFileContents(check));
     }
 
+    @Test
     public void testSingleFileFileset() {
-        executeTarget("test_single_file_fileset");
-        File file  = new File(getOutputDir(),
+        buildRule.executeTarget("test_single_file_fileset");
+        File file  = new File(buildRule.getProject().getProperty("output"),
                                         "copytest_single_file_fileset.tmp");
         assertTrue(file.exists());
     }
 
+    @Test
     public void testSingleFilePath() {
-        executeTarget("test_single_file_path");
-        File file  = new File(getOutputDir(),
+        buildRule.executeTarget("test_single_file_path");
+        File file  = new File(buildRule.getProject().getProperty("output"),
                                         "copytest_single_file_path.tmp");
         assertTrue(file.exists());
     }
 
+    @Test
     public void testTranscoding() throws IOException {
-        executeTarget("testTranscoding");
-        File f1 = getProject().resolveFile("copy/expected/utf-8");
-        File f2 = new File(getOutputDir(), "copytest1.tmp");
-        assertTrue(FILE_UTILS.contentEquals(f1, f2));
+        buildRule.executeTarget("testTranscoding");
+        File f1 = buildRule.getProject().resolveFile("copy/expected/utf-8");
+        File f2 = new File(buildRule.getProject().getProperty("output"), "copytest1.tmp");
+        assertEquals(FileUtilities.getFileContents(f1), FileUtilities.getFileContents(f2));
     }
 
+    @Test
     public void testMissingFileIgnore() {
-        expectLogContaining("testMissingFileIgnore",
-                            "Warning: Could not find file ");
+        buildRule.executeTarget("testMissingFileIgnore");
+        assertContains("Warning: Could not find file", buildRule.getLog());
     }
 
+    @Test
     public void testMissingFileBail() {
-        expectBuildException("testMissingFileBail", "not-there doesn't exist");
-        assertTrue(getBuildException().getMessage()
-                   .startsWith("Warning: Could not find file "));
+        try {
+            buildRule.executeTarget("testMissingFileBail");
+            fail("not-there doesn't exist");
+        } catch (BuildException ex) {
+            assertTrue(ex.getMessage()
+                    .startsWith("Warning: Could not find file "));
+        }
     }
 
+    @Test
     public void testMissingDirIgnore() {
-        expectLogContaining("testMissingDirIgnore", "Warning: ");
+        buildRule.executeTarget("testMissingDirIgnore");
+        assertContains("Warning: ", buildRule.getLog());
     }
 
+    @Test
     public void testMissingDirBail() {
-        expectBuildException("testMissingDirBail", "not-there doesn't exist");
-        assertTrue(getBuildException().getMessage().endsWith(" does not exist."));
+        try {
+            buildRule.executeTarget("testMissingDirBail");
+            fail("not-there doesn't exist");
+        } catch (BuildException ex) {
+            assertTrue(ex.getMessage().endsWith(" does not exist."));
+        }
     }
     
+    @Test
     public void testFileResourcePlain() {
-        executeTarget("testFileResourcePlain");
-        File file1 = new File(getProject().getProperty("to.dir")+"/file1.txt");
-        File file2 = new File(getProject().getProperty("to.dir")+"/file2.txt");
-        File file3 = new File(getProject().getProperty("to.dir")+"/file3.txt");
+        buildRule.executeTarget("testFileResourcePlain");
+        File file1 = new File(buildRule.getProject().getProperty("to.dir")+"/file1.txt");
+        File file2 = new File(buildRule.getProject().getProperty("to.dir")+"/file2.txt");
+        File file3 = new File(buildRule.getProject().getProperty("to.dir")+"/file3.txt");
         assertTrue(file1.exists());
         assertTrue(file2.exists());
         assertTrue(file3.exists());
     }
-    
-    public void _testFileResourceWithMapper() {
-        executeTarget("testFileResourceWithMapper");
-        File file1 = new File(getProject().getProperty("to.dir")+"/file1.txt.bak");
-        File file2 = new File(getProject().getProperty("to.dir")+"/file2.txt.bak");
-        File file3 = new File(getProject().getProperty("to.dir")+"/file3.txt.bak");
+
+    @Ignore("Previously ignored by naming convention")
+    @Test
+    public void testFileResourceWithMapper() {
+        buildRule.executeTarget("testFileResourceWithMapper");
+        File file1 = new File(buildRule.getProject().getProperty("to.dir")+"/file1.txt.bak");
+        File file2 = new File(buildRule.getProject().getProperty("to.dir")+"/file2.txt.bak");
+        File file3 = new File(buildRule.getProject().getProperty("to.dir")+"/file3.txt.bak");
         assertTrue(file1.exists());
         assertTrue(file2.exists());
         assertTrue(file3.exists());
     }
     
+    @Test
     public void testFileResourceWithFilter() {
-        executeTarget("testFileResourceWithFilter");
-        File file1 = new File(getProject().getProperty("to.dir")+"/fileNR.txt");
+        buildRule.executeTarget("testFileResourceWithFilter");
+        File file1 = new File(buildRule.getProject().getProperty("to.dir")+"/fileNR.txt");
         assertTrue(file1.exists());
         try {
             String file1Content = FileUtils.readFully(new FileReader(file1));
@@ -185,44 +226,55 @@ public class CopyTest extends BuildFileT
         }
     }
     
+    @Test
     public void testPathAsResource() {
-        executeTarget("testPathAsResource");
-        File file1 = new File(getProject().getProperty("to.dir")+"/file1.txt");
-        File file2 = new File(getProject().getProperty("to.dir")+"/file2.txt");
-        File file3 = new File(getProject().getProperty("to.dir")+"/file3.txt");
+        buildRule.executeTarget("testPathAsResource");
+        File file1 = new File(buildRule.getProject().getProperty("to.dir")+"/file1.txt");
+        File file2 = new File(buildRule.getProject().getProperty("to.dir")+"/file2.txt");
+        File file3 = new File(buildRule.getProject().getProperty("to.dir")+"/file3.txt");
         assertTrue(file1.exists());
         assertTrue(file2.exists());
         assertTrue(file3.exists());
     }
     
+    @Test
     public void testZipfileset() {
-        executeTarget("testZipfileset");
-        File file1 = new File(getProject().getProperty("to.dir")+"/file1.txt");
-        File file2 = new File(getProject().getProperty("to.dir")+"/file2.txt");
-        File file3 = new File(getProject().getProperty("to.dir")+"/file3.txt");
+        buildRule.executeTarget("testZipfileset");
+        File file1 = new File(buildRule.getProject().getProperty("to.dir")+"/file1.txt");
+        File file2 = new File(buildRule.getProject().getProperty("to.dir")+"/file2.txt");
+        File file3 = new File(buildRule.getProject().getProperty("to.dir")+"/file3.txt");
         assertTrue(file1.exists());
         assertTrue(file2.exists());
         assertTrue(file3.exists());
     }
 
+    @Test
     public void testDirset() {
-        executeTarget("testDirset");
+        buildRule.executeTarget("testDirset");
     }
     
-    public void _testResourcePlain() {
-        executeTarget("testResourcePlain");
+    @Ignore("Previously ignored due to naming convention")
+    @Test
+    public void testResourcePlain() {
+        buildRule.executeTarget("testResourcePlain");
     }
-    
-    public void _testResourcePlainWithMapper() {
-        executeTarget("testResourcePlainWithMapper");
+
+    @Ignore("Previously ignored due to naming convention")
+    @Test
+    public void testResourcePlainWithMapper() {
+        buildRule.executeTarget("testResourcePlainWithMapper");
     }
-    
-    public void _testResourcePlainWithFilter() {
-        executeTarget("testResourcePlainWithFilter");
+
+    @Ignore("Previously ignored due to naming convention")
+    @Test
+    public void testResourcePlainWithFilter() {
+        buildRule.executeTarget("testResourcePlainWithFilter");
     }
-    
-    public void _testOnlineResources() {
-        executeTarget("testOnlineResources");
+
+    @Ignore("Previously ignored due to naming convention")
+    @Test
+    public void testOnlineResources() {
+        buildRule.executeTarget("testOnlineResources");
     }
     
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/CopydirTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/CopydirTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/CopydirTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/CopydirTest.java Fri Apr 18 21:00:38 2014
@@ -18,48 +18,83 @@
 
 package org.apache.tools.ant.taskdefs;
 
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
+import org.junit.Before;
+import org.junit.Test;
 
-/**
- */
-public class CopydirTest extends BuildFileTest {
+import java.io.File;
 
-    public CopydirTest(String name) {
-        super(name);
-    }
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+
+public class CopydirTest {
 
+    public BuildFileRule buildRule = new BuildFileRule();
+
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/copydir.xml");
-        executeTarget("setUp");
+        buildRule.configureProject("src/etc/testcases/taskdefs/copydir.xml");
+        buildRule.executeTarget("setUp");
     }
 
+    @Test
     public void test1() {
-        expectBuildException("test1", "required argument not specified");
+        try {
+            buildRule.executeTarget("test1");
+            fail("Required argument not specified");
+        } catch (BuildException ex) {
+            // TODO assert value
+        }
     }
 
+    @Test
     public void test2() {
-        expectBuildException("test2", "required argument not specified");
+        try {
+            buildRule.executeTarget("test2");
+            fail("Required argument not specified");
+        } catch (BuildException ex) {
+            // TODO assert value
+        }
     }
 
+    @Test
     public void test3() {
-        expectBuildException("test3", "required argument not specified");
+        try {
+            buildRule.executeTarget("test3");
+            fail("Required argument not specified");
+        } catch (BuildException ex) {
+            // TODO assert value
+        }
     }
 
+    @Test
     public void test4() {
-        expectLog("test4", "DEPRECATED - The copydir task is deprecated.  Use copy instead.Warning: src == dest");
+        buildRule.executeTarget("test4");
+        assertEquals("DEPRECATED - The copydir task is deprecated.  Use copy instead.Warning: src == dest",
+                buildRule.getLog());
     }
 
+    @Test
     public void test5() {
-        executeTarget("test5");
-        java.io.File f = new java.io.File(getOutputDir(), "taskdefs.tmp");
+        buildRule.executeTarget("test5");
+        java.io.File f = new java.io.File(new File(buildRule.getProject().getProperty("output")), "taskdefs.tmp");
+
         if (!f.exists() || !f.isDirectory()) {
             fail("Copy failed");
         }
         // We keep this, so we have something to delete in later tests :-)
     }
 
+    @Test
     public void test6() {
-        expectBuildException("test6", "target is file");
+        try {
+            buildRule.executeTarget("test6");
+            fail("target is file");
+        } catch (BuildException ex) {
+            //TODO assert value
+        }
     }
 
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/CopyfileTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/CopyfileTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/CopyfileTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/CopyfileTest.java Fri Apr 18 21:00:38 2014
@@ -18,46 +18,83 @@
 
 package org.apache.tools.ant.taskdefs;
 
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.File;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
 
 /**
  */
-public class CopyfileTest extends BuildFileTest {
+public class CopyfileTest {
 
-    public void test6() {
-        expectBuildException("test6", "target is directory");
-    }
-
-    public CopyfileTest(String name) {
-        super(name);
-    }
+    public final BuildFileRule buildRule = new BuildFileRule();
 
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/copyfile.xml");
-        executeTarget("setUp");
+        buildRule.configureProject("src/etc/testcases/taskdefs/copyfile.xml");
+        buildRule.executeTarget("setUp");
     }
 
+    @Test
     public void test1() {
-        expectBuildException("test1", "required argument not specified");
+        try {
+            buildRule.executeTarget("test1");
+            fail("Required argument not specified");
+        } catch (BuildException ex) {
+            // TODO assert value
+        }
     }
 
+    @Test
     public void test2() {
-        expectBuildException("test2", "required argument not specified");
+        try {
+            buildRule.executeTarget("test2");
+            fail("Required argument not specified");
+        } catch (BuildException ex) {
+            // TODO assert value
+        }
     }
 
+    @Test
     public void test3() {
-        expectBuildException("test3", "required argument not specified");
+        try {
+            buildRule.executeTarget("test3");
+            fail("Required argument not specified");
+        } catch (BuildException ex) {
+            // TODO assert value
+        }
     }
 
+    @Test
     public void test4() {
-        expectLog("test4", "DEPRECATED - The copyfile task is deprecated.  Use copy instead.Warning: src == dest");
+        buildRule.executeTarget("test4");
+        assertEquals("DEPRECATED - The copyfile task is deprecated.  Use copy instead.Warning: src == dest",
+                buildRule.getLog());
     }
 
+    @Test
     public void test5() {
-        executeTarget("test5");
-        java.io.File f = new java.io.File(getOutputDir(), "copyfile.tmp");
-        if (!f.exists()) {
+        buildRule.executeTarget("test5");
+        File f = new File(new File(buildRule.getProject().getProperty("output")), "copyfile.tmp");
+        if (f.exists()) {
+            f.delete();
+        } else {
             fail("Copy failed");
         }
     }
+
+    @Test
+    public void test6() {
+        try {
+            buildRule.executeTarget("test6");
+            fail("Required argument not specified");
+        } catch (BuildException ex) {
+            // TODO assert value
+        }
+    }
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/DefaultExcludesTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/DefaultExcludesTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/DefaultExcludesTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/DefaultExcludesTest.java Fri Apr 18 21:00:38 2014
@@ -18,26 +18,35 @@
 
 package org.apache.tools.ant.taskdefs;
 
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.BuildFileRule;
 import org.apache.tools.ant.DirectoryScanner;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 /**
  */
-public class DefaultExcludesTest extends BuildFileTest {
+public class DefaultExcludesTest {
 
-    public DefaultExcludesTest(String name) {
-        super(name);
-    }
+    @Rule
+    public final BuildFileRule buildRule = new BuildFileRule();
 
+    @Before
     public void setUp() {
-        configureProject("src/etc/testcases/taskdefs/defaultexcludes.xml");
+        buildRule.configureProject("src/etc/testcases/taskdefs/defaultexcludes.xml");
     }
 
+    @After
     public void tearDown() {
-        project.executeTarget("cleanup");
+        buildRule.executeTarget("cleanup");
     }
 
     // Output the default excludes
+    @Test
     public void test1() {
         String[] expected = {
                           "**/*~",
@@ -68,11 +77,12 @@ public class DefaultExcludesTest extends
                           "**/.bzr/**",
                           "**/.bzrignore",
                           "**/.DS_Store"};
-        project.executeTarget("test1");
-        assertEquals("current default excludes", expected, DirectoryScanner.getDefaultExcludes());
+        buildRule.getProject().executeTarget("test1");
+        assertArrayContentsEquals("current default excludes", expected, DirectoryScanner.getDefaultExcludes());
     }
 
     // adding something to the excludes'
+    @Test
     public void test2() {
         String[] expected = {
                           "**/*~",
@@ -104,11 +114,12 @@ public class DefaultExcludesTest extends
                           "**/.bzrignore",
                           "**/.DS_Store",
                           "foo"};
-        project.executeTarget("test2");
-        assertEquals("current default excludes", expected, DirectoryScanner.getDefaultExcludes());
+        buildRule.executeTarget("test2");
+        assertArrayContentsEquals("current default excludes", expected, DirectoryScanner.getDefaultExcludes());
     }
 
     // removing something from the defaults
+    @Test
     public void test3() {
         String[] expected = {
                           "**/*~",
@@ -139,10 +150,11 @@ public class DefaultExcludesTest extends
                           "**/.bzr/**",
                           "**/.bzrignore",
                           "**/.DS_Store"};
-        project.executeTarget("test3");
-        assertEquals("current default excludes", expected, DirectoryScanner.getDefaultExcludes());
+        buildRule.executeTarget("test3");
+        assertArrayContentsEquals("current default excludes", expected, DirectoryScanner.getDefaultExcludes());
     }
-    private void assertEquals(String message, String[] expected, String[] actual) {
+
+    private void assertArrayContentsEquals(String message, String[] expected, String[] actual) {
         // check that both arrays have the same size
         assertEquals(message + " : string array length match", expected.length, actual.length);
         for (int counter=0; counter < expected.length; counter++) {
@@ -151,7 +163,7 @@ public class DefaultExcludesTest extends
                 found |= expected[counter].equals(actual[i]);
             }
             assertTrue(message + " : didn't find element "
-                       + expected[counter] + " in array match", found);
+                    + expected[counter] + " in array match", found);
         }
 
     }



Re: svn commit: r1588563 [4/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

Posted by Antoine Levy Lambert <an...@gmx.de>.
Thanks for the great work Michael,

On Apr 19, 2014, at 1:51 PM, Matt Sicker <bo...@gmail.com> wrote:

> You can use the ExpectedException rule exactly where you expect the
> exception to be thrown. Using the @Test(expected = foo.class) (or whatever
> the attribute name was) is for the whole method. Unless you're talking
> about larger methods being tested that can throw multiple exceptions, then
> that's a different story altogether.
> 
> 
> On 19 April 2014 04:59, Michael Clarke <mi...@gmail.com> wrote:
> 
>>> 
>>> buildRule.executeTarget("test1");
>>> ==> could the BuildFileRule use a default (test name) for executeTarget?
>>>    buildRule.executeTarget();
>>> 
>> 
>> I'm not sure it can - the same build file is often used for multiple tests,
>> each calling a different target, so how would we know which target was
>> intending to be called? If we were to change the general testing practice
>> to have an individual build XML for each test then this would be fine,
>> although I'm not sure this would be the right way to go. Alternatively we
>> could have an executeTarget() method that executes a default target (e.g.
>> "test") or incrementally executes targets for that class ("test1" on first
>> call, "test2" on the second call"), but this seems like it would just be
>> introducing complexity into BuildFileRule to force a specific convention.
>> I'd be interested in other's opinions on this though.
>> 
I am fine the way the BuidFileRule currently works, I do not see the need to introduce new conventions.

>> 
>>> //TODO assert exception message
>>> Here the rule ExpectedException would help
>>> 
>> 
>> Agreed, although the problem still remains that we're not asserting we have
>> the right exception: how do we know Ant hasn't thrown a build exception
>> about a missing attribute when the test is expecting it to throw a
>> BuildException about now being able to create a temporary file? Working out
>> the exception messages and moving to ExpectedException is currently planned
>> to be part of my second phase of migration. There are some tests where we
>> have multiple exception asserts grouped into a single method so I need to
>> spit these into individual methods to allow the ExpectedException rule to
>> be used, but I plan on doing this as part of the exception testing cleanup.
>> 
>> Thanks,
>> Michael
>> 
> 
> 
> 
> -- 
> Matt Sicker <bo...@gmail.com>
Antoine
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: svn commit: r1588563 [4/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

Posted by Matt Sicker <bo...@gmail.com>.
You can use the ExpectedException rule exactly where you expect the
exception to be thrown. Using the @Test(expected = foo.class) (or whatever
the attribute name was) is for the whole method. Unless you're talking
about larger methods being tested that can throw multiple exceptions, then
that's a different story altogether.


On 19 April 2014 04:59, Michael Clarke <mi...@gmail.com> wrote:

> >
> > buildRule.executeTarget("test1");
> > ==> could the BuildFileRule use a default (test name) for executeTarget?
> >     buildRule.executeTarget();
> >
>
> I'm not sure it can - the same build file is often used for multiple tests,
> each calling a different target, so how would we know which target was
> intending to be called? If we were to change the general testing practice
> to have an individual build XML for each test then this would be fine,
> although I'm not sure this would be the right way to go. Alternatively we
> could have an executeTarget() method that executes a default target (e.g.
> "test") or incrementally executes targets for that class ("test1" on first
> call, "test2" on the second call"), but this seems like it would just be
> introducing complexity into BuildFileRule to force a specific convention.
> I'd be interested in other's opinions on this though.
>
>
> > //TODO assert exception message
> > Here the rule ExpectedException would help
> >
>
> Agreed, although the problem still remains that we're not asserting we have
> the right exception: how do we know Ant hasn't thrown a build exception
> about a missing attribute when the test is expecting it to throw a
> BuildException about now being able to create a temporary file? Working out
> the exception messages and moving to ExpectedException is currently planned
> to be part of my second phase of migration. There are some tests where we
> have multiple exception asserts grouped into a single method so I need to
> spit these into individual methods to allow the ExpectedException rule to
> be used, but I plan on doing this as part of the exception testing cleanup.
>
> Thanks,
> Michael
>



-- 
Matt Sicker <bo...@gmail.com>

Re: svn commit: r1588563 [4/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

Posted by Michael Clarke <mi...@gmail.com>.
>
> buildRule.executeTarget("test1");
> ==> could the BuildFileRule use a default (test name) for executeTarget?
>     buildRule.executeTarget();
>

I'm not sure it can - the same build file is often used for multiple tests,
each calling a different target, so how would we know which target was
intending to be called? If we were to change the general testing practice
to have an individual build XML for each test then this would be fine,
although I'm not sure this would be the right way to go. Alternatively we
could have an executeTarget() method that executes a default target (e.g.
"test") or incrementally executes targets for that class ("test1" on first
call, "test2" on the second call"), but this seems like it would just be
introducing complexity into BuildFileRule to force a specific convention.
I'd be interested in other's opinions on this though.


> //TODO assert exception message
> Here the rule ExpectedException would help
>

Agreed, although the problem still remains that we're not asserting we have
the right exception: how do we know Ant hasn't thrown a build exception
about a missing attribute when the test is expecting it to throw a
BuildException about now being able to create a temporary file? Working out
the exception messages and moving to ExpectedException is currently planned
to be part of my second phase of migration. There are some tests where we
have multiple exception asserts grouped into a single method so I need to
spit these into individual methods to allow the ExpectedException rule to
be used, but I plan on doing this as part of the exception testing cleanup.

Thanks,
Michael

AW: svn commit: r1588563 [4/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

Posted by "Jan Matèrne (jhm)" <ap...@materne.de>.
> +    @Rule
> +    public BuildFileRule buildRule = new BuildFileRule();
> +
> +    @Before
>      public void setUp() {
> -        configureProject("src/etc/testcases/taskdefs/available.xml");
> -        executeTarget("setUp");
> +        buildRule.configureProject("src/etc/testcases/taskdefs/available.xml");
> +        buildRule.executeTarget("setUp");
>      }
> 
>      // Nothing specified -> Fail
> +    @Test
>      public void test1() {
> -        expectBuildException("test1", "required argument not specified");
> +        try {
> +            buildRule.executeTarget("test1");
> +            fail("Required argument not specified");
> +        } catch (BuildException ex) {
> +            //TODO assert exception message
> +        }
>      }


Some ideas:

buildRule.executeTarget("test1");
==> could the BuildFileRule use a default (test name) for executeTarget?
    buildRule.executeTarget();


//TODO assert exception message
Here the rule ExpectedException would help


Jan


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org