Browse Source

Use BuildFileRule rather that raw “root” property

master
Gintas Grigelionis 7 years ago
parent
commit
f6cffb3658
13 changed files with 81 additions and 92 deletions
  1. +8
    -5
      src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java
  2. +20
    -16
      src/tests/junit/org/apache/tools/ant/taskdefs/ExecStreamRedirectorTest.java
  3. +4
    -6
      src/tests/junit/org/apache/tools/ant/taskdefs/ExecTaskTest.java
  4. +5
    -5
      src/tests/junit/org/apache/tools/ant/taskdefs/ImportTest.java
  5. +4
    -3
      src/tests/junit/org/apache/tools/ant/taskdefs/InitializeClassTest.java
  6. +4
    -7
      src/tests/junit/org/apache/tools/ant/taskdefs/TouchTest.java
  7. +2
    -4
      src/tests/junit/org/apache/tools/ant/taskdefs/XmlPropertyTest.java
  8. +1
    -1
      src/tests/junit/org/apache/tools/ant/taskdefs/optional/PropertyFileTest.java
  9. +12
    -7
      src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java
  10. +13
    -23
      src/tests/junit/org/apache/tools/ant/taskdefs/optional/junitlauncher/JUnitLauncherTaskTest.java
  11. +5
    -8
      src/tests/junit/org/apache/tools/ant/types/FilterSetTest.java
  12. +2
    -6
      src/tests/junit/org/apache/tools/ant/types/ResourceOutputTest.java
  13. +1
    -1
      src/tests/junit/org/apache/tools/ant/types/selectors/PresentSelectorTest.java

+ 8
- 5
src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java View File

@@ -238,17 +238,20 @@ public class DirectoryScannerTest {
@Test @Test
public void testSetFollowLinks() throws IOException, InterruptedException { public void testSetFollowLinks() throws IOException, InterruptedException {
if (supportsSymlinks) { 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 { try {
// add conditions and more commands as soon as the need arises // 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); Process process = Runtime.getRuntime().exec(command);
assertEquals("0 return code expected for external process", 0, process.waitFor()); 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(); DirectoryScanner ds = new DirectoryScanner();


// followLinks should be true by default, but if this ever // followLinks should be true by default, but if this ever


+ 20
- 16
src/tests/junit/org/apache/tools/ant/taskdefs/ExecStreamRedirectorTest.java View File

@@ -1,8 +1,10 @@
package org.apache.tools.ant.taskdefs; package org.apache.tools.ant.taskdefs;


import org.apache.tools.ant.BuildFileRule;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
import org.apache.tools.ant.ProjectHelper; import org.apache.tools.ant.ProjectHelper;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;


import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@@ -20,18 +22,15 @@ import static org.junit.Assert.assertTrue;
*/ */
public class ExecStreamRedirectorTest { public class ExecStreamRedirectorTest {


private Project project;
@Rule
public BuildFileRule buildRule = new BuildFileRule();


@Before @Before
public void setUp() { 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(); 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 @Test
public void testRedirection() throws Exception { 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); assertNotNull("Directory to list isn't available", dirToList);
assertTrue(dirToList + " is not a directory", new File(dirToList).isDirectory()); assertTrue(dirToList + " is not a directory", new File(dirToList).isDirectory());


project.executeTarget("list-dir");
buildRule.executeTarget("list-dir");


// verify the redirected output // verify the redirected output
final String outputDirPath = project.getProperty("output");
final String outputDirPath = buildRule.getProject().getProperty("output");
byte[] dirListingOutput = null; byte[] dirListingOutput = null;
for (int i = 1; i <= 16; i++) { for (int i = 1; i <= 16; i++) {
final File redirectedOutputFile = new File(outputDirPath, "ls" + i + ".txt"); 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); final byte[] redirectedOutput = readAllBytes(redirectedOutputFile);
assertNotNull("No content was redirected to " + redirectedOutputFile, redirectedOutput); 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) { 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 + 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; dirListingOutput = redirectedOutput;
} }
} }


private File createTmpDir() { 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.mkdir();
tmpDir.deleteOnExit(); tmpDir.deleteOnExit();
return tmpDir; return tmpDir;


+ 4
- 6
src/tests/junit/org/apache/tools/ant/taskdefs/ExecTaskTest.java View File

@@ -56,11 +56,8 @@ public class ExecTaskTest {
/** Utilities used for file operations */ /** Utilities used for file operations */
private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();


private File logFile;
private MonitoredBuild myBuild = null;
private volatile boolean buildFinished = false; private volatile boolean buildFinished = false;



@Before @Before
public void setUp() { public void setUp() {
buildRule.configureProject(BUILD_FILE); buildRule.configureProject(BUILD_FILE);
@@ -70,9 +67,10 @@ public class ExecTaskTest {
public void testspawn() throws InterruptedException { public void testspawn() throws InterruptedException {
buildRule.getProject().executeTarget("setUp"); buildRule.getProject().executeTarget("setUp");
assumeNotNull(buildRule.getProject().getProperty("test.can.run")); 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 // this is guaranteed by FileUtils#createTempFile
assertFalse("log file not existing", logFile.exists()); assertFalse("log file not existing", logFile.exists());
// make the spawned process run 1 seconds // make the spawned process run 1 seconds


+ 5
- 5
src/tests/junit/org/apache/tools/ant/taskdefs/ImportTest.java View File

@@ -124,16 +124,16 @@ public class ImportTest {
ln = "/bin/ln"; ln = "/bin/ln";
} }
assumeTrue("Current system does not support Symlinks", new File(ln).exists()); 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); Runtime.getRuntime().exec(new String[] {ln, "-s", "d3a", symlinkFile.getAbsolutePath()}).waitFor(), 0);
try { try {
buildRule.configureProject("src/etc/testcases/taskdefs/import/symlinks/d1/p1.xml"); buildRule.configureProject("src/etc/testcases/taskdefs/import/symlinks/d1/p1.xml");
assertEquals(buildRule.getProject().getProperty("ant.file.p2"), 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"), 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 { } finally {
symlinkFile.delete(); symlinkFile.delete();
} }


+ 4
- 3
src/tests/junit/org/apache/tools/ant/taskdefs/InitializeClassTest.java View File

@@ -42,13 +42,14 @@ public class InitializeClassTest {
@Rule @Rule
public final BuildFileRule buildRule = new BuildFileRule(); 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 @Before
public void setUp() { public void setUp() {
buildRule.configureProject("src/etc/testcases/taskdefs/initializeclass.xml"); buildRule.configureProject("src/etc/testcases/taskdefs/initializeclass.xml");
f1 = buildRule.getProject().resolveFile("forkedout");
f2 = buildRule.getProject().resolveFile("unforkedout");
} }


@Test @Test


+ 4
- 7
src/tests/junit/org/apache/tools/ant/taskdefs/TouchTest.java View File

@@ -39,8 +39,6 @@ public class TouchTest {
@Rule @Rule
public ExpectedException thrown = ExpectedException.none(); public ExpectedException thrown = ExpectedException.none();


private static String TOUCH_FILE = "src/etc/testcases/taskdefs/touchtest";

/** Utilities used for file operations */ /** Utilities used for file operations */
private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();


@@ -55,8 +53,7 @@ public class TouchTest {
} }


public long getTargetTime() { public long getTargetTime() {

File file = new File(System.getProperty("root"), TOUCH_FILE);
File file = new File(buildRule.getProject().getBaseDir(), "touchtest");
if (!file.exists()) { if (!file.exists()) {
throw new BuildException("failed to touch file " + file); throw new BuildException("failed to touch file " + file);
} }
@@ -100,6 +97,7 @@ public class TouchTest {
long time = getTargetTime(); long time = getTargetTime();
assertTimesNearlyMatch(time, now, 5000); assertTimesNearlyMatch(time, now, 5000);
} }

/** /**
* verify that the millis test sets things up * verify that the millis test sets things up
*/ */
@@ -181,8 +179,7 @@ public class TouchTest {
*/ */
private void touchFile(String targetName, long timestamp) { private void touchFile(String targetName, long timestamp) {
buildRule.executeTarget(targetName); buildRule.executeTarget(targetName);
long time = getTargetTime();
assertTimesNearlyMatch(timestamp, time);
assertTimesNearlyMatch(timestamp, getTargetTime());
} }


/** /**
@@ -191,7 +188,7 @@ public class TouchTest {
* @param time long * @param time long
*/ */
public void assertTimesNearlyMatch(long timestamp, long time) { public void assertTimesNearlyMatch(long timestamp, long time) {
long granularity= FILE_UTILS.getFileTimestampGranularity();
long granularity = FILE_UTILS.getFileTimestampGranularity();
assertTimesNearlyMatch(timestamp, time, granularity); assertTimesNearlyMatch(timestamp, time, granularity);
} }




+ 2
- 4
src/tests/junit/org/apache/tools/ant/taskdefs/XmlPropertyTest.java View File

@@ -150,7 +150,7 @@ public class XmlPropertyTest {
private void doTest(String msg, boolean keepRoot, boolean collapse, private void doTest(String msg, boolean keepRoot, boolean collapse,
boolean semantic, boolean include, boolean localRoot) throws IOException { boolean semantic, boolean include, boolean localRoot) throws IOException {
Enumeration<File> iter = Enumeration<File> iter =
getFiles(new File(System.getProperty("root"), "src/etc/testcases/taskdefs/xmlproperty/inputs"));
getFiles(buildRule.getProject().resolveFile("xmlproperty/inputs"));
while (iter.hasMoreElements()) { while (iter.hasMoreElements()) {
File inputFile = iter.nextElement(); File inputFile = iter.nextElement();
// What's the working directory? If local, then its the // 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 * Debugging method to print the properties in the given hashtable
*/ */
private static void printProperties(Hashtable<Object, Object> xmlproperties) { 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));
} }


/** /**


+ 1
- 1
src/tests/junit/org/apache/tools/ant/taskdefs/optional/PropertyFileTest.java View File

@@ -142,7 +142,7 @@ public class PropertyFileTest {
public void testDirect() throws Exception { public void testDirect() throws Exception {
PropertyFile pf = new PropertyFile(); PropertyFile pf = new PropertyFile();
pf.setProject(buildRule.getProject()); pf.setProject(buildRule.getProject());
pf.setFile(new File(System.getProperty("root"), testPropsFilePath));
pf.setFile(new File(buildRule.getOutputDir(), testPropsFilePath));
PropertyFile.Entry entry = pf.createEntry(); PropertyFile.Entry entry = pf.createEntry();


entry.setKey("date"); entry.setKey("date");


+ 12
- 7
src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java View File

@@ -64,8 +64,8 @@ public class JUnitReportTest {
@Test @Test
public void testNoFileJUnitNoFrames() { public void testNoFileJUnitNoFrames() {
buildRule.executeTarget("reports1"); 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() { public void assertIndexCreated() {
@@ -101,21 +101,24 @@ public class JUnitReportTest {
public void testEmptyFile() { public void testEmptyFile() {
buildRule.executeTarget("testEmptyFile"); buildRule.executeTarget("testEmptyFile");
assertIndexCreated(); 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 @Test
public void testIncompleteFile() { public void testIncompleteFile() {
buildRule.executeTarget("testIncompleteFile"); buildRule.executeTarget("testIncompleteFile");
assertIndexCreated(); 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 @Test
public void testWrongElement() { public void testWrongElement() {
buildRule.executeTarget("testWrongElement"); buildRule.executeTarget("testWrongElement");
assertIndexCreated(); 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 // Bugzilla Report 34963
@@ -127,8 +130,10 @@ public class JUnitReportTest {
try { try {
r = new FileReader(new File(buildRule.getOutputDir(), "html/sampleproject/coins/0_CoinTest.html")); r = new FileReader(new File(buildRule.getOutputDir(), "html/sampleproject/coins/0_CoinTest.html"));
String report = FileUtils.readFully(r); 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 { } finally {
FileUtils.close(r); FileUtils.close(r);
} }


+ 13
- 23
src/tests/junit/org/apache/tools/ant/taskdefs/optional/junitlauncher/JUnitLauncherTaskTest.java View File

@@ -2,59 +2,50 @@ package org.apache.tools.ant.taskdefs.optional.junitlauncher;


import org.apache.tools.ant.BuildEvent; import org.apache.tools.ant.BuildEvent;
import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.BuildFileRule;
import org.apache.tools.ant.BuildListener; import org.apache.tools.ant.BuildListener;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
import org.apache.tools.ant.ProjectHelper;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;


import java.io.File;

/** /**
* Tests the {@link JUnitLauncherTask} * Tests the {@link JUnitLauncherTask}
*/ */
public class JUnitLauncherTaskTest { public class JUnitLauncherTaskTest {


private Project project;
@Rule
public final BuildFileRule buildRule = new BuildFileRule();


/** /**
* The JUnit setup method. * The JUnit setup method.
*/ */
@Before @Before
public void setUp() { 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 @Override
public void buildStarted(final BuildEvent event) { public void buildStarted(final BuildEvent event) {

} }


@Override @Override
public void buildFinished(final BuildEvent event) { public void buildFinished(final BuildEvent event) {

} }


@Override @Override
public void targetStarted(final BuildEvent event) { public void targetStarted(final BuildEvent event) {

} }


@Override @Override
public void targetFinished(final BuildEvent event) { public void targetFinished(final BuildEvent event) {

} }


@Override @Override
public void taskStarted(final BuildEvent event) { public void taskStarted(final BuildEvent event) {

} }


@Override @Override
public void taskFinished(final BuildEvent event) { public void taskFinished(final BuildEvent event) {

} }


@Override @Override
@@ -72,7 +63,7 @@ public class JUnitLauncherTaskTest {
*/ */
@Test(expected = BuildException.class) @Test(expected = BuildException.class)
public void testFailureStopsBuild() { public void testFailureStopsBuild() {
project.executeTarget("test-failure-stops-build");
buildRule.executeTarget("test-failure-stops-build");
} }


/** /**
@@ -81,16 +72,15 @@ public class JUnitLauncherTaskTest {
*/ */
@Test @Test
public void testFailureContinuesBuild() { 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 * Tests the execution of test that's expected to succeed
*/ */
@Test @Test
public void testSuccessfulTests() { public void testSuccessfulTests() {
project.executeTarget("test-success");
buildRule.executeTarget("test-success");
} }


/** /**
@@ -98,8 +88,8 @@ public class JUnitLauncherTaskTest {
*/ */
@Test @Test
public void testSpecificMethodTest() { 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 @Test
public void testMultipleIndividualTests() { public void testMultipleIndividualTests() {
project.executeTarget("test-multiple-individual");
buildRule.executeTarget("test-multiple-individual");
} }


/** /**
@@ -116,6 +106,6 @@ public class JUnitLauncherTaskTest {
*/ */
@Test @Test
public void testTestClasses() { public void testTestClasses() {
project.executeTarget("test-batch");
buildRule.executeTarget("test-batch");
} }
} }

+ 5
- 8
src/tests/junit/org/apache/tools/ant/types/FilterSetTest.java View File

@@ -57,22 +57,19 @@ public class FilterSetTest {
@Test @Test
public void test1() throws IOException { public void test1() throws IOException {
buildRule.executeTarget("test1"); 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 @Test
public void test2() throws IOException { public void test2() throws IOException {
buildRule.executeTarget("test2"); 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 @Test
public void test3() throws IOException { public void test3() throws IOException {
buildRule.executeTarget("test3"); 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 { 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()) { if (!file1.exists() || !file2.exists() || file1.length() != file2.length()) {
return false; return false;


+ 2
- 6
src/tests/junit/org/apache/tools/ant/types/ResourceOutputTest.java View File

@@ -49,17 +49,13 @@ public class ResourceOutputTest {
public BuildFileRule buildRule = new BuildFileRule(); public BuildFileRule buildRule = new BuildFileRule();


private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
private static final String BASE_DIR = "src/etc/testcases/types/resources";


private Project project; private Project project;


@Before @Before
public void setUp() { public void setUp() {
buildRule.configureProject(BASE_DIR + "/resourcelist.xml");
buildRule.configureProject("src/etc/testcases/types/resources/resourcelist.xml");
project = buildRule.getProject(); project = buildRule.getProject();
if (System.getProperty("root") != null) {
project.setBasedir(System.getProperty("root"));
}
} }


/** /**
@@ -89,7 +85,7 @@ public class ResourceOutputTest {
} }


@Test @Test
public void teststringoutput3() throws IOException {
public void teststringoutput3() {
StringResource r = new StringResource("bar"); StringResource r = new StringResource("bar");
assertEquals("bar", r.getValue()); assertEquals("bar", r.getValue());
} }


+ 1
- 1
src/tests/junit/org/apache/tools/ant/types/selectors/PresentSelectorTest.java View File

@@ -91,7 +91,7 @@ public class PresentSelectorTest {


@Test @Test
public void testSelectionBehaviour2() { 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); s.setTargetdir(subdir);
Mapper m = s.createMapper(); Mapper m = s.createMapper();
Mapper.MapperType flatten = new Mapper.MapperType(); Mapper.MapperType flatten = new Mapper.MapperType();


Loading…
Cancel
Save