use of de.pdark.decentxml.Document in project tycho by eclipse.
the class Feature method write.
public static void write(Feature feature, File file, String indent) throws IOException {
OutputStream os = new BufferedOutputStream(new FileOutputStream(file));
Document document = feature.document;
try {
String enc = document.getEncoding() != null ? document.getEncoding() : "UTF-8";
Writer w = new OutputStreamWriter(os, enc);
XMLWriter xw = new XMLWriter(w);
xw.setIndent(indent);
try {
document.toXML(xw);
} finally {
xw.flush();
}
} finally {
IOUtil.close(os);
}
}
use of de.pdark.decentxml.Document in project tycho by eclipse.
the class IU method write.
public static void write(IU iu, File file, String indent) throws IOException {
OutputStream os = new BufferedOutputStream(new FileOutputStream(file));
Document document = iu.document;
try {
String enc = document.getEncoding() != null ? document.getEncoding() : "UTF-8";
Writer w = new OutputStreamWriter(os, enc);
XMLWriter xw = new XMLWriter(w);
xw.setIndent(indent);
try {
document.toXML(xw);
} finally {
xw.flush();
}
} finally {
IOUtil.close(os);
}
}
use of de.pdark.decentxml.Document in project tycho by eclipse.
the class RepositoryCategoriesTest method testDeployableFeature.
@Test
public void testDeployableFeature() throws Exception {
Verifier v01 = getVerifier("TYCHO0439repositoryCategories");
v01.executeGoal("install");
v01.verifyErrorFreeLog();
File site = new File(v01.getBasedir(), "target/site");
Assert.assertTrue(site.isDirectory());
File content = new File(site, "content.jar");
Assert.assertTrue(content.isFile());
boolean found = false;
XMLParser parser = new XMLParser();
Document document = null;
ZipFile contentJar = new ZipFile(content);
try {
ZipEntry contentXmlEntry = contentJar.getEntry("content.xml");
document = parser.parse(new XMLIOSource(contentJar.getInputStream(contentXmlEntry)));
} finally {
contentJar.close();
}
Element repository = document.getRootElement();
all_units: for (Element unit : repository.getChild("units").getChildren("unit")) {
for (Element property : unit.getChild("properties").getChildren("property")) {
if ("org.eclipse.equinox.p2.type.category".equals(property.getAttributeValue("name")) && Boolean.parseBoolean(property.getAttributeValue("value"))) {
found = true;
break all_units;
}
}
}
Assert.assertTrue("Custom category", found);
}
use of de.pdark.decentxml.Document in project tycho by eclipse.
the class MultienvP2infTest method test.
@Test
public void test() throws Exception {
Verifier verifier = getVerifier("/p2Inf.multiEnv", false);
verifier.getCliOptions().add("-De342-repo=" + ResourceUtil.P2Repositories.ECLIPSE_342);
verifier.executeGoals(Arrays.asList("clean", "verify"));
verifier.verifyErrorFreeLog();
// assert repository contains cross-platform IUs defined in p2.inf files
Document doc;
ZipFile zip = new ZipFile(new File(verifier.getBasedir(), "product/target/repository/content.jar"));
try {
InputStream is = zip.getInputStream(zip.getEntry("content.xml"));
doc = new XMLParser().parse(new XMLIOSource(is));
} finally {
zip.close();
}
List<String> ids = new ArrayList<>();
Element units = doc.getChild("repository/units");
for (Element unit : units.getChildren("unit")) {
ids.add(unit.getAttributeValue("id"));
}
// disabled due to a limitation of BundlesAction
// Assert.assertTrue(ids.contains("tychotest.bundle.macosx"));
Assert.assertTrue(ids.contains("tychotest.feature.macosx"));
Assert.assertTrue(ids.contains("tychotest.product.macosx"));
}
use of de.pdark.decentxml.Document in project tycho by eclipse.
the class TargetDefinitionFile method write.
public static void write(TargetDefinitionFile target, File file) throws IOException {
OutputStream os = new BufferedOutputStream(new FileOutputStream(file));
Document document = target.document;
try {
String enc = document.getEncoding() != null ? document.getEncoding() : "UTF-8";
Writer w = new OutputStreamWriter(os, enc);
XMLWriter xw = new XMLWriter(w);
try {
document.toXML(xw);
} finally {
xw.flush();
}
} finally {
IOUtil.close(os);
}
}
Aggregations