use of org.apache.tools.ant.types.Reference in project ant-ivy by apache.
the class IvyConfigureTest method getIvyInstance.
private Ivy getIvyInstance() {
IvyTask task = new IvyTask() {
public void doExecute() throws BuildException {
}
};
task.setProject(project);
task.init();
Reference ref = new Reference(task.getProject(), configure.getSettingsId());
// ref.setProject(project);
task.setSettingsRef(ref);
return task.getIvyInstance();
}
use of org.apache.tools.ant.types.Reference in project ant-ivy by apache.
the class IvyTaskTest method testReferencedSettings.
@Test
public void testReferencedSettings() throws MalformedURLException {
Project p = TestHelper.newProject();
p.setProperty("myproperty", "myvalue");
IvyAntSettings antSettings = new IvyAntSettings();
antSettings.setProject(p);
// antSettings.setId("mySettings");
antSettings.setFile(new File("test/repositories/ivysettings.xml"));
p.addReference("mySettings", antSettings);
IvyTask task = new IvyTask() {
public void doExecute() throws BuildException {
}
};
task.setProject(p);
task.setSettingsRef(new Reference(task.getProject(), "mySettings"));
Ivy ivy = task.getIvyInstance();
assertNotNull(ivy);
IvySettings settings = ivy.getSettings();
assertNotNull(settings);
assertEquals(new File("build/cache").getAbsoluteFile(), settings.getDefaultCache());
assertEquals(new File("test/repositories/ivysettings.xml").getAbsolutePath(), settings.getVariables().getVariable("ivy.settings.file"));
assertEquals(new File("test/repositories/ivysettings.xml").toURI().toURL().toExternalForm(), settings.getVariables().getVariable("ivy.settings.url"));
assertEquals(new File("test/repositories").getAbsolutePath(), settings.getVariables().getVariable("ivy.settings.dir"));
assertEquals("myvalue", settings.getVariables().getVariable("myproperty"));
}
use of org.apache.tools.ant.types.Reference in project checkstyle by checkstyle.
the class CheckstyleAntTaskTest method testSetClasspathRef1.
/**
* This test is created to satisfy pitest, it is hard to emulate Reference by Id.
*/
@Test
public void testSetClasspathRef1() {
final CheckstyleAntTask antTask = new CheckstyleAntTask();
final Project project = new Project();
antTask.setClasspath(new Path(project, "firstPath"));
antTask.setClasspathRef(new Reference(project, "idXX"));
assertWithMessage("Classpath should not be null").that(TestUtil.<Path>getInternalState(antTask, "classpath")).isNotNull();
final Path classpath = TestUtil.getInternalState(antTask, "classpath");
final BuildException ex = assertThrows(BuildException.class, classpath::list, "BuildException is expected");
assertWithMessage("unexpected exception message").that(ex.getMessage()).isEqualTo("Reference idXX not found.");
}
Aggregations