assertTrue(childrenCount == 5);
}
public void testInvalidXML() throws Exception {
XMLStreamReader originalReader = StAXUtils.createXMLStreamReader(getTestResource("invalid_xml.xml"));
InvocationCounter invocationCounter = new InvocationCounter();
XMLStreamReader reader = (XMLStreamReader)invocationCounter.createProxy(originalReader);
StAXOMBuilder stAXOMBuilder =
OMXMLBuilderFactory.createStAXOMBuilder(OMAbstractFactory.getSOAP11Factory(),
reader);
Exception exception = null;
while (exception == null || stAXOMBuilder.isCompleted()) {
try {
stAXOMBuilder.next();
} catch (Exception e) {
exception =e;
}
}
assertTrue("Expected an exception because invalid_xml.xml is wrong", exception != null);
assertTrue(invocationCounter.getInvocationCount() > 0);
invocationCounter.reset();
// Intentionally call builder again to make sure the same error is returned.
Exception exception2 = null;
try {
stAXOMBuilder.next();
} catch (Exception e) {
exception2 = e;
}
assertEquals(0, invocationCounter.getInvocationCount());
assertTrue("Expected a second exception because invalid_xml.xml is wrong", exception2 != null);
assertTrue("Expected the same exception. first=" + exception + " second=" + exception2,
exception.getMessage().equals(exception2.getMessage()));