use of org.apache.axiom.om.ds.StringOMDataSource 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
}
}
use of org.apache.axiom.om.ds.StringOMDataSource in project webservices-axiom by apache.
the class TestGetNamespaceNormalized2 method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMSourcedElement element = factory.createOMElement(new StringOMDataSource("<element>content</element>"), new QName("element"));
assertNull(element.getNamespace());
// Expand the element
element.getFirstOMChild();
assertNull(element.getNamespace());
}
use of org.apache.axiom.om.ds.StringOMDataSource in project webservices-axiom by apache.
the class TestGetNamespaceNormalized method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMNamespace ns = factory.createOMNamespace("", "");
OMSourcedElement element = factory.createOMElement(new StringOMDataSource("<element>content</element>"), "element", ns);
// This actually returns the "declared" namespace because the sourced element is not
// expanded yet. Nevertheless the value should have been normalized to null.
assertNull(element.getNamespace());
// Now expand the element and check getNamespace() again
element.getFirstOMChild();
assertNull(element.getNamespace());
}
use of org.apache.axiom.om.ds.StringOMDataSource in project webservices-axiom by apache.
the class TestCloneWithSourcedElement2 method runTest.
@Override
protected void runTest() throws Throwable {
SOAPEnvelope sourceEnv = soapFactory.getDefaultEnvelope();
SOAPBody body = sourceEnv.getBody();
SOAPHeader header = sourceEnv.getHeader();
// Create a header OMSE
OMDataSource dsHdr = new StringOMDataSource("<hdr:myheader xmlns:hdr=\"urn://test\">Hello World</hdr:myheader>");
OMNamespace hdrNS = header.getOMFactory().createOMNamespace("urn://test", "hdr");
SOAPFactory sf = (SOAPFactory) header.getOMFactory();
SOAPHeaderBlock shb = sf.createSOAPHeaderBlock("myheader", hdrNS, dsHdr);
// test setting processing flag
shb.setProcessed();
header.addChild(shb);
// Create a payload
OMDataSource ds = new StringOMDataSource("<tns:payload xmlns:tns=\"urn://test\">Hello World</tns:payload>");
OMNamespace ns = body.getOMFactory().createOMNamespace("urn://test", "tns");
OMSourcedElement omse = body.getOMFactory().createOMElement(ds, "payload", ns);
body.addChild(omse);
copyAndCheck(sourceEnv);
// The source SOAPHeaderBlock should not be expanded in the process
assertFalse(shb.isExpanded());
}
use of org.apache.axiom.om.ds.StringOMDataSource in project webservices-axiom by apache.
the class TestGetNextOMSiblingIncomplete method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMSourcedElement omse = factory.createOMElement(new StringOMDataSource("<sourcedelement/>"));
OMElement parent = factory.createOMElement(new QName("parent"));
parent.addChild(omse);
// Cause expansion of the sourced element without building it completely
omse.getLocalName();
assertTrue(omse.isExpanded());
assertFalse(omse.isComplete());
// Call getNextOMSibling(); this should not build the element
omse.getNextOMSibling();
assertFalse(omse.isComplete());
}
Aggregations