use of org.apache.axiom.om.OMFactory in project webservices-axiom by apache.
the class TestAddChildWithIncompleteSibling method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMContainer container = containerFactory.create(factory);
container.addChild(OMXMLBuilderFactory.createOMBuilder(factory, new StringReader("<a>test</a>")).getDocumentElement(true));
assertThat(container.isComplete()).isFalse();
container.addChild(factory.createOMText("test"));
assertThat(container).hasNumberOfChildren(2);
}
use of org.apache.axiom.om.OMFactory in project webservices-axiom by apache.
the class TestCreateOMTextCDATASectionWithParent method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMElement parent = factory.createOMElement("test", null);
OMText text = factory.createOMText(parent, "cdata section content", OMNode.CDATA_SECTION_NODE);
assertTrue(text instanceof CDATASection);
}
use of org.apache.axiom.om.OMFactory in project webservices-axiom by apache.
the class TestGetDataHandlerFromElement method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
RandomDataSource orgDS = new RandomDataSource(64 * 1024);
OMElement orgRoot = factory.createOMElement(new QName("root"));
OMElement orgChild = factory.createOMElement(new QName("child"), orgRoot);
orgChild.addChild(factory.createOMText(new DataHandler(orgDS), false));
OMElement root = OMXMLBuilderFactory.createOMBuilder(factory, new StringReader(orgRoot.toString())).getDocumentElement();
XMLStreamReader reader = root.getXMLStreamReader(cache);
assertEquals(XMLStreamReader.START_ELEMENT, reader.next());
assertEquals(XMLStreamReader.START_ELEMENT, reader.next());
DataSource ds = XMLStreamReaderUtils.getDataHandlerFromElement(reader).getDataSource();
IOTestUtils.compareStreams(orgDS.getInputStream(), ds.getInputStream());
}
use of org.apache.axiom.om.OMFactory in project webservices-axiom by apache.
the class TestSetTextQName method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMElement element = factory.createOMElement("TestElement", null);
QName qname = new QName("urn:ns1", "test", "ns");
element.setText(qname);
boolean foundNamespace = false;
for (Iterator<OMNamespace> it = element.getAllDeclaredNamespaces(); it.hasNext(); ) {
OMNamespace ns = it.next();
if ("urn:ns1".equals(ns.getNamespaceURI()) && "ns".equals(ns.getPrefix())) {
foundNamespace = true;
}
}
assertTrue("Namespace of the text is not defined in the parent element", foundNamespace);
assertTrue(element.toString().contains("ns:test"));
assertEquals("ns:test", element.getText());
assertEquals(qname, element.getTextAsQName());
}
use of org.apache.axiom.om.OMFactory in project webservices-axiom by apache.
the class TestSetTextQNameWithEmptyPrefix method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMElement element = factory.createOMElement("test", null);
QName qname = new QName("urn:test", "test");
element.setText(qname);
Iterator<OMNamespace> it = element.getAllDeclaredNamespaces();
assertTrue(it.hasNext());
OMNamespace ns = it.next();
assertEquals("urn:test", ns.getNamespaceURI());
String prefix = ns.getPrefix();
assertTrue(prefix.length() > 0);
assertEquals(prefix + ":test", element.getText());
assertFalse(it.hasNext());
}
Aggregations