Search in sources :

Example 21 with Path

use of org.apache.tools.ant.types.Path in project ant by apache.

the class AntTest method testRefId.

@Test
public void testRefId() {
    Path testPath = new Path(buildRule.getProject());
    testPath.createPath().setPath(System.getProperty("java.class.path"));
    PropertyChecker pc = new PropertyChecker("testprop", new String[] { null, testPath.toString() });
    buildRule.getProject().addBuildListener(pc);
    buildRule.executeTarget("testRefid");
    AssertionFailedError ae = pc.getError();
    if (ae != null) {
        throw ae;
    }
    buildRule.getProject().removeBuildListener(pc);
}
Also used : Path(org.apache.tools.ant.types.Path) AssertionFailedError(junit.framework.AssertionFailedError) Test(org.junit.Test)

Example 22 with Path

use of org.apache.tools.ant.types.Path in project ant by apache.

the class AntTest method testReferenceInheritance.

@Test
public void testReferenceInheritance() {
    Path p = Path.systemClasspath;
    p.setProject(buildRule.getProject());
    buildRule.getProject().addReference("path", p);
    buildRule.getProject().addReference("no-override", p);
    testReference("testInherit", new String[] { "path", "path" }, new boolean[] { true, true }, p);
    testReference("testInherit", new String[] { "no-override", "no-override" }, new boolean[] { true, false }, p);
    testReference("testInherit", new String[] { "no-override", "no-override" }, new boolean[] { false, false }, null);
}
Also used : Path(org.apache.tools.ant.types.Path) Test(org.junit.Test)

Example 23 with Path

use of org.apache.tools.ant.types.Path in project ant by apache.

the class AntTest method testReferenceNoInheritance.

@Test
public void testReferenceNoInheritance() {
    Path p = Path.systemClasspath;
    p.setProject(buildRule.getProject());
    buildRule.getProject().addReference("path", p);
    buildRule.getProject().addReference("no-override", p);
    testReference("testNoInherit", new String[] { "path", "path" }, new boolean[] { true, false }, p);
    testReference("testNoInherit", new String[] { "path", "path" }, new boolean[] { false, true }, null);
    testReference("testInherit", new String[] { "no-override", "no-override" }, new boolean[] { true, false }, p);
    testReference("testInherit", new String[] { "no-override", "no-override" }, new boolean[] { false, false }, null);
}
Also used : Path(org.apache.tools.ant.types.Path) Test(org.junit.Test)

Example 24 with Path

use of org.apache.tools.ant.types.Path in project ant by apache.

the class AntTest method testReferenceRename.

@Test
public void testReferenceRename() {
    Path p = Path.systemClasspath;
    p.setProject(buildRule.getProject());
    buildRule.getProject().addReference("path", p);
    testReference("testRename", new String[] { "path", "path" }, new boolean[] { true, false }, p);
    testReference("testRename", new String[] { "path", "path" }, new boolean[] { false, true }, null);
    testReference("testRename", new String[] { "newpath", "newpath" }, new boolean[] { false, true }, p);
}
Also used : Path(org.apache.tools.ant.types.Path) Test(org.junit.Test)

Example 25 with Path

use of org.apache.tools.ant.types.Path in project ant by apache.

the class AntClassLoaderDelegationTest method testFindIsolateResources.

@SuppressWarnings("resource")
@Test
public void testFindIsolateResources() throws Exception {
    String buildTestcases = System.getProperty("build.tests");
    assertNotNull("defined ${build.tests}", buildTestcases);
    assertTrue("have a dir " + buildTestcases, new File(buildTestcases).isDirectory());
    Path path = new Path(p, buildTestcases + "/org");
    // A special parent loader which is not the system class loader:
    ClassLoader parent = new ParentLoader();
    URL urlFromPath = new URL(FILE_UTILS.toURI(buildTestcases) + "org/" + TEST_RESOURCE);
    AntClassLoader acl = new AntClassLoader(parent, p, path, false);
    acl.setIsolated(true);
    assertEquals("correct resources (reverse delegation order)", Collections.singletonList(urlFromPath), enum2List(acl.getResources(TEST_RESOURCE)));
}
Also used : Path(org.apache.tools.ant.types.Path) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Aggregations

Path (org.apache.tools.ant.types.Path)174 File (java.io.File)78 BuildException (org.apache.tools.ant.BuildException)55 Test (org.junit.Test)49 Project (org.apache.tools.ant.Project)28 IOException (java.io.IOException)24 Commandline (org.apache.tools.ant.types.Commandline)21 ArrayList (java.util.ArrayList)12 DirectoryScanner (org.apache.tools.ant.DirectoryScanner)10 URL (java.net.URL)8 AntClassLoader (org.apache.tools.ant.AntClassLoader)7 Java (org.apache.tools.ant.taskdefs.Java)7 StringTokenizer (java.util.StringTokenizer)6 FileSet (org.apache.tools.ant.types.FileSet)6 Reference (org.apache.tools.ant.types.Reference)6 Resource (org.apache.tools.ant.types.Resource)6 Test (org.junit.jupiter.api.Test)6 GroovyClassLoader (groovy.lang.GroovyClassLoader)5 Enumeration (java.util.Enumeration)5 Vector (java.util.Vector)5