use of org.apache.axiom.om.DeferredParsingException in project webservices-axiom by apache.
the class TestInvalidXML method runTest.
@Override
protected void runTest() throws Throwable {
XMLStreamReader originalReader = StAXUtils.createXMLStreamReader(TestInvalidXML.class.getResourceAsStream("invalid_xml.xml"));
InvocationCounter invocationCounter = new InvocationCounter();
XMLStreamReader reader = (XMLStreamReader) invocationCounter.createProxy(originalReader);
OMElement element = OMXMLBuilderFactory.createStAXOMBuilder(metaFactory.getOMFactory(), reader).getDocumentElement();
DeferredParsingException exception;
try {
element.getNextOMSibling();
exception = null;
} catch (DeferredParsingException ex) {
exception = ex;
}
assertThat(exception).isNotNull();
assertTrue(invocationCounter.getInvocationCount() > 0);
invocationCounter.reset();
// Intentionally call builder again to make sure the same error is returned.
DeferredParsingException exception2;
try {
element.getNextOMSibling();
exception2 = null;
} catch (DeferredParsingException ex) {
exception2 = ex;
}
assertThat(invocationCounter.getInvocationCount()).isEqualTo(0);
assertThat(exception2).isNotNull();
assertThat(exception2.getMessage()).isEqualTo(exception.getMessage());
}
Aggregations