Search in sources :

Example 31 with OMSourcedElement

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");
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) PullOMDataSource(org.apache.axiom.ts.om.sourcedelement.util.PullOMDataSource) QName(javax.xml.namespace.QName) OMSourcedElement(org.apache.axiom.om.OMSourcedElement) OMAttribute(org.apache.axiom.om.OMAttribute)

Example 32 with OMSourcedElement

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();
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) PullOMDataSource(org.apache.axiom.ts.om.sourcedelement.util.PullOMDataSource) OMNamespace(org.apache.axiom.om.OMNamespace) OMSourcedElement(org.apache.axiom.om.OMSourcedElement)

Example 33 with OMSourcedElement

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());
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) OMNamespace(org.apache.axiom.om.OMNamespace) StringOMDataSource(org.apache.axiom.om.ds.StringOMDataSource) OMSourcedElement(org.apache.axiom.om.OMSourcedElement)

Example 34 with OMSourcedElement

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);
}
Also used : CustomBuilderSupport(org.apache.axiom.om.ds.custombuilder.CustomBuilderSupport) OMElement(org.apache.axiom.om.OMElement) SOAPModelBuilder(org.apache.axiom.soap.SOAPModelBuilder) BlobOMDataSourceCustomBuilder(org.apache.axiom.om.ds.custombuilder.BlobOMDataSourceCustomBuilder) OMSourcedElement(org.apache.axiom.om.OMSourcedElement)

Example 35 with 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());
}
Also used : SOAPBody(org.apache.axiom.soap.SOAPBody) OMNamespace(org.apache.axiom.om.OMNamespace) OMDataSource(org.apache.axiom.om.OMDataSource) StringOMDataSource(org.apache.axiom.om.ds.StringOMDataSource) StringOMDataSource(org.apache.axiom.om.ds.StringOMDataSource) SOAPHeaderBlock(org.apache.axiom.soap.SOAPHeaderBlock) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) OMSourcedElement(org.apache.axiom.om.OMSourcedElement) SOAPHeader(org.apache.axiom.soap.SOAPHeader) SOAPFactory(org.apache.axiom.soap.SOAPFactory)

Aggregations

OMSourcedElement (org.apache.axiom.om.OMSourcedElement)44 OMFactory (org.apache.axiom.om.OMFactory)32 OMElement (org.apache.axiom.om.OMElement)16 PullOMDataSource (org.apache.axiom.ts.om.sourcedelement.util.PullOMDataSource)14 QName (javax.xml.namespace.QName)13 StringOMDataSource (org.apache.axiom.om.ds.StringOMDataSource)11 OMNamespace (org.apache.axiom.om.OMNamespace)9 OMDataSource (org.apache.axiom.om.OMDataSource)8 OMNode (org.apache.axiom.om.OMNode)7 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)7 JAXBContext (javax.xml.bind.JAXBContext)6 JAXBOMDataSource (org.apache.axiom.om.ds.jaxb.JAXBOMDataSource)6 XMLStreamReader (javax.xml.stream.XMLStreamReader)5 StringReader (java.io.StringReader)4 OMAttribute (org.apache.axiom.om.OMAttribute)4 DocumentBean (org.apache.axiom.ts.jaxb.beans.DocumentBean)4 DataSource (javax.activation.DataSource)3 XMLStreamException (javax.xml.stream.XMLStreamException)3 BlobOMDataSource (org.apache.axiom.om.ds.BlobOMDataSource)3 WrappedTextNodeOMDataSourceFromDataSource (org.apache.axiom.om.ds.WrappedTextNodeOMDataSourceFromDataSource)3