use of org.apache.tools.ant.Project in project ant by apache.
the class PropertySet method getEffectiveProperties.
private Map<String, Object> getEffectiveProperties() {
final Project prj = getProject();
final Map<String, Object> result;
if (prj == null) {
result = getAllSystemProperties();
} else {
final PropertyHelper ph = PropertyHelper.getPropertyHelper(prj);
result = prj.getPropertyNames().stream().map(n -> new AbstractMap.SimpleImmutableEntry<>(n, ph.getProperty(n))).filter(kv -> kv.getValue() != null).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}
// quick & dirty, to make nested mapped p-sets work:
for (PropertySet set : setRefs) {
result.putAll(set.getPropertyMap());
}
return result;
}
use of org.apache.tools.ant.Project in project ant by apache.
the class ManifestTest method testLongLine.
/**
* Tets long line wrapping
*/
@Test
public void testLongLine() throws IOException, ManifestException {
Project p = buildRule.getProject();
p.setUserProperty("test.longline", LONG_LINE);
p.setUserProperty("test.long68name", LONG_68_NAME);
p.setUserProperty("test.long70name", LONG_70_NAME);
p.setUserProperty("test.notlongname", NOT_LONG_NAME);
p.setUserProperty("test.value", VALUE);
buildRule.executeTarget("testLongLine");
Manifest manifest = getManifest(expandedManifest);
Manifest.Section mainSection = manifest.getMainSection();
String classpath = mainSection.getAttributeValue("class-path");
assertEquals("Class-Path attribute was not set correctly - ", LONG_LINE, classpath);
assertEquals("LONG_68_NAME_VALUE_MISMATCH", VALUE, mainSection.getAttributeValue(LONG_68_NAME));
assertEquals("LONG_70_NAME_VALUE_MISMATCH", VALUE, mainSection.getAttributeValue(LONG_70_NAME));
assertEquals("NOT_LONG_NAME_VALUE_MISMATCH", VALUE, mainSection.getAttributeValue(NOT_LONG_NAME));
Set<String> set = new HashSet<>();
try (FileReader fin = new FileReader(expandedManifest)) {
BufferedReader in = new BufferedReader(fin);
String read = in.readLine();
while (read != null) {
set.add(read);
read = in.readLine();
}
in.close();
}
assertTrue("Manifest file should have contained string ", set.remove(" NOT_LONG"));
assertTrue("Manifest file should have contained string ", set.remove(" NG"));
assertTrue("Manifest file should have contained string ", set.remove(LONG_70_NAME + ": "));
assertTrue("Manifest file should have contained string ", set.remove(NOT_LONG_NAME + ": NOT_LO"));
}
use of org.apache.tools.ant.Project in project ant by apache.
the class EchoTest method setUp.
@Before
public void setUp() {
Project p = new Project();
p.init();
logger = new EchoTestLogger();
p.addBuildListener(logger);
echo = new Echo();
echo.setProject(p);
}
use of org.apache.tools.ant.Project in project exist by eXist-db.
the class BaseTaskTest method taskAvailable.
@Test
public void taskAvailable() {
final Project project = buildFileRule.getProject();
project.setProperty(PROP_ANT_TEST_DATA_TASK_NAME, taskName);
buildFileRule.executeTarget("taskAvailable");
final String result = project.getProperty(PROP_ANT_TEST_DATA_RESULT);
assertTrue(Boolean.parseBoolean(result));
}
use of org.apache.tools.ant.Project in project exist by eXist-db.
the class ServerTaskTest method backup.
@Test
public void backup() throws IOException {
final Project project = buildFileRule.getProject();
final Path backupDir = temporaryFolder.newFolder().toPath();
project.setProperty(PROP_ANT_TEST_DATA_BACKUP_DIR, backupDir.toAbsolutePath().toString());
buildFileRule.executeTarget("backup");
assertTrue(Files.exists(backupDir.resolve("db").resolve("__contents__.xml")));
}
Aggregations