use of org.apache.tools.ant.types.Reference in project checkstyle by checkstyle.
the class CheckstyleAntTaskTest method testSetClasspathRef.
@Test
public void testSetClasspathRef() {
final CheckstyleAntTask antTask = new CheckstyleAntTask();
antTask.setClasspathRef(new Reference(new Project(), "id"));
assertWithMessage("Classpath should not be null").that(TestUtil.<Path>getInternalState(antTask, "classpath")).isNotNull();
}
use of org.apache.tools.ant.types.Reference in project flyway by flyway.
the class AbstractFlywayTask method prepareClassPath.
/**
* Prepares the classpath this task runs in, so that it includes both the classpath for Flyway and the classpath for
* the JDBC drivers and migrations.
*/
private void prepareClassPath() {
Path classpath = (Path) getProject().getReference("flyway.classpath");
if (classpath != null) {
setClasspath(classpath);
} else {
Reference classpathRef = (Reference) getProject().getReference("flyway.classpathref");
if (classpathRef != null) {
setClasspathref(classpathRef);
}
}
ClassLoader classLoader = new AntClassLoader(getClass().getClassLoader(), getProject(), classPath);
Thread.currentThread().setContextClassLoader(classLoader);
}
use of org.apache.tools.ant.types.Reference in project ant by apache.
the class MultiRootFileSetTest method testEmptyElementIfIsReferenceAdditionalAttributes.
@Test
public void testEmptyElementIfIsReferenceAdditionalAttributes() {
MultiRootFileSet f = new MultiRootFileSet();
f.setProject(getProject());
f.setBaseDirs("a");
try {
f.setRefid(new Reference(getProject(), "dummyref"));
fail("Can add reference to multirootfileset " + " with elements from setBasedirs");
} catch (BuildException be) {
assertEquals("You must not specify more than one attribute " + "when using refid", be.getMessage());
}
f = new MultiRootFileSet();
f.addConfiguredBaseDir(new FileResource(new File(".")));
try {
f.setRefid(new Reference(getProject(), "dummyref"));
fail("Can add reference to multirootfileset" + " with elements from addConfiguredBaseDir");
} catch (BuildException be) {
assertEquals("You must not specify more than one attribute " + "when using refid", be.getMessage());
}
f = new MultiRootFileSet();
f.setRefid(new Reference(getProject(), "dummyref"));
try {
f.setBaseDirs("a");
fail("Can set basedirs in multirootfileset" + " that is a reference.");
} catch (BuildException be) {
assertEquals("You must not specify more than one attribute " + "when using refid", be.getMessage());
}
try {
f.setCache(true);
fail("Can set cache in multirootfileset" + " that is a reference.");
} catch (BuildException be) {
assertEquals("You must not specify more than one attribute " + "when using refid", be.getMessage());
}
try {
f.setType(MultiRootFileSet.SetType.file);
fail("Can set type in multirootfileset" + " that is a reference.");
} catch (BuildException be) {
assertEquals("You must not specify more than one attribute " + "when using refid", be.getMessage());
}
try {
f.addConfiguredBaseDir(new FileResource(new File(".")));
fail("Can add nested basedir in multirootfileset " + " that is a reference.");
} catch (BuildException be) {
assertEquals("You must not specify nested elements when using " + "refid", be.getMessage());
}
}
use of org.apache.tools.ant.types.Reference in project ant by apache.
the class ResourceListTest method testCircularReference.
@Test
public void testCircularReference() {
ResourceList rl1 = new ResourceList();
rl1.setProject(buildRule.getProject());
rl1.setRefid(new Reference(buildRule.getProject(), "foo"));
ResourceList rl2 = new ResourceList();
rl2.setProject(buildRule.getProject());
buildRule.getProject().addReference("foo", rl2);
Union u = new Union();
u.add(rl1);
u.setProject(buildRule.getProject());
rl2.add(u);
try {
rl2.size();
fail("Can make ResourceList a Reference to itself.");
} catch (BuildException be) {
assertEquals("This data type contains a circular reference.", be.getMessage());
}
}
use of org.apache.tools.ant.types.Reference in project ant by apache.
the class ResourceListTest method testEmptyElementWithReference.
@Test
public void testEmptyElementWithReference() {
ResourceList rl = new ResourceList();
rl.setEncoding("foo");
try {
rl.setRefid(new Reference(buildRule.getProject(), "dummyref"));
fail("Can add reference to ResourceList with encoding attribute set.");
} catch (BuildException be) {
assertEquals("You must not specify more than one attribute when using refid", be.getMessage());
}
rl = new ResourceList();
rl.setRefid(new Reference(buildRule.getProject(), "dummyref"));
try {
rl.setEncoding("foo");
fail("Can set encoding in ResourceList that is a reference");
} catch (BuildException be) {
assertEquals("You must not specify more than one attribute when using refid", be.getMessage());
}
rl = new ResourceList();
rl.add(new FileResource(buildRule.getProject(), "."));
try {
rl.setRefid(new Reference(buildRule.getProject(), "dummyref"));
fail("Can add reference to ResourceList with nested resource collection.");
} catch (BuildException be) {
assertEquals("You must not specify nested elements when using refid", be.getMessage());
}
rl = new ResourceList();
rl.setRefid(new Reference(buildRule.getProject(), "dummyref"));
try {
rl.add(new FileResource(buildRule.getProject(), "."));
fail("Can add reference to ResourceList with nested resource collection.");
} catch (BuildException be) {
assertEquals("You must not specify nested elements when using refid", be.getMessage());
}
rl = new ResourceList();
rl.addFilterChain(new FilterChain());
try {
rl.setRefid(new Reference(buildRule.getProject(), "dummyref"));
fail("Can add reference to ResourceList with nested filter chain.");
} catch (BuildException be) {
assertEquals("You must not specify nested elements when using refid", be.getMessage());
}
rl = new ResourceList();
rl.setRefid(new Reference(buildRule.getProject(), "dummyref"));
try {
rl.addFilterChain(new FilterChain());
fail("Can add reference to ResourceList with nested filter chain.");
} catch (BuildException be) {
assertEquals("You must not specify nested elements when using refid", be.getMessage());
}
}
Aggregations