use of org.apache.axiom.om.OMSourcedElement in project webservices-axiom by apache.
the class TestGetAttribute method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMSourcedElement element = factory.createOMElement(new PullOMDataSource("<root attr='value'/>"), "root", null);
OMAttribute attr = element.getAttribute(new QName("attr"));
assertThat(attr).isNotNull();
assertThat(attr.getLocalName()).isEqualTo("attr");
}
use of org.apache.axiom.om.OMSourcedElement in project webservices-axiom by apache.
the class TestGetAllDeclaredNamespaces method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMSourcedElement element = factory.createOMElement(new PullOMDataSource("<root xmlns:p='urn:ns1'/>"), "root", null);
Iterator<OMNamespace> attributes = element.getAllDeclaredNamespaces();
assertThat(attributes.hasNext()).isTrue();
OMNamespace ns = attributes.next();
assertThat(ns.getPrefix()).isEqualTo("p");
assertThat(ns.getNamespaceURI()).isEqualTo("urn:ns1");
assertThat(attributes.hasNext()).isFalse();
}
use of org.apache.axiom.om.OMSourcedElement 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.OMSourcedElement in project webservices-axiom by apache.
the class TestRegisterCustomBuilderForPayloadAfterSOAPFaultCheck method runTest.
@Override
protected void runTest(SOAPEnvelope envelope) throws Throwable {
SOAPModelBuilder builder = (SOAPModelBuilder) envelope.getBuilder();
// Do a fault check. This is normally done in the engine (Axiom) and should
// not cause inteference with the custom builder processing
envelope.getBody().hasFault();
// Do the registration here...this simulates when it could occure in the engine
// (After the fault check and during phase processing...probably dispatch phase)
((CustomBuilderSupport) builder).registerCustomBuilder(CustomBuilder.Selector.PAYLOAD, new BlobOMDataSourceCustomBuilder(MemoryBlob.FACTORY, "utf-8"));
OMElement bodyElement = envelope.getBody().getFirstElement();
assertTrue(bodyElement instanceof OMSourcedElement);
}
use of org.apache.axiom.om.OMSourcedElement 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());
}
Aggregations