Search in sources :

Example 46 with OMText

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

the class TestCreateOMText method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMNamespace namespace = factory.createOMNamespace("http://www.apache.org/~chinthaka", "myhome");
    OMElement omElement = factory.createOMElement("chinthaka", namespace);
    String text = "sampleText";
    OMText omText = factory.createOMText(omElement, text);
    assertTrue("Programatically created OMText should have done = true ", omText.isComplete());
    assertTrue("Programatically created OMText should have correct text value ", text.equals(omText.getText()));
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) OMNamespace(org.apache.axiom.om.OMNamespace) OMText(org.apache.axiom.om.OMText) OMElement(org.apache.axiom.om.OMElement)

Example 47 with OMText

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

the class TestCreateOMTextFromDataHandlerProvider method runTest.

@Override
protected void runTest() throws Throwable {
    TestDataHandlerProvider prov = new TestDataHandlerProvider();
    OMFactory factory = metaFactory.getOMFactory();
    String contentID = nullContentID ? null : UIDGenerator.generateContentId();
    OMText text = factory.createOMText(contentID, prov, true);
    assertFalse(prov.isDataHandlerCreated());
    assertEquals(text.getDataHandler().getContent(), "Data");
    assertTrue(prov.isDataHandlerCreated());
    if (contentID == null) {
        assertThat(text.getContentID()).isNotNull();
    } else {
        assertThat(text.getContentID()).isEqualTo(contentID);
    }
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) OMText(org.apache.axiom.om.OMText)

Example 48 with OMText

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

the class TestCreateOMTextFromOMText method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMText orgText = factory.createOMText("text");
    OMElement parent = factory.createOMElement("test", null);
    OMText text = factory.createOMText(parent, orgText);
    assertEquals("text", text.getText());
    assertSame(parent, text.getParent());
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) OMText(org.apache.axiom.om.OMText) OMElement(org.apache.axiom.om.OMElement)

Example 49 with OMText

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

the class TestCreateOMTextWithNullParent method runTest.

@Override
protected void runTest() throws Throwable {
    OMText text = metaFactory.getOMFactory().createOMText(null, "text");
    assertNull(text.getParent());
}
Also used : OMText(org.apache.axiom.om.OMText)

Example 50 with OMText

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

the class TestInsertSiblingAfterOnSelf method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMElement parent = factory.createOMElement("test", null);
    OMText text = factory.createOMText("test");
    parent.addChild(text);
    try {
        text.insertSiblingAfter(text);
        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