use of org.apache.axiom.om.OMFactory in project webservices-axiom by apache.
the class TestGetNamespaceURI method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMNamespace ns = factory.createOMNamespace("http://www.w3.org/XML/1998/namespace", "xml");
assertEquals("http://www.w3.org/XML/1998/namespace", ns.getNamespaceURI());
}
use of org.apache.axiom.om.OMFactory in project webservices-axiom by apache.
the class TestGetPrefix method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMNamespace ns = factory.createOMNamespace("http://www.w3.org/XML/1998/namespace", "xml");
assertEquals("xml", ns.getPrefix());
ns = factory.createOMNamespace("", null);
assertNull(ns.getPrefix());
}
use of org.apache.axiom.om.OMFactory in project webservices-axiom by apache.
the class TestCloneOMElementNamespaceRepairing method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
// Create a root element on which we declare the namespaces
OMElement root = factory.createOMElement("root", null);
OMNamespace ns1 = root.declareNamespace("urn:ns1", "ns1");
OMNamespace ns2 = root.declareNamespace("urn:ns2", "ns2");
root.declareNamespace("urn:ns3", "ns3");
// Create a child that uses these namespaces (in the element name and in the name of an attribute)
OMElement child = factory.createOMElement("child", ns1, root);
child.addAttribute("attr", "value", ns2);
// Check that the child has no namespace declarations (to validate the correctness of the test)
assertFalse(child.getAllDeclaredNamespaces().hasNext());
// Clone the child and check that namespace declarations have been generated automatically
OMElement clone = child.cloneOMElement();
Set<OMNamespace> expectedNSDecls = new HashSet<>();
expectedNSDecls.add(ns1);
expectedNSDecls.add(ns2);
Set<OMNamespace> actualNSDecls = new HashSet<>();
for (Iterator<OMNamespace> it = clone.getAllDeclaredNamespaces(); it.hasNext(); ) {
actualNSDecls.add(it.next());
}
assertEquals(expectedNSDecls, actualNSDecls);
}
use of org.apache.axiom.om.OMFactory 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.OMFactory 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