use of org.apache.axiom.om.OMXMLParserWrapper in project webservices-axiom by apache.
the class TestGetElementTextFromParser method runTest.
@Override
protected void runTest() throws Throwable {
// Note: We test getElementText on a child element ("b") of the element from which we request
// the XMLStreamReader ("a"). This is to make sure that the XMLStreamReader implementation actually
// delegates to the underlying parser (which is not necessarily the case on "a").
OMXMLParserWrapper builder = builderFactory.getBuilder(metaFactory, new InputSource(new StringReader("<a><b>AB<!--comment text-->CD</b></a>")));
OMElement element = builder.getDocumentElement();
// Build a certain number of descendants. This is used to test scenarios where the XMLStreamReader
// needs to switch to pull through mode in the middle of the element from which we attempt to
// get the text.
Iterator<OMNode> it = element.getDescendants(true);
for (int i = 0; i < build; i++) {
it.next();
}
XMLStreamReader reader = element.getXMLStreamReader(cache);
assertEquals(XMLStreamReader.START_ELEMENT, reader.next());
assertEquals(XMLStreamReader.START_ELEMENT, reader.next());
assertEquals("ABCD", reader.getElementText());
}
use of org.apache.axiom.om.OMXMLParserWrapper in project webservices-axiom by apache.
the class TestAxiom95 method runTest.
@Override
protected void runTest() throws Throwable {
OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(), TestAxiom95.class.getResourceAsStream("defaultNamespace2.xml"));
String serializedXML = builder.getDocumentElement().toString();
// System.out.println("serializedXML = " + serializedXML);
assertTrue(serializedXML.indexOf("xmlns=\"\"") == -1);
}
use of org.apache.axiom.om.OMXMLParserWrapper in project webservices-axiom by apache.
the class TestDiscardIncomplete method runTest.
@Override
protected void runTest() throws Throwable {
OMElement documentElement = null;
// first build the OM tree without caching and see whether we can discard
// an element from it
// TODO: we shouldn't use a SOAP message here
OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(), SOAPSampleSet.WSA.getMessage(SOAPSpec.SOAP11).getInputStream());
documentElement = builder.getDocumentElement();
documentElement.getFirstElement().discard();
String envelopeString = documentElement.toStringWithConsume();
documentElement.close(false);
}
use of org.apache.axiom.om.OMXMLParserWrapper in project webservices-axiom by apache.
the class TestDetachAfterBuilderClose method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(factory, new StringReader("<a><b/></a>"));
OMElement element = builder.getDocumentElement();
element.build();
builder.close();
// Since the node has been fully built, this should not result in an error
element.detach();
}
use of org.apache.axiom.om.OMXMLParserWrapper in project webservices-axiom by apache.
the class TestGetDocumentFromBuilder method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMDataSource ds = new StringOMDataSource("<root><a/></root>");
OMSourcedElement element = factory.createOMElement(ds);
// Force expansion
element.getFirstOMChild();
OMXMLParserWrapper builder = element.getBuilder();
try {
builder.getDocument();
fail("Expected UnsupportedOperationException");
} catch (UnsupportedOperationException ex) {
// Expected
}
try {
builder.getDocumentElement();
fail("Expected UnsupportedOperationException");
} catch (UnsupportedOperationException ex) {
// Expected
}
}
Aggregations