use of org.apache.axiom.om.OMAttribute in project webservices-axiom by apache.
the class TestAddAttributeAlreadyOwnedByElement method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMElement element = factory.createOMElement(new QName("test"));
OMAttribute att = element.addAttribute("test", "test", null);
OMAttribute result = element.addAttribute(att);
assertSame(result, att);
assertSame(element, att.getOwner());
Iterator<OMAttribute> it = element.getAllAttributes();
assertTrue(it.hasNext());
assertSame(att, it.next());
assertFalse(it.hasNext());
}
use of org.apache.axiom.om.OMAttribute in project webservices-axiom by apache.
the class TestAddAttributeAlreadyOwnedByOtherElement method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMElement element1 = factory.createOMElement(new QName("test"));
OMElement element2 = factory.createOMElement(new QName("test"));
OMAttribute att1 = element1.addAttribute("test", "test", null);
OMAttribute att2 = element2.addAttribute(att1);
assertSame(element1, att1.getOwner());
assertNotSame(att1, att2);
assertSame(element2, att2.getOwner());
}
use of org.apache.axiom.om.OMAttribute in project webservices-axiom by apache.
the class TestGetAttributeWithXmlPrefix2 method runTest.
@Override
protected void runTest() throws Throwable {
OMElement elem = AXIOMUtil.stringToOM(metaFactory.getOMFactory(), "<Policy xml:base=\"uri:thisBase\"></Policy>");
OMAttribute attr = elem.getAttribute(new QName(XMLConstants.XML_NS_URI, "base"));
assertEquals("Attribute namespace mismatch", XMLConstants.XML_NS_URI, attr.getNamespace().getNamespaceURI());
}
use of org.apache.axiom.om.OMAttribute in project webservices-axiom by apache.
the class TestGetAllAttributes1 method runTest.
@Override
protected void runTest() throws Throwable {
OMElement element = metaFactory.getOMFactory().createOMElement("test", null);
element.addAttribute("attr1", "value1", null);
element.addAttribute("attr2", "value2", null);
Iterator<OMAttribute> it = element.getAllAttributes();
assertTrue(it.hasNext());
OMAttribute attr = it.next();
assertEquals("attr1", attr.getLocalName());
assertTrue(it.hasNext());
attr = it.next();
assertEquals("attr2", attr.getLocalName());
assertFalse(it.hasNext());
}
use of org.apache.axiom.om.OMAttribute in project webservices-axiom by apache.
the class TestGetAllAttributes method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMSourcedElement element = factory.createOMElement(new PullOMDataSource("<root attr='value'/>"), "root", null);
Iterator<OMAttribute> attributes = element.getAllAttributes();
assertThat(attributes.hasNext()).isTrue();
OMAttribute attr = attributes.next();
assertThat(attr.getLocalName()).isEqualTo("attr");
assertThat(attributes.hasNext()).isFalse();
}
Aggregations