use of nl.nn.adapterframework.xml.FullXmlFilter in project iaf by ibissource.
the class XsltExceptionTest method testXsltException.
public void testXsltException(boolean expectChildThreads, int tailCount) throws Exception {
String xpathExpression = "*/*";
int xsltVersion = 1;
TransformerPool tp = TransformerPool.configureTransformer0(null, null, null, xpathExpression, null, OutputType.XML, false, null, xsltVersion);
XmlWriter writer = new XmlWriter();
FullXmlFilter filter = new FullXmlFilter(writer) {
@Override
public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
if (localName.equals("error")) {
throw new SaxException("Found error");
}
super.startElement(uri, localName, qName, atts);
}
};
try (ThreadConnector threadConnector = expectChildThreads ? new ThreadConnector(null, null, null, (PipeLineSession) null) : null) {
TransformerFilter transformer = tp.getTransformerFilter(threadConnector, filter);
try {
try (SaxDocumentBuilder seb = new SaxDocumentBuilder("root", transformer)) {
seb.addElement("elem");
seb.addElement("error");
for (int i = 0; i < tailCount; i++) {
seb.addElement("elem");
}
}
fail("Expected exception to be caught while processing");
} catch (Exception e) {
System.out.println("Expected exception: " + e.getMessage());
}
System.out.println(writer);
}
}
Aggregations