use of de.pdark.decentxml.XMLIOSource in project fabric8 by jboss-fuse.
the class RouteXml method createExemplarDoc.
protected Document createExemplarDoc() throws IOException {
String exemplar = "io/fabric8/camel/tooling/exemplar.xml";
URL url = findResource(exemplar, null);
if (url != null) {
return parse(new XMLIOSource(url));
} else {
LOG.warn("Could not find file {} on the class path", exemplar);
Document d = new Document();
d.addNode(new Element("beans", springNamespace));
return d;
}
}
use of de.pdark.decentxml.XMLIOSource in project tycho by eclipse.
the class Util method openXmlFromZip.
public static Document openXmlFromZip(File zipFile, String xmlFile) throws IOException, ZipException {
XMLParser parser = new XMLParser();
ZipFile zip = new ZipFile(zipFile);
try {
ZipEntry contentXmlEntry = zip.getEntry(xmlFile);
InputStream entryStream = zip.getInputStream(contentXmlEntry);
return parser.parse(new XMLIOSource(entryStream));
} finally {
zip.close();
}
}
use of de.pdark.decentxml.XMLIOSource 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.XMLIOSource 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.XMLIOSource in project tycho by eclipse.
the class IU method read.
public static IU read(File file) throws IOException {
FileInputStream is = new FileInputStream(file);
try {
Document iuDocument = parser.parse(new XMLIOSource(is));
Element root = iuDocument.getChild(UNIT);
if (root == null)
throw new RuntimeException("No iu found.");
IU result = new IU(iuDocument, root);
if (result.getId() == null)
throw new RuntimeException(String.format("The IU defined in %s is missing an id.", file.getAbsolutePath()));
if (result.getVersion() == null)
throw new RuntimeException(String.format("The IU defined in %s is missing a version.", file.getAbsolutePath()));
return result;
} finally {
IOUtil.close(is);
}
}
Aggregations