use of org.apache.axiom.om.OMFactory in project webservices-axiom by apache.
the class TestAddChildWithParent method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMElement element1 = factory.createOMElement("test1", null);
OMElement element2 = factory.createOMElement("test2", null);
OMText text = factory.createOMText("test");
element1.addChild(text);
element2.addChild(text);
assertSame(element2, text.getParent());
assertNull(element1.getFirstOMChild());
assertSame(text, element2.getFirstOMChild());
}
use of org.apache.axiom.om.OMFactory in project webservices-axiom by apache.
the class TestChildReDeclaringGrandParentsDefaultNSWithPrefix method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory fac = metaFactory.getOMFactory();
OMElement elem = fac.createOMElement("RequestSecurityToken", fac.createOMNamespace("http://schemas.xmlsoap.org/ws/2005/02/trust", ""));
fac.createOMElement(new QName("TokenType"), elem).setText("test");
fac.createOMElement(new QName("RequestType"), elem).setText("test1");
OMElement entElem = fac.createOMElement(new QName("http://schemas.xmlsoap.org/ws/2005/02/trust", "Entropy", "wst"), elem);
OMElement binSecElem = fac.createOMElement(new QName("http://schemas.xmlsoap.org/ws/2005/02/trust", "Binarysecret", "wst"), entElem);
binSecElem.setText("secret value");
String xml = elem.toString();
assertTrue("Binarysecret element should have \'wst\' ns prefix", xml.indexOf("<wst:Binarysecret") != -1);
}
use of org.apache.axiom.om.OMFactory in project webservices-axiom by apache.
the class TestFindNamespaceURIWithPrefixUndeclaring method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMElement parent = factory.createOMElement("parent", null);
OMElement child = factory.createOMElement("child", null, parent);
OMNamespace ns = parent.declareNamespace("urn:test", "p");
child.undeclarePrefix("p");
assertEquals(ns, parent.findNamespaceURI("p"));
assertNull(child.findNamespaceURI("p"));
}
use of org.apache.axiom.om.OMFactory in project webservices-axiom by apache.
the class TestGetAttributeValueNonExisting method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMElement element = factory.createOMElement("test", null);
element.addAttribute("attr", "value", null);
assertNull(element.getAttributeValue(new QName("urn:ns", "attr2")));
}
use of org.apache.axiom.om.OMFactory in project webservices-axiom by apache.
the class TestDeclareNamespaceWithEmptyPrefix method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMElement element = factory.createOMElement(new QName("test"));
OMNamespace ns = element.declareNamespace("urn:ns", "");
assertThat(ns.getNamespaceURI()).isEqualTo("urn:ns");
assertThat(ns.getPrefix()).isEmpty();
Iterator<OMNamespace> it = element.getAllDeclaredNamespaces();
assertThat(it.hasNext()).isTrue();
OMNamespace ns2 = it.next();
assertThat(ns2).isEqualTo(ns);
assertThat(it.hasNext()).isFalse();
}
Aggregations