use of org.apache.axiom.om.OMElement in project webservices-axiom by apache.
the class TestSetValueOnNamespaceDeclaration method runTest.
@Override
protected void runTest() throws Throwable {
Document doc = ((DOMMetaFactory) metaFactory).newDocumentBuilderFactory().newDocumentBuilder().newDocument();
Element element = doc.createElementNS("", "test");
Attr attr = doc.createAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns:attr");
element.setAttributeNodeNS(attr);
attr.setValue("urn:test");
Iterator<OMNamespace> it = ((OMElement) element).getAllDeclaredNamespaces();
assertThat(it.hasNext()).isTrue();
OMNamespace ns = it.next();
assertThat(ns.getNamespaceURI()).isEqualTo("urn:test");
assertThat(it.hasNext()).isFalse();
}
use of org.apache.axiom.om.OMElement in project webservices-axiom by apache.
the class TestGetNamespaceNoNamespace method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMElement element = factory.createOMElement("TestElement", null);
OMText text = factory.createOMText(element, "value");
assertNull(text.getNamespace());
}
use of org.apache.axiom.om.OMElement in project webservices-axiom by apache.
the class TestInsertSiblingAfterFromForeignDocument method runTest.
@Override
protected void runTest() throws Throwable {
DocumentBuilder db = ((DOMMetaFactory) metaFactory).newDocumentBuilderFactory().newDocumentBuilder();
Document document1 = db.newDocument();
Element element1 = document1.createElementNS(null, "element1");
Text text = document1.createTextNode("test");
element1.appendChild(text);
Document document2 = db.newDocument();
Element element2 = document2.createElementNS(null, "element2");
((OMNode) text).insertSiblingAfter((OMElement) element2);
// Assert that the new child is not a copy, but the original element
assertSame(element2, element1.getLastChild());
// Assert that the owner document of element2 was changed
assertSame(document1, element2.getOwnerDocument());
}
use of org.apache.axiom.om.OMElement in project webservices-axiom by apache.
the class WriteEmptyElementScenario method validate.
@Override
public void validate(OMElement element, boolean dataHandlersPreserved) throws Throwable {
OMElement child = element.getFirstElement();
Assert.assertEquals("p", child.getPrefix());
Assert.assertEquals("urn:test", child.getNamespaceURI());
Assert.assertEquals("child", child.getLocalName());
}
use of org.apache.axiom.om.OMElement in project webservices-axiom by apache.
the class TestRemoveAttributeNSNamespaceDeclaration method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMElement element = factory.createOMElement("test", null);
element.declareNamespace("urn:test", "ns");
((Element) element).removeAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "ns");
assertFalse(element.getAllDeclaredNamespaces().hasNext());
}
Aggregations