Search in sources :

Example 6 with StringOMDataSource

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

Example 7 with StringOMDataSource

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

Example 8 with StringOMDataSource

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());
}
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 9 with StringOMDataSource

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());
}
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)

Example 10 with StringOMDataSource

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

Aggregations

StringOMDataSource (org.apache.axiom.om.ds.StringOMDataSource)11 OMSourcedElement (org.apache.axiom.om.OMSourcedElement)10 OMFactory (org.apache.axiom.om.OMFactory)8 OMNamespace (org.apache.axiom.om.OMNamespace)5 OMDataSource (org.apache.axiom.om.OMDataSource)4 OMElement (org.apache.axiom.om.OMElement)4 SOAPBody (org.apache.axiom.soap.SOAPBody)3 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)3 StringWriter (java.io.StringWriter)2 QName (javax.xml.namespace.QName)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 XMLStreamReader (javax.xml.stream.XMLStreamReader)1 OMAttribute (org.apache.axiom.om.OMAttribute)1 OMCloneOptions (org.apache.axiom.om.OMCloneOptions)1 OMDataSourceExt (org.apache.axiom.om.OMDataSourceExt)1 OMNode (org.apache.axiom.om.OMNode)1 OMXMLParserWrapper (org.apache.axiom.om.OMXMLParserWrapper)1 SOAPFactory (org.apache.axiom.soap.SOAPFactory)1 SOAPHeader (org.apache.axiom.soap.SOAPHeader)1 SOAPHeaderBlock (org.apache.axiom.soap.SOAPHeaderBlock)1