use of org.apache.axiom.om.OMNamespace in project webservices-axiom by apache.
the class TestCreateOMElementWithNamespaceInScope2 method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMElement parent = factory.createOMElement("parent", "urn:test", "p1");
OMElement child = variant.createOMElement(factory, parent, "child", "urn:test", "p2");
OMNamespace ns = factory.createOMNamespace("urn:test", "p2");
assertEquals(ns, child.getNamespace());
Iterator<OMNamespace> it = child.getAllDeclaredNamespaces();
assertTrue(it.hasNext());
}
use of org.apache.axiom.om.OMNamespace in project webservices-axiom by apache.
the class TestSerialization method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory fac = metaFactory.getOMFactory();
OMNamespace nsParent = createNamespace(fac, parent);
OMNamespace nsChildren = createNamespace(fac, children);
OMElement personElem = fac.createOMElement("person", nsParent);
OMElement nameElem = fac.createOMElement("name", nsChildren);
nameElem.setText("John");
OMElement ageElem = fac.createOMElement("age", nsChildren);
ageElem.setText("34");
OMElement weightElem = fac.createOMElement("weight", nsChildren);
weightElem.setText("50");
//Add children to the person element
personElem.addChild(nameElem);
personElem.addChild(ageElem);
personElem.addChild(weightElem);
assertEquals(expected, personElem.toString());
}
use of org.apache.axiom.om.OMNamespace in project webservices-axiom by apache.
the class TestCreateOMAttributeWithInvalidNamespace2 method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMNamespace ns = factory.createOMNamespace("urn:test", "");
try {
factory.createOMAttribute("attr", ns, "value");
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException ex) {
assertEquals("Cannot create an unprefixed attribute with a namespace", ex.getMessage());
}
}
use of org.apache.axiom.om.OMNamespace in project webservices-axiom by apache.
the class TestCreateOMElementWithNonDefaultNamespace method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMElement element = variant.createOMElement(factory, parentSupplier.createParent(factory), "test", "urn:ns", "ns");
assertTrue(element.isComplete());
assertEquals("test", element.getLocalName());
OMNamespace ns = factory.createOMNamespace("urn:ns", "ns");
assertEquals(ns, element.getNamespace());
Iterator<OMNamespace> it = element.getAllDeclaredNamespaces();
assertTrue(it.hasNext());
assertEquals(ns, it.next());
assertFalse(it.hasNext());
}
use of org.apache.axiom.om.OMNamespace in project webservices-axiom by apache.
the class TestCreateOMElementWithoutNamespaceNullPrefix method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMElement element = variant.createOMElement(factory, parentSupplier.createParent(factory), "test", "", null);
assertEquals("test", element.getLocalName());
assertNull(element.getNamespace());
Iterator<OMNamespace> it = element.getAllDeclaredNamespaces();
assertFalse(it.hasNext());
}
Aggregations