use of org.apache.axiom.om.OMNode in project webservices-axiom by apache.
the class TestCloseOnComplete method runTest.
@Override
protected void runTest() throws Throwable {
PullOMDataSource ds = new PullOMDataSource("<root><a/></root>");
OMSourcedElement element = metaFactory.getOMFactory().createOMElement(ds);
OMNode child = element.getFirstOMChild();
assertFalse(element.isComplete());
assertTrue(ds.hasUnclosedReaders());
child.getNextOMSibling();
assertTrue(element.isComplete());
assertFalse(ds.hasUnclosedReaders());
}
use of org.apache.axiom.om.OMNode in project webservices-axiom by apache.
the class TestExpand method runTest.
@Override
protected void runTest() throws Throwable {
OMSourcedElement element = TestDocument.DOCUMENT1.createOMSourcedElement(metaFactory.getOMFactory(), false, true);
element.getAllDeclaredNamespaces();
assertEquals("Expanded namespace count error", 1, countItems(element.getAllDeclaredNamespaces()));
assertEquals("Expanded attribute count error", 1, countItems(element.getAllAttributes()));
assertEquals("Expanded attribute value error", "1", element.getAttributeValue(new QName("books")));
OMElement child = element.getFirstElement();
assertEquals("Child element name", "type", child.getLocalName());
assertEquals("Child element namespace", "http://www.sosnoski.com/uwjws/library", child.getNamespace().getNamespaceURI());
OMNode next = child.getNextOMSibling();
assertTrue("Expected child element", next instanceof OMElement);
next = next.getNextOMSibling();
assertTrue("Expected child element", next instanceof OMElement);
child = (OMElement) next;
assertEquals("Child element name", "book", child.getLocalName());
assertEquals("Child element namespace", "http://www.sosnoski.com/uwjws/library", child.getNamespace().getNamespaceURI());
assertEquals("Attribute value error", "xml", child.getAttributeValue(new QName("type")));
}
use of org.apache.axiom.om.OMNode in project webservices-axiom by apache.
the class TestDetach method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMContainer root;
if (document) {
root = OMXMLBuilderFactory.createOMBuilder(factory, new StringReader("<!--a--><b/><!--c-->")).getDocument();
} else {
root = OMXMLBuilderFactory.createOMBuilder(factory, new StringReader("<root><!--a--><b/><!--c--></root>")).getDocumentElement();
}
if (build) {
root.build();
} else {
assertFalse(root.isComplete());
}
OMComment a = (OMComment) root.getFirstOMChild();
assertEquals("a", a.getValue());
OMElement b = (OMElement) a.getNextOMSibling();
assertEquals("b", b.getLocalName());
OMNode returnValue = b.detach();
// Detach is expected to do a "return this"
assertSame(b, returnValue);
assertNull(b.getParent());
assertNull(b.getPreviousOMSibling());
assertNull(b.getNextOMSibling());
OMComment c = (OMComment) a.getNextOMSibling();
assertEquals("c", c.getValue());
assertSame(c, a.getNextOMSibling());
assertSame(a, c.getPreviousOMSibling());
root.close(false);
}
use of org.apache.axiom.om.OMNode in project webservices-axiom by apache.
the class TestAddSOAPTextMultiple method runTest.
@Override
protected void runTest() throws Throwable {
SOAPFaultReason reason = soapFactory.createSOAPFaultReason();
SOAPFaultText text1 = soapFactory.createSOAPFaultText();
text1.setLang("en");
text1.setText("System error");
reason.addSOAPText(text1);
SOAPFaultText text2 = soapFactory.createSOAPFaultText();
text2.setLang("de");
text2.setText("Systemfehler");
reason.addSOAPText(text2);
OMNode child = reason.getFirstOMChild();
assertThat(child).isSameAs(text1);
child = child.getNextOMSibling();
assertThat(child).isSameAs(text2);
}
use of org.apache.axiom.om.OMNode in project webservices-axiom by apache.
the class TestStandaloneConfiguration method runTest.
@Override
protected void runTest() throws Throwable {
InputStream is = TestStandaloneConfiguration.class.getResourceAsStream("web_w_dtd2.xml");
OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(), StAXParserConfiguration.STANDALONE, is);
OMElement root = builder.getDocumentElement();
assertTrue(root.getLocalName().equals("web-app"));
OMDocument document = builder.getDocument();
Iterator<OMNode> i = document.getChildren();
OMDocType docType = null;
while (docType == null && i.hasNext()) {
OMNode obj = i.next();
if (obj instanceof OMDocType) {
docType = (OMDocType) obj;
}
}
assertTrue(docType != null);
root.close(false);
}
Aggregations