use of org.apache.axiom.om.OMDocument in project webservices-axiom by apache.
the class TestSetOMDocumentElementNew method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMDocument document = factory.createOMDocument();
OMComment comment = factory.createOMComment(document, "some comment");
OMElement documentElement = factory.createOMElement("root", null);
document.setOMDocumentElement(documentElement);
assertSame(documentElement, document.getOMDocumentElement());
assertSame(document, documentElement.getParent());
Iterator<OMNode> it = document.getChildren();
assertTrue(it.hasNext());
assertSame(comment, it.next());
assertTrue(it.hasNext());
assertSame(documentElement, it.next());
assertFalse(it.hasNext());
}
use of org.apache.axiom.om.OMDocument in project webservices-axiom by apache.
the class TestSetOMDocumentElementReplace method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMDocument document = OMXMLBuilderFactory.createOMBuilder(factory, new StringReader("<!--comment1--><root/><!--comment2-->")).getDocument();
OMElement documentElement = factory.createOMElement("new", null);
document.setOMDocumentElement(documentElement);
assertSame(documentElement, document.getOMDocumentElement());
Iterator<OMNode> it = document.getChildren();
assertTrue(it.hasNext());
OMNode child = it.next();
assertTrue(child instanceof OMComment);
assertEquals("comment1", ((OMComment) child).getValue());
assertTrue(it.hasNext());
assertSame(documentElement, it.next());
assertTrue(it.hasNext());
child = it.next();
assertTrue(child instanceof OMComment);
assertEquals("comment2", ((OMComment) child).getValue());
assertFalse(it.hasNext());
}
use of org.apache.axiom.om.OMDocument in project webservices-axiom by apache.
the class TestDTDReaderFromParser method runTest.
@Override
protected void runTest() throws Throwable {
OMDocument doc = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(), StAXParserConfiguration.STANDALONE, TestDTDReaderFromParser.class.getResourceAsStream("/web_w_dtd.xml")).getDocument();
if (build) {
doc.build();
}
XMLStreamReader reader = doc.getXMLStreamReader(cache);
// Note that according to the specification of the DTDReader interface, it is
// allowed to look up the extension before reaching the DTD event.
DTDReader dtdReader = (DTDReader) reader.getProperty(DTDReader.PROPERTY);
assertNotNull(dtdReader);
while (reader.next() != XMLStreamReader.DTD) {
// Just loop
}
assertEquals("web-app", dtdReader.getRootName());
assertEquals("-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN", dtdReader.getPublicId());
assertEquals("http://java.sun.com/dtd/web-app_2_3.dtd", dtdReader.getSystemId());
}
use of org.apache.axiom.om.OMDocument in project webservices-axiom by apache.
the class TestAddChildIncomplete method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMDocument parent = OMXMLBuilderFactory.createOMBuilder(factory, new StringReader("<!--a--><b/><!--c-->")).getDocument();
parent.addChild(factory.createOMComment(null, "d"));
Iterator<OMNode> it = parent.getChildren();
assertEquals("a", ((OMComment) it.next()).getValue());
assertEquals("b", ((OMElement) it.next()).getLocalName());
assertEquals("c", ((OMComment) it.next()).getValue());
assertEquals("d", ((OMComment) it.next()).getValue());
assertFalse(it.hasNext());
}
use of org.apache.axiom.om.OMDocument in project webservices-axiom by apache.
the class TestGetOMDocumentElement method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMDocument document = factory.createOMDocument();
OMElement documentElement = factory.createOMElement("root", null, document);
assertSame(documentElement, document.getOMDocumentElement());
}
Aggregations