Use BuildFileRule rather that raw “root” property

Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/f6cffb36
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/f6cffb36
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/f6cffb36

Branch: refs/heads/master
Commit: f6cffb3658299752392b4cd010d221fb9c5ca2cf
Parents: 97080ce
Author: Gintas Grigelionis <gin...@apache.org>
Authored: Tue Apr 24 07:02:19 2018 +0200
Committer: Gintas Grigelionis <gin...@apache.org>
Committed: Tue Apr 24 07:08:44 2018 +0200

----------------------------------------------------------------------
 .../apache/tools/ant/DirectoryScannerTest.java  | 13 ++++---
 .../ant/taskdefs/ExecStreamRedirectorTest.java  | 36 +++++++++++---------
 .../apache/tools/ant/taskdefs/ExecTaskTest.java | 10 +++---
 .../apache/tools/ant/taskdefs/ImportTest.java   | 10 +++---
 .../tools/ant/taskdefs/InitializeClassTest.java |  7 ++--
 .../apache/tools/ant/taskdefs/TouchTest.java    | 11 +++---
 .../tools/ant/taskdefs/XmlPropertyTest.java     |  6 ++--
 .../ant/taskdefs/optional/PropertyFileTest.java |  2 +-
 .../optional/junit/JUnitReportTest.java         | 19 +++++++----
 .../junitlauncher/JUnitLauncherTaskTest.java    | 36 +++++++-------------
 .../apache/tools/ant/types/FilterSetTest.java   | 13 +++----
 .../tools/ant/types/ResourceOutputTest.java     |  8 ++---
 .../types/selectors/PresentSelectorTest.java    |  2 +-
 13 files changed, 81 insertions(+), 92 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/f6cffb36/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java 
b/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java
index 33fe2a9..773d33a 100644
--- a/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java
+++ b/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java
@@ -238,17 +238,20 @@ public class DirectoryScannerTest {
     @Test
     public void testSetFollowLinks() throws IOException, InterruptedException {
         if (supportsSymlinks) {
-            File linkFile = new File(System.getProperty("root"), 
"src/main/org/apache/tools/ThisIsALink");
-            System.err.println("link exists pre-test? " + linkFile.exists());
+            File dir = new File(buildRule.getProject().getBaseDir(),
+                    "../../../main/org/apache/tools");
+
+            File linkFile = new File(dir, "ThisIsALink");
+            assertFalse("link exists pre-test", linkFile.exists());
+            File targetFile = new File(dir, "ant");
+            assertTrue("target does not exist pre-test", targetFile.exists());
 
             try {
                 // add conditions and more commands as soon as the need arises
-                String[] command = new String[] {"ln", "-s", "ant", 
linkFile.getAbsolutePath()};
+                String[] command = new String[] {"ln", "-s", 
targetFile.getAbsolutePath(), linkFile.getAbsolutePath()};
                 Process process = Runtime.getRuntime().exec(command);
                 assertEquals("0 return code expected for external process", 0, 
process.waitFor());
 
-                File dir = new File(System.getProperty("root"), 
"src/main/org/apache/tools");
-
                 DirectoryScanner ds = new DirectoryScanner();
 
                 // followLinks should be true by default, but if this ever

http://git-wip-us.apache.org/repos/asf/ant/blob/f6cffb36/src/tests/junit/org/apache/tools/ant/taskdefs/ExecStreamRedirectorTest.java
----------------------------------------------------------------------
diff --git 
a/src/tests/junit/org/apache/tools/ant/taskdefs/ExecStreamRedirectorTest.java 
b/src/tests/junit/org/apache/tools/ant/taskdefs/ExecStreamRedirectorTest.java
index 99cb018..36ee234 100644
--- 
a/src/tests/junit/org/apache/tools/ant/taskdefs/ExecStreamRedirectorTest.java
+++ 
b/src/tests/junit/org/apache/tools/ant/taskdefs/ExecStreamRedirectorTest.java
@@ -1,8 +1,10 @@
 package org.apache.tools.ant.taskdefs;
 
+import org.apache.tools.ant.BuildFileRule;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.ProjectHelper;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
 
 import java.io.ByteArrayOutputStream;
@@ -20,18 +22,15 @@ import static org.junit.Assert.assertTrue;
  */
 public class ExecStreamRedirectorTest {
 
-    private Project project;
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
 
     @Before
     public void setUp() {
-        project = new Project();
-        project.init();
-        final File antFile = new File(System.getProperty("root"), 
"src/etc/testcases/taskdefs/exec/exec-with-redirector.xml");
-        project.setUserProperty("ant.file", antFile.getAbsolutePath());
+        
buildRule.configureProject("src/etc/testcases/taskdefs/exec/exec-with-redirector.xml");
         final File outputDir = this.createTmpDir();
-        project.setUserProperty("output", outputDir.toString());
-        ProjectHelper.configureProject(project, antFile);
-        project.executeTarget("setUp");
+        buildRule.getProject().setUserProperty("output", outputDir.toString());
+        buildRule.executeTarget("setUp");
     }
 
     /**
@@ -43,32 +42,37 @@ public class ExecStreamRedirectorTest {
      */
     @Test
     public void testRedirection() throws Exception {
-        final String dirToList = project.getProperty("dir.to.ls");
+        final String dirToList = 
buildRule.getProject().getProperty("dir.to.ls");
         assertNotNull("Directory to list isn't available", dirToList);
         assertTrue(dirToList + " is not a directory", new 
File(dirToList).isDirectory());
 
-        project.executeTarget("list-dir");
+        buildRule.executeTarget("list-dir");
 
         // verify the redirected output
-        final String outputDirPath = project.getProperty("output");
+        final String outputDirPath = 
buildRule.getProject().getProperty("output");
         byte[] dirListingOutput = null;
         for (int i = 1; i <= 16; i++) {
             final File redirectedOutputFile = new File(outputDirPath, "ls" + i 
+ ".txt");
-            assertTrue(redirectedOutputFile + " is missing or not a regular 
file", redirectedOutputFile.isFile());
+            assertTrue(redirectedOutputFile + " is missing or not a regular 
file",
+                    redirectedOutputFile.isFile());
             final byte[] redirectedOutput = readAllBytes(redirectedOutputFile);
             assertNotNull("No content was redirected to " + 
redirectedOutputFile, redirectedOutput);
-            assertNotEquals("Content in redirected file " + 
redirectedOutputFile + " was empty", 0, redirectedOutput.length);
+            assertNotEquals("Content in redirected file " + 
redirectedOutputFile + " was empty",
+                    0, redirectedOutput.length);
             if (dirListingOutput != null) {
-                // compare the directory listing that was redirected to these 
files. all files should have the same content
+                // Compare the directory listing that was redirected to these 
files.
+                // All files should have the same content.
                 assertTrue("Redirected output in file " + redirectedOutputFile 
+
-                        " doesn't match content in other redirected output 
file(s)", Arrays.equals(dirListingOutput, redirectedOutput));
+                        " doesn't match content in other redirected output 
file(s)",
+                        Arrays.equals(dirListingOutput, redirectedOutput));
             }
             dirListingOutput = redirectedOutput;
         }
     }
 
     private File createTmpDir() {
-        final File tmpDir = new File(System.getProperty("java.io.tmpdir"), 
String.valueOf("temp-" + System.nanoTime()));
+        final File tmpDir = new File(System.getProperty("java.io.tmpdir"),
+                String.valueOf("temp-" + System.nanoTime()));
         tmpDir.mkdir();
         tmpDir.deleteOnExit();
         return tmpDir;

http://git-wip-us.apache.org/repos/asf/ant/blob/f6cffb36/src/tests/junit/org/apache/tools/ant/taskdefs/ExecTaskTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ExecTaskTest.java 
b/src/tests/junit/org/apache/tools/ant/taskdefs/ExecTaskTest.java
index 8e81fcd..fd92ded 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/ExecTaskTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ExecTaskTest.java
@@ -56,11 +56,8 @@ public class ExecTaskTest {
     /** Utilities used for file operations */
     private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
 
-    private File logFile;
-    private MonitoredBuild myBuild = null;
     private volatile boolean buildFinished = false;
 
-
     @Before
     public void setUp() {
         buildRule.configureProject(BUILD_FILE);
@@ -70,9 +67,10 @@ public class ExecTaskTest {
     public void testspawn() throws InterruptedException {
         buildRule.getProject().executeTarget("setUp");
         assumeNotNull(buildRule.getProject().getProperty("test.can.run"));
-        myBuild = new MonitoredBuild(new File(System.getProperty("root"), 
BUILD_FILE), "spawn");
-        logFile = FILE_UTILS.createTempFile("spawn", "log", new 
File(buildRule.getProject().getProperty("output")),
-                false, false);
+        MonitoredBuild myBuild = new MonitoredBuild(new File(
+                buildRule.getProject().getProperty("ant.file")), "spawn");
+        File logFile = FILE_UTILS.createTempFile("spawn", "log",
+                new File(buildRule.getProject().getProperty("output")), false, 
false);
         // this is guaranteed by FileUtils#createTempFile
         assertFalse("log file not existing", logFile.exists());
         // make the spawned process run 1 seconds

http://git-wip-us.apache.org/repos/asf/ant/blob/f6cffb36/src/tests/junit/org/apache/tools/ant/taskdefs/ImportTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ImportTest.java 
b/src/tests/junit/org/apache/tools/ant/taskdefs/ImportTest.java
index c6e2acc..2c1e1e7 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/ImportTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ImportTest.java
@@ -124,16 +124,16 @@ public class ImportTest {
             ln = "/bin/ln";
         }
         assumeTrue("Current system does not support Symlinks", new 
File(ln).exists());
-        String symlink = "src/etc/testcases/taskdefs/import/symlinks/d3b";
-        File symlinkFile = new File(System.getProperty("root"), symlink);
-        assertEquals("'" + ln + " -s d3a " + symlink + "' failed",
+        
buildRule.configureProject("src/etc/testcases/taskdefs/import/import.xml");
+        File symlinkFile = buildRule.getProject().resolveFile("symlinks/d3b");
+        assertEquals("'" + ln + " -s d3a " + symlinkFile.getAbsolutePath() + 
"' failed",
                 Runtime.getRuntime().exec(new String[] {ln, "-s", "d3a", 
symlinkFile.getAbsolutePath()}).waitFor(), 0);
         try {
             
buildRule.configureProject("src/etc/testcases/taskdefs/import/symlinks/d1/p1.xml");
             assertEquals(buildRule.getProject().getProperty("ant.file.p2"),
-                new File(System.getProperty("root"), 
"src/etc/testcases/taskdefs/import/symlinks/d2/p2.xml").getAbsolutePath());
+                
buildRule.getProject().resolveFile("../d2/p2.xml").getAbsolutePath());
             assertEquals(buildRule.getProject().getProperty("ant.file.p3"),
-                new File(System.getProperty("root"), 
"src/etc/testcases/taskdefs/import/symlinks/d3b/p3.xml").getAbsolutePath());
+                    
buildRule.getProject().resolveFile("../d3b/p3.xml").getAbsolutePath());
         } finally {
             symlinkFile.delete();
         }

http://git-wip-us.apache.org/repos/asf/ant/blob/f6cffb36/src/tests/junit/org/apache/tools/ant/taskdefs/InitializeClassTest.java
----------------------------------------------------------------------
diff --git 
a/src/tests/junit/org/apache/tools/ant/taskdefs/InitializeClassTest.java 
b/src/tests/junit/org/apache/tools/ant/taskdefs/InitializeClassTest.java
index 04aa153..6b6d14f 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/InitializeClassTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/InitializeClassTest.java
@@ -42,13 +42,14 @@ public class InitializeClassTest {
     @Rule
     public final BuildFileRule buildRule = new BuildFileRule();
 
-    private File f1 = new File(System.getProperty("root"), 
"src/etc/testcases/taskdefs/forkedout");
-    private File f2 = new File(System.getProperty("root"), 
"src/etc/testcases/taskdefs/unforkedout");
-
+    private File f1;
+    private File f2;
 
     @Before
     public void setUp() {
         
buildRule.configureProject("src/etc/testcases/taskdefs/initializeclass.xml");
+        f1 = buildRule.getProject().resolveFile("forkedout");
+        f2 = buildRule.getProject().resolveFile("unforkedout");
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ant/blob/f6cffb36/src/tests/junit/org/apache/tools/ant/taskdefs/TouchTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/TouchTest.java 
b/src/tests/junit/org/apache/tools/ant/taskdefs/TouchTest.java
index 700aec1..fc845d9 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/TouchTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/TouchTest.java
@@ -39,8 +39,6 @@ public class TouchTest {
     @Rule
     public ExpectedException thrown = ExpectedException.none();
 
-    private static String TOUCH_FILE = "src/etc/testcases/taskdefs/touchtest";
-
     /** Utilities used for file operations */
     private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
 
@@ -55,8 +53,7 @@ public class TouchTest {
     }
 
     public long getTargetTime() {
-
-        File file = new File(System.getProperty("root"), TOUCH_FILE);
+        File file = new File(buildRule.getProject().getBaseDir(), "touchtest");
         if (!file.exists()) {
             throw new BuildException("failed to touch file " + file);
         }
@@ -100,6 +97,7 @@ public class TouchTest {
         long time = getTargetTime();
         assertTimesNearlyMatch(time, now, 5000);
     }
+
     /**
      * verify that the millis test sets things up
      */
@@ -181,8 +179,7 @@ public class TouchTest {
      */
     private void touchFile(String targetName, long timestamp) {
         buildRule.executeTarget(targetName);
-        long time = getTargetTime();
-        assertTimesNearlyMatch(timestamp, time);
+        assertTimesNearlyMatch(timestamp, getTargetTime());
     }
 
     /**
@@ -191,7 +188,7 @@ public class TouchTest {
      * @param time long
      */
     public void assertTimesNearlyMatch(long timestamp, long time) {
-        long granularity= FILE_UTILS.getFileTimestampGranularity();
+        long granularity = FILE_UTILS.getFileTimestampGranularity();
         assertTimesNearlyMatch(timestamp, time, granularity);
     }
 

http://git-wip-us.apache.org/repos/asf/ant/blob/f6cffb36/src/tests/junit/org/apache/tools/ant/taskdefs/XmlPropertyTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/XmlPropertyTest.java 
b/src/tests/junit/org/apache/tools/ant/taskdefs/XmlPropertyTest.java
index 0145757..c02deb7 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/XmlPropertyTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/XmlPropertyTest.java
@@ -150,7 +150,7 @@ public class XmlPropertyTest {
     private void doTest(String msg, boolean keepRoot, boolean collapse,
                         boolean semantic, boolean include, boolean localRoot) 
throws IOException {
         Enumeration<File> iter =
-            getFiles(new File(System.getProperty("root"), 
"src/etc/testcases/taskdefs/xmlproperty/inputs"));
+            getFiles(buildRule.getProject().resolveFile("xmlproperty/inputs"));
         while (iter.hasMoreElements()) {
             File inputFile = iter.nextElement();
             // What's the working directory?  If local, then its the
@@ -264,9 +264,7 @@ public class XmlPropertyTest {
      * Debugging method to print the properties in the given hashtable
      */
     private static void printProperties(Hashtable<Object, Object> 
xmlproperties) {
-        for (Map.Entry<Object, Object> entry : xmlproperties.entrySet()) {
-            System.out.println(entry.getKey() + " = " + entry.getValue());
-        }
+        xmlproperties.forEach((key, value) -> System.out.println(key + " = " + 
value));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ant/blob/f6cffb36/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PropertyFileTest.java
----------------------------------------------------------------------
diff --git 
a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PropertyFileTest.java 
b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PropertyFileTest.java
index 3896c8f..41ed189 100644
--- 
a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PropertyFileTest.java
+++ 
b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PropertyFileTest.java
@@ -142,7 +142,7 @@ public class PropertyFileTest {
     public void testDirect() throws Exception {
         PropertyFile pf = new PropertyFile();
         pf.setProject(buildRule.getProject());
-        pf.setFile(new File(System.getProperty("root"), testPropsFilePath));
+        pf.setFile(new File(buildRule.getOutputDir(), testPropsFilePath));
         PropertyFile.Entry entry = pf.createEntry();
 
         entry.setKey("date");

http://git-wip-us.apache.org/repos/asf/ant/blob/f6cffb36/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java
----------------------------------------------------------------------
diff --git 
a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java
 
b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java
index 2355b7a..f4d111a 100644
--- 
a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java
+++ 
b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java
@@ -64,8 +64,8 @@ public class JUnitReportTest {
     @Test
     public void testNoFileJUnitNoFrames() {
         buildRule.executeTarget("reports1");
-        assertFalse("No file junit-noframes.html expected", new 
File(System.getProperty("root"),
-                
"src/etc/testcases/taskdefs/optional/junitreport/test/html/junit-noframes.html").exists());
+        assertFalse("No file junit-noframes.html expected", 
buildRule.getProject().resolveFile(
+                "junitreport/test/html/junit-noframes.html").exists());
     }
 
     public void assertIndexCreated() {
@@ -101,21 +101,24 @@ public class JUnitReportTest {
     public void testEmptyFile() {
         buildRule.executeTarget("testEmptyFile");
         assertIndexCreated();
-        assertThat("Required text not found in log", buildRule.getLog(), 
containsString(XMLResultAggregator.WARNING_EMPTY_FILE));
+        assertThat("Required text not found in log", buildRule.getLog(),
+                containsString(XMLResultAggregator.WARNING_EMPTY_FILE));
     }
 
     @Test
     public void testIncompleteFile() {
         buildRule.executeTarget("testIncompleteFile");
         assertIndexCreated();
-        assertThat("Required text not found in log", buildRule.getLog(), 
containsString(XMLResultAggregator.WARNING_IS_POSSIBLY_CORRUPTED));
+        assertThat("Required text not found in log", buildRule.getLog(),
+                
containsString(XMLResultAggregator.WARNING_IS_POSSIBLY_CORRUPTED));
     }
 
     @Test
     public void testWrongElement() {
         buildRule.executeTarget("testWrongElement");
         assertIndexCreated();
-        assertThat("Required text not found in log", buildRule.getLog(), 
containsString(XMLResultAggregator.WARNING_INVALID_ROOT_ELEMENT));
+        assertThat("Required text not found in log", buildRule.getLog(),
+                
containsString(XMLResultAggregator.WARNING_INVALID_ROOT_ELEMENT));
     }
 
     // Bugzilla Report 34963
@@ -127,8 +130,10 @@ public class JUnitReportTest {
         try {
             r = new FileReader(new File(buildRule.getOutputDir(), 
"html/sampleproject/coins/0_CoinTest.html"));
             String report = FileUtils.readFully(r);
-            assertThat("output must contain <br>:\n" + report, report, 
containsString("junit.framework.AssertionFailedError: DOEG<br>"));
-            assertThat("#51049: output must translate line breaks:\n" + 
report, report, containsString("cur['line.separator'] = '\\r\\n';"));
+            assertThat("output must contain <br>:\n" + report, report,
+                    containsString("junit.framework.AssertionFailedError: 
DOEG<br>"));
+            assertThat("#51049: output must translate line breaks:\n" + 
report, report,
+                    containsString("cur['line.separator'] = '\\r\\n';"));
         } finally {
             FileUtils.close(r);
         }

http://git-wip-us.apache.org/repos/asf/ant/blob/f6cffb36/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junitlauncher/JUnitLauncherTaskTest.java
----------------------------------------------------------------------
diff --git 
a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junitlauncher/JUnitLauncherTaskTest.java
 
b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junitlauncher/JUnitLauncherTaskTest.java
index be574ca..8e0144f 100644
--- 
a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junitlauncher/JUnitLauncherTaskTest.java
+++ 
b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junitlauncher/JUnitLauncherTaskTest.java
@@ -2,59 +2,50 @@ package org.apache.tools.ant.taskdefs.optional.junitlauncher;
 
 import org.apache.tools.ant.BuildEvent;
 import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
 import org.apache.tools.ant.BuildListener;
 import org.apache.tools.ant.Project;
-import org.apache.tools.ant.ProjectHelper;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
 
-import java.io.File;
-
 /**
  * Tests the {@link JUnitLauncherTask}
  */
 public class JUnitLauncherTaskTest {
 
-    private Project project;
+    @Rule
+    public final BuildFileRule buildRule = new BuildFileRule();
 
     /**
      * The JUnit setup method.
      */
     @Before
     public void setUp() {
-        File antFile = new File(System.getProperty("root"), 
"src/etc/testcases/taskdefs/optional/junitlauncher.xml");
-        this.project = new Project();
-        this.project.init();
-        ProjectHelper.configureProject(project, antFile);
-        project.addBuildListener(new BuildListener() {
+        
buildRule.configureProject("src/etc/testcases/taskdefs/optional/junitlauncher.xml");
+        buildRule.getProject().addBuildListener(new BuildListener() {
             @Override
             public void buildStarted(final BuildEvent event) {
-
             }
 
             @Override
             public void buildFinished(final BuildEvent event) {
-
             }
 
             @Override
             public void targetStarted(final BuildEvent event) {
-
             }
 
             @Override
             public void targetFinished(final BuildEvent event) {
-
             }
 
             @Override
             public void taskStarted(final BuildEvent event) {
-
             }
 
             @Override
             public void taskFinished(final BuildEvent event) {
-
             }
 
             @Override
@@ -72,7 +63,7 @@ public class JUnitLauncherTaskTest {
      */
     @Test(expected = BuildException.class)
     public void testFailureStopsBuild() {
-        project.executeTarget("test-failure-stops-build");
+        buildRule.executeTarget("test-failure-stops-build");
     }
 
     /**
@@ -81,16 +72,15 @@ public class JUnitLauncherTaskTest {
      */
     @Test
     public void testFailureContinuesBuild() {
-        project.executeTarget("test-failure-continues-build");
+        buildRule.executeTarget("test-failure-continues-build");
     }
 
-
     /**
      * Tests the execution of test that's expected to succeed
      */
     @Test
     public void testSuccessfulTests() {
-        project.executeTarget("test-success");
+        buildRule.executeTarget("test-success");
     }
 
     /**
@@ -98,8 +88,8 @@ public class JUnitLauncherTaskTest {
      */
     @Test
     public void testSpecificMethodTest() {
-        project.executeTarget("test-one-specific-method");
-        project.executeTarget("test-multiple-specific-methods");
+        buildRule.executeTarget("test-one-specific-method");
+        buildRule.executeTarget("test-multiple-specific-methods");
     }
 
     /**
@@ -107,7 +97,7 @@ public class JUnitLauncherTaskTest {
      */
     @Test
     public void testMultipleIndividualTests() {
-        project.executeTarget("test-multiple-individual");
+        buildRule.executeTarget("test-multiple-individual");
     }
 
     /**
@@ -116,6 +106,6 @@ public class JUnitLauncherTaskTest {
      */
     @Test
     public void testTestClasses() {
-        project.executeTarget("test-batch");
+        buildRule.executeTarget("test-batch");
     }
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/f6cffb36/src/tests/junit/org/apache/tools/ant/types/FilterSetTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/types/FilterSetTest.java 
b/src/tests/junit/org/apache/tools/ant/types/FilterSetTest.java
index a057a60..b989f6d 100644
--- a/src/tests/junit/org/apache/tools/ant/types/FilterSetTest.java
+++ b/src/tests/junit/org/apache/tools/ant/types/FilterSetTest.java
@@ -57,22 +57,19 @@ public class FilterSetTest {
     @Test
     public void test1() throws IOException {
         buildRule.executeTarget("test1");
-        assertTrue("Filterset 1 failed", 
compareFiles("src/etc/testcases/types/gold/filterset1.txt",
-                                                      
"src/etc/testcases/types/dest1.txt"));
+        assertTrue("Filterset 1 failed", compareFiles("gold/filterset1.txt", 
"dest1.txt"));
     }
 
     @Test
     public void test2() throws IOException {
         buildRule.executeTarget("test2");
-        assertTrue("Filterset 2 failed", 
compareFiles("src/etc/testcases/types/gold/filterset2.txt",
-                                                      
"src/etc/testcases/types/dest2.txt"));
+        assertTrue("Filterset 2 failed", compareFiles("gold/filterset2.txt", 
"dest2.txt"));
     }
 
     @Test
     public void test3() throws IOException {
         buildRule.executeTarget("test3");
-        assertTrue("Filterset 3 failed", 
compareFiles("src/etc/testcases/types/gold/filterset3.txt",
-                                                      
"src/etc/testcases/types/dest3.txt"));
+        assertTrue("Filterset 3 failed", compareFiles("gold/filterset3.txt", 
"dest3.txt"));
     }
 
     /**
@@ -200,8 +197,8 @@ public class FilterSetTest {
     }
 
     private boolean compareFiles(String name1, String name2) throws 
IOException {
-        File file1 = new File(System.getProperty("root"), name1);
-        File file2 = new File(System.getProperty("root"), name2);
+        File file1 = buildRule.getProject().resolveFile(name1);
+        File file2 = buildRule.getProject().resolveFile(name2);
 
         if (!file1.exists() || !file2.exists() || file1.length() != 
file2.length()) {
             return false;

http://git-wip-us.apache.org/repos/asf/ant/blob/f6cffb36/src/tests/junit/org/apache/tools/ant/types/ResourceOutputTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/types/ResourceOutputTest.java 
b/src/tests/junit/org/apache/tools/ant/types/ResourceOutputTest.java
index 167d3e7..a827209 100644
--- a/src/tests/junit/org/apache/tools/ant/types/ResourceOutputTest.java
+++ b/src/tests/junit/org/apache/tools/ant/types/ResourceOutputTest.java
@@ -49,17 +49,13 @@ public class ResourceOutputTest {
     public BuildFileRule buildRule = new BuildFileRule();
 
     private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
-    private static final String BASE_DIR = "src/etc/testcases/types/resources";
 
     private Project project;
 
     @Before
     public void setUp() {
-        buildRule.configureProject(BASE_DIR + "/resourcelist.xml");
+        
buildRule.configureProject("src/etc/testcases/types/resources/resourcelist.xml");
         project = buildRule.getProject();
-        if (System.getProperty("root") != null) {
-            project.setBasedir(System.getProperty("root"));
-        }
     }
 
     /**
@@ -89,7 +85,7 @@ public class ResourceOutputTest {
     }
 
     @Test
-    public void teststringoutput3() throws IOException {
+    public void teststringoutput3() {
         StringResource r = new StringResource("bar");
         assertEquals("bar", r.getValue());
     }

http://git-wip-us.apache.org/repos/asf/ant/blob/f6cffb36/src/tests/junit/org/apache/tools/ant/types/selectors/PresentSelectorTest.java
----------------------------------------------------------------------
diff --git 
a/src/tests/junit/org/apache/tools/ant/types/selectors/PresentSelectorTest.java 
b/src/tests/junit/org/apache/tools/ant/types/selectors/PresentSelectorTest.java
index 3d6d95f..cb45594 100644
--- 
a/src/tests/junit/org/apache/tools/ant/types/selectors/PresentSelectorTest.java
+++ 
b/src/tests/junit/org/apache/tools/ant/types/selectors/PresentSelectorTest.java
@@ -91,7 +91,7 @@ public class PresentSelectorTest {
 
     @Test
     public void testSelectionBehaviour2() {
-        File subdir = new File(System.getProperty("root"), 
"src/etc/testcases/taskdefs/expected");
+        File subdir = 
selectorRule.getProject().resolveFile("../taskdefs/expected");
         s.setTargetdir(subdir);
         Mapper m = s.createMapper();
         Mapper.MapperType flatten = new Mapper.MapperType();

Reply via email to