use of org.apache.axiom.om.OMNamespace in project webservices-axiom by apache.
the class TestDeclareDefaultNamespaceConflict2 method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMNamespace ns = factory.createOMNamespace("urn:ns1", "");
OMElement element = factory.createOMElement("test", ns);
try {
element.declareDefaultNamespace("urn:ns2");
fail("Expected OMException");
} catch (OMException ex) {
// Expected
}
}
use of org.apache.axiom.om.OMNamespace in project webservices-axiom by apache.
the class TestGetFirstChildWithName method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMNamespace ns1 = factory.createOMNamespace("urn:ns1", "ns1");
OMNamespace ns2 = factory.createOMNamespace("urn:ns2", "ns2");
OMElement parent = factory.createOMElement("root", null);
OMElement child1 = factory.createOMElement("a", ns1, parent);
factory.createOMComment(parent, "some comment");
OMElement child2 = factory.createOMElement("b", ns2, parent);
OMElement child3 = factory.createOMElement("b", ns1, parent);
OMElement child4 = factory.createOMElement("c", null, parent);
factory.createOMElement("a", ns1, parent);
// Check that it's really the first element that is returned
assertSame(child1, parent.getFirstChildWithName(new QName("urn:ns1", "a")));
// Test with a child that is not the first one
assertSame(child2, parent.getFirstChildWithName(new QName("urn:ns2", "b")));
// Check that the namespace URI is taken into account
assertNull(parent.getFirstChildWithName(new QName("b")));
// Check that the prefix of the given QName is not taken into account
assertSame(child3, parent.getFirstChildWithName(new QName("urn:ns1", "b", "ns2")));
// Test with null namespace
assertSame(child4, parent.getFirstChildWithName(new QName("c")));
}
use of org.apache.axiom.om.OMNamespace in project webservices-axiom by apache.
the class TestGetDefaultNamespace2 method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMElement parent = factory.createOMElement("parent", "urn:test", "");
OMElement child = factory.createOMElement("child", null, parent);
OMNamespace ns = child.getDefaultNamespace();
assertNull(ns);
}
use of org.apache.axiom.om.OMNamespace in project webservices-axiom by apache.
the class TestGetAllDeclaredNamespaces method runTest.
@Override
protected void runTest() throws Throwable {
OMElement element = AXIOMUtil.stringToOM(metaFactory.getOMFactory(), "<e xmlns:p='urn:test' p:attr='test'/>");
Iterator<OMNamespace> it = element.getAllDeclaredNamespaces();
assertTrue(it.hasNext());
OMNamespace ns = it.next();
assertEquals("p", ns.getPrefix());
assertEquals("urn:test", ns.getNamespaceURI());
assertFalse(it.hasNext());
}
use of org.apache.axiom.om.OMNamespace in project webservices-axiom by apache.
the class TestGetAllDeclaredNamespacesNoSuchElementException method runTest.
@Override
protected void runTest() throws Throwable {
OMElement element = AXIOMUtil.stringToOM(metaFactory.getOMFactory(), "<e xmlns:p='urn:test' p:attr='test'/>");
Iterator<OMNamespace> it = element.getAllDeclaredNamespaces();
it.next();
try {
it.next();
fail("Expected NoSuchElementException");
} catch (NoSuchElementException ex) {
// Expected
}
}
Aggregations