Search in sources :

Example 1 with XMLParser

use of de.pdark.decentxml.XMLParser in project sling by apache.

the class TolerantXMLParser method parse.

public static Document parse(final XMLSource xmlSource, final String originDetails) throws IOException {
    XMLParser parser = new XMLParser() {

        @Override
        protected XMLTokenizer createTokenizer(XMLSource source) {
            XMLTokenizer tolerantTokenizerIgnoringEntities = new TolerantXMLTokenizer(source, originDetails);
            tolerantTokenizerIgnoringEntities.setTreatEntitiesAsText(this.isTreatEntitiesAsText());
            return tolerantTokenizerIgnoringEntities;
        }
    };
    return parser.parse(xmlSource);
}
Also used : XMLTokenizer(de.pdark.decentxml.XMLTokenizer) XMLParser(de.pdark.decentxml.XMLParser) XMLSource(de.pdark.decentxml.XMLSource)

Example 2 with XMLParser

use of de.pdark.decentxml.XMLParser 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();
    }
}
Also used : ZipFile(java.util.zip.ZipFile) XMLIOSource(de.pdark.decentxml.XMLIOSource) InputStream(java.io.InputStream) ZipEntry(java.util.zip.ZipEntry) XMLParser(de.pdark.decentxml.XMLParser)

Example 3 with XMLParser

use of de.pdark.decentxml.XMLParser 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);
}
Also used : ZipFile(java.util.zip.ZipFile) XMLIOSource(de.pdark.decentxml.XMLIOSource) ZipEntry(java.util.zip.ZipEntry) Element(de.pdark.decentxml.Element) Verifier(org.apache.maven.it.Verifier) XMLParser(de.pdark.decentxml.XMLParser) Document(de.pdark.decentxml.Document) ZipFile(java.util.zip.ZipFile) File(java.io.File) Test(org.junit.Test) AbstractTychoIntegrationTest(org.eclipse.tycho.test.AbstractTychoIntegrationTest)

Example 4 with XMLParser

use of de.pdark.decentxml.XMLParser 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"));
}
Also used : ZipFile(java.util.zip.ZipFile) XMLIOSource(de.pdark.decentxml.XMLIOSource) InputStream(java.io.InputStream) Element(de.pdark.decentxml.Element) ArrayList(java.util.ArrayList) Verifier(org.apache.maven.it.Verifier) Document(de.pdark.decentxml.Document) XMLParser(de.pdark.decentxml.XMLParser) File(java.io.File) ZipFile(java.util.zip.ZipFile) Test(org.junit.Test) AbstractTychoIntegrationTest(org.eclipse.tycho.test.AbstractTychoIntegrationTest)

Aggregations

XMLParser (de.pdark.decentxml.XMLParser)4 XMLIOSource (de.pdark.decentxml.XMLIOSource)3 ZipFile (java.util.zip.ZipFile)3 Document (de.pdark.decentxml.Document)2 Element (de.pdark.decentxml.Element)2 File (java.io.File)2 InputStream (java.io.InputStream)2 ZipEntry (java.util.zip.ZipEntry)2 Verifier (org.apache.maven.it.Verifier)2 AbstractTychoIntegrationTest (org.eclipse.tycho.test.AbstractTychoIntegrationTest)2 Test (org.junit.Test)2 XMLSource (de.pdark.decentxml.XMLSource)1 XMLTokenizer (de.pdark.decentxml.XMLTokenizer)1 ArrayList (java.util.ArrayList)1