use of aQute.libg.sax.filters.MergeContentFilter in project bnd by bndtools.
the class TestSAXFilters method testMergeInconsistentRoots.
public void testMergeInconsistentRoots() throws Exception {
ByteArrayOutputStream output = new ByteArrayOutputStream();
MergeContentFilter merger = new MergeContentFilter();
XMLReader reader = SAXUtil.buildPipeline(new StreamResult(output), merger);
try {
reader.parse(new InputSource(new ByteArrayInputStream(SAMPLE1.getBytes())));
reader.parse(new InputSource(new ByteArrayInputStream(SAMPLE3.getBytes())));
fail("Should throw exception for inconsistent roots");
} catch (SAXException e) {
}
}
use of aQute.libg.sax.filters.MergeContentFilter in project bnd by bndtools.
the class TestSAXFilters method testDontRepeatProcessingInstruction.
public void testDontRepeatProcessingInstruction() throws Exception {
ByteArrayOutputStream output = new ByteArrayOutputStream();
MergeContentFilter merger = new MergeContentFilter();
XMLReader reader = SAXUtil.buildPipeline(new StreamResult(output), merger);
reader.parse(new InputSource(new ByteArrayInputStream(SAMPLE5.getBytes())));
reader.parse(new InputSource(new ByteArrayInputStream(SAMPLE5.getBytes())));
merger.closeRootAndDocument();
String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><?xml-stylesheet type='text/xsl' href='http://www2.osgi.org/www/obr2html.xsl'?><root><a/><a/></root>";
assertEquals(expected, stripLineBreaks(output.toString()));
}
use of aQute.libg.sax.filters.MergeContentFilter in project bnd by bndtools.
the class TestSAXFilters method testMerge.
public void testMerge() throws Exception {
ByteArrayOutputStream output = new ByteArrayOutputStream();
MergeContentFilter merger = new MergeContentFilter();
XMLReader reader = SAXUtil.buildPipeline(new StreamResult(output), merger);
reader.parse(new InputSource(new ByteArrayInputStream(SAMPLE1.getBytes())));
reader.parse(new InputSource(new ByteArrayInputStream(SAMPLE2.getBytes())));
merger.closeRootAndDocument();
assertEquals(MERGED1_2, output.toString());
assertEquals(2, merger.getRootElements().size());
}
Aggregations