Search in sources :

Example 26 with OMText

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

the class TestInsertSiblingAfter method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory fac = metaFactory.getOMFactory();
    OMElement parent = fac.createOMElement("test", null);
    OMText text1 = fac.createOMText("text1");
    OMText text2 = fac.createOMText("text2");
    parent.addChild(text1);
    text1.insertSiblingAfter(text2);
    assertSame(parent, text2.getParent());
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) OMText(org.apache.axiom.om.OMText) OMElement(org.apache.axiom.om.OMElement)

Example 27 with OMText

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

the class TestInsertSiblingAfterOnChild method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMElement element = factory.createOMElement("test", null);
    OMText text = factory.createOMText("test");
    element.addChild(text);
    try {
        text.insertSiblingAfter(element);
        fail("Expected OMException");
    } catch (OMException ex) {
    // Expected
    }
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) OMText(org.apache.axiom.om.OMText) OMElement(org.apache.axiom.om.OMElement) OMException(org.apache.axiom.om.OMException)

Example 28 with OMText

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

the class TestInsertSiblingAfterOnOrphan method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory fac = metaFactory.getOMFactory();
    OMText text1 = fac.createOMText("text1");
    OMText text2 = fac.createOMText("text2");
    try {
        text1.insertSiblingBefore(text2);
        fail("Expected OMException because node has no parent");
    } catch (OMException ex) {
    // Expected
    }
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) OMText(org.apache.axiom.om.OMText) OMException(org.apache.axiom.om.OMException)

Example 29 with OMText

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

the class TestInsertSiblingAfterSameParent method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory fac = metaFactory.getOMFactory();
    OMElement parent = fac.createOMElement("test", null);
    OMText text1 = fac.createOMText("text1");
    OMText text2 = fac.createOMText("text2");
    OMText text3 = fac.createOMText("text3");
    parent.addChild(text1);
    parent.addChild(text2);
    parent.addChild(text3);
    text1.insertSiblingAfter(text3);
    assertSame(parent, text3.getParent());
    Iterator<OMNode> it = parent.getChildren();
    assertSame(text1, it.next());
    assertSame(text3, it.next());
    assertSame(text2, it.next());
    assertFalse(it.hasNext());
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) OMNode(org.apache.axiom.om.OMNode) OMText(org.apache.axiom.om.OMText) OMElement(org.apache.axiom.om.OMElement)

Example 30 with OMText

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

the class TestInsertSiblingBeforeOnChild method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMElement element = factory.createOMElement("test", null);
    OMText text = factory.createOMText("test");
    element.addChild(text);
    try {
        text.insertSiblingBefore(element);
        fail("Expected OMException");
    } catch (OMException ex) {
    // Expected
    }
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) OMText(org.apache.axiom.om.OMText) OMElement(org.apache.axiom.om.OMElement) OMException(org.apache.axiom.om.OMException)

Aggregations

OMText (org.apache.axiom.om.OMText)92 OMElement (org.apache.axiom.om.OMElement)62 OMFactory (org.apache.axiom.om.OMFactory)39 DataHandler (javax.activation.DataHandler)26 OMNode (org.apache.axiom.om.OMNode)21 OMNamespace (org.apache.axiom.om.OMNamespace)10 QName (javax.xml.namespace.QName)8 OMException (org.apache.axiom.om.OMException)8 IOException (java.io.IOException)7 Iterator (java.util.Iterator)7 InputStream (java.io.InputStream)6 OMAttribute (org.apache.axiom.om.OMAttribute)6 Entry (org.apache.synapse.config.Entry)6 ArrayList (java.util.ArrayList)5 DataSource (javax.activation.DataSource)5 ByteArrayDataSource (org.apache.axiom.attachments.ByteArrayDataSource)5 OMOutputFormat (org.apache.axiom.om.OMOutputFormat)5 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)5 OutputStream (java.io.OutputStream)4 StringReader (java.io.StringReader)4