Search in sources :

Example 11 with StringOMDataSource

use of org.apache.axiom.om.ds.StringOMDataSource in project webservices-axiom by apache.

the class TestRemoveChildrenUnexpanded method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMSourcedElement element = factory.createOMElement(new StringOMDataSource("<element attr='value'><a/></element>"));
    element.removeChildren();
    // Check that the attribute has been added
    Iterator<OMAttribute> it = element.getAllAttributes();
    assertTrue(it.hasNext());
    OMAttribute attr = it.next();
    assertEquals("attr", attr.getLocalName());
    assertEquals("value", attr.getAttributeValue());
    assertFalse(it.hasNext());
    // Check that the element is empty
    assertNull(element.getFirstOMChild());
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) StringOMDataSource(org.apache.axiom.om.ds.StringOMDataSource) OMSourcedElement(org.apache.axiom.om.OMSourcedElement) OMAttribute(org.apache.axiom.om.OMAttribute)

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