use of org.apache.axiom.om.OMElement in project webservices-axiom by apache.
the class TestClose method runTest.
@Override
protected void runTest() throws Throwable {
OMElement rootElement = XMLSample.SIMPLE.getAdapter(XMLSampleAdapter.class).getDocumentElement(metaFactory);
// get the first OMElement child
OMNode omnode = rootElement.getFirstOMChild();
while (!(omnode instanceof OMElement)) {
omnode = omnode.getNextOMSibling();
}
// Close the element after building the element
OMElement omElement = (OMElement) omnode;
omElement.close(true);
Iterator<OMNode> children = ((OMElement) omnode).getChildren();
int childrenCount = 0;
while (children.hasNext()) {
if (children.next() instanceof OMElement) {
childrenCount++;
}
}
assertThat(childrenCount).isEqualTo(2);
}
use of org.apache.axiom.om.OMElement in project webservices-axiom by apache.
the class TestDeclareDefaultNamespaceConflict1 method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMElement element = factory.createOMElement("test", null);
try {
element.declareDefaultNamespace("urn:test");
fail("Expected OMException");
} catch (OMException ex) {
// Expected
}
}
use of org.apache.axiom.om.OMElement in project webservices-axiom by apache.
the class TestDeclareNamespace1 method runTest.
@Override
protected void runTest() throws Throwable {
OMElement element = metaFactory.getOMFactory().createOMElement(new QName("test"));
OMNamespace ns = element.declareNamespace("urn:ns1", "ns1");
assertEquals("urn:ns1", ns.getNamespaceURI());
assertEquals("ns1", ns.getPrefix());
Iterator<OMNamespace> it = element.getAllDeclaredNamespaces();
assertTrue(it.hasNext());
OMNamespace ns2 = it.next();
assertEquals(ns, ns2);
assertFalse(it.hasNext());
}
use of org.apache.axiom.om.OMElement in project webservices-axiom by apache.
the class TestDeclareNamespaceInvalid1 method runTest.
@Override
protected void runTest() throws Throwable {
OMElement element = metaFactory.getOMFactory().createOMElement(new QName("test"));
try {
element.declareNamespace("", "ns");
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException ex) {
// Expected
}
}
use of org.apache.axiom.om.OMElement in project webservices-axiom by apache.
the class TestSetOMDocumentElementReplaceSame method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMDocument document = factory.createOMDocument();
OMElement root = factory.createOMElement("root", null, document);
document.setOMDocumentElement(root);
assertThat(document.getOMDocumentElement()).isSameAs(root);
assertThat(root.getPreviousOMSibling()).isNull();
assertThat(root.getNextOMSibling()).isNull();
assertThat(root.getParent()).isSameAs(document);
}
Aggregations