use of org.apache.axiom.om.OMFactory in project webservices-axiom by apache.
the class TestAddAttributeWithExistingNamespaceDeclarationInScope method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMElement root = factory.createOMElement(new QName("test"));
OMNamespace ns = factory.createOMNamespace("urn:ns", "p");
root.declareNamespace(ns);
OMElement child = factory.createOMElement(new QName("test"), root);
strategy.addAttribute(child, "test", ns, "test");
Iterator<OMNamespace> it = child.getAllDeclaredNamespaces();
assertFalse(it.hasNext());
}
use of org.apache.axiom.om.OMFactory in project webservices-axiom by apache.
the class TestAddChild 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);
assertSame(element, text.getParent());
assertSame(text, element.getFirstOMChild());
}
use of org.apache.axiom.om.OMFactory in project webservices-axiom by apache.
the class TestAddChild2 method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
String localName = "TestLocalName";
String childLocalName = "TestChildLocalName";
String namespace = "http://ws.apache.org/axis2/ns";
String prefix = "axis2";
OMElement elem = factory.createOMElement(localName, namespace, prefix);
OMElement childElem = factory.createOMElement(childLocalName, namespace, prefix);
elem.addChild(childElem);
Iterator<OMElement> it = elem.getChildrenWithName(new QName(namespace, childLocalName));
int count = 0;
while (it.hasNext()) {
OMElement child = it.next();
assertEquals("Child local name mismatch", childLocalName, child.getLocalName());
assertEquals("Child namespace mismatch", namespace, child.getNamespace().getNamespaceURI());
count++;
}
assertEquals("In correct number of children", 1, count);
}
use of org.apache.axiom.om.OMFactory in project webservices-axiom by apache.
the class TestGetChildElementsConcurrentModification method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMElement parent = factory.createOMElement("parent", null);
factory.createOMElement("child1", null, parent);
factory.createOMElement("child2", null, parent);
factory.createOMElement("child3", null, parent);
Iterator<OMElement> it = parent.getChildElements();
it.next();
OMElement child2 = it.next();
child2.detach();
try {
it.next();
fail("Expected ConcurrentModificationException");
} catch (ConcurrentModificationException ex) {
// Expected
}
}
use of org.apache.axiom.om.OMFactory in project webservices-axiom by apache.
the class TestAddChildDiscarded method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMElement parent = OMXMLBuilderFactory.createOMBuilder(factory, new StringReader("<root><a/><b/></root>")).getDocumentElement();
// Partially build the parent
parent.getFirstOMChild();
parent.discard();
try {
parent.addChild(factory.createOMElement("c", null));
fail("Expected NodeUnavailableException");
} catch (NodeUnavailableException ex) {
// Expected
}
}
Aggregations