use of org.apache.axiom.om.NodeUnavailableException in project webservices-axiom by apache.
the class TestGetChildElementsConsumed method runTest.
@Override
protected void runTest() throws Throwable {
OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(), TestGetChildElementsConsumed.class.getResourceAsStream("purchase-order.xml"));
OMElement documentElement = builder.getDocumentElement();
XMLStreamReader reader = documentElement.getXMLStreamReaderWithoutCaching();
//building the tree
while (reader.hasNext()) {
reader.next();
}
//error since the underlying stream is fully consumed without building the object tree
try {
Iterator<OMElement> childElements = documentElement.getChildElements();
while (childElements.hasNext()) {
childElements.next();
}
fail("Expected NodeUnavailableException");
} catch (NodeUnavailableException ex) {
// Expected
}
documentElement.close(false);
}
use of org.apache.axiom.om.NodeUnavailableException in project webservices-axiom by apache.
the class TestSerializeAndConsumeConsumed method runTest.
@Override
protected void runTest() throws Throwable {
OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(), TestGetChildElementsConsumed.class.getResourceAsStream("purchase-order.xml"));
OMElement documentElement = builder.getDocumentElement();
XMLStreamReader reader = documentElement.getXMLStreamReaderWithoutCaching();
//building the tree
while (reader.hasNext()) {
reader.next();
}
//error since the underlying stream is fully consumed without building the object tree
try {
documentElement.serializeAndConsume(StAX.createNullXMLStreamWriter());
fail("Expected NodeUnavailableException");
} catch (NodeUnavailableException e) {
//wea re cool
}
documentElement.close(false);
}
Aggregations