use of org.apache.axiom.om.OMFactory in project webservices-axiom by apache.
the class TestGetDefaultNamespace method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMElement parent = factory.createOMElement("parent", "urn:ns1", "");
OMElement child = factory.createOMElement(new QName("urn:ns2", "child", "p"), parent);
OMNamespace ns = child.getDefaultNamespace();
assertNotNull(ns);
assertEquals("", ns.getPrefix());
assertEquals("urn:ns1", ns.getNamespaceURI());
}
use of org.apache.axiom.om.OMFactory in project webservices-axiom by apache.
the class TestGetNamespaceNormalized method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMElement parent = factory.createOMElement("parent", "urn:test", "");
OMNamespace ns = useNull ? null : factory.createOMNamespace("", "");
OMElement child = factory.createOMElement("child", ns);
parent.addChild(child);
assertNull(child.getNamespace());
}
use of org.apache.axiom.om.OMFactory in project webservices-axiom by apache.
the class TestGetTextWithCDATASectionChild method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMElement omElement = factory.createOMElement("TestElement", null);
final String text = "this is <some> text in a CDATA";
factory.createOMText(omElement, text, XMLStreamConstants.CDATA);
assertEquals(text, omElement.getText());
}
use of org.apache.axiom.om.OMFactory in project webservices-axiom by apache.
the class TestGetXMLStreamReaderCDATAEventFromElement method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory omfactory = metaFactory.getOMFactory();
OMElement element = omfactory.createOMElement("test", null);
OMText cdata = omfactory.createOMText("hello world", OMNode.CDATA_SECTION_NODE);
element.addChild(cdata);
// Get the XMLStreamReader for the element. This will return an OMStAXWrapper.
XMLStreamReader reader2 = element.getXMLStreamReader();
// Check the sequence of events
int event = reader2.next();
assertEquals(XMLStreamReader.START_ELEMENT, event);
while (reader2.hasNext() && event != XMLStreamReader.CDATA) {
event = reader2.next();
}
assertEquals(XMLStreamReader.CDATA, event);
// AXIOM-146
assertEquals("hello world", reader2.getText());
// AXIOM-144
assertTrue(Arrays.equals("hello world".toCharArray(), reader2.getTextCharacters()));
assertEquals(XMLStreamReader.END_ELEMENT, reader2.next());
}
use of org.apache.axiom.om.OMFactory in project webservices-axiom by apache.
the class TestGetTextAsQNameNoNamespace method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMElement omElement = factory.createOMElement("TestElement", null);
omElement.setText("value");
assertEquals(new QName("value"), omElement.getTextAsQName());
}
Aggregations