use of org.apache.axiom.om.OMDocument in project webservices-axiom by apache.
the class TestMalformedDocument method runTest.
@Override
protected void runTest() throws Throwable {
OMDocument document = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(), new StringReader("<Root><Child attr='a' attr='a'/></Root>")).getDocument();
try {
document.serialize(new ByteArrayOutputStream());
fail("Expected exception");
} catch (Exception ex) {
// We expect an exception here
}
document.close(false);
}
use of org.apache.axiom.om.OMDocument in project webservices-axiom by apache.
the class TestAddChildWithExistingDocumentElement method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMDocument document = factory.createOMDocument();
document.addChild(factory.createOMElement(new QName("root1")));
try {
document.addChild(factory.createOMElement(new QName("root2")));
fail("Expected OMException");
} catch (OMException ex) {
// Expected
}
}
use of org.apache.axiom.om.OMDocument in project webservices-axiom by apache.
the class TestBuild method runTest.
@Override
protected void runTest() throws Throwable {
InstrumentedInputStream in = new InstrumentedInputStream(XMLSample.LARGE.getInputStream());
OMDocument doc = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(), in).getDocument();
assertFalse(doc.isComplete());
long countBeforeBuild = in.getCount();
doc.build();
assertTrue(doc.isComplete());
long countAfterBuild = in.getCount();
assertTrue(countAfterBuild > countBeforeBuild);
OMNode node = doc.getFirstOMChild();
while (node != null) {
node = node.getNextOMSibling();
}
assertEquals(countAfterBuild, in.getCount());
}
use of org.apache.axiom.om.OMDocument in project webservices-axiom by apache.
the class TestDigest method createInformationItem.
@Override
protected OMInformationItem createInformationItem() throws Exception {
InputStream in = TestDigest.class.getResourceAsStream(file);
try {
OMDocument document = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(), in).getDocument();
document.build();
return document;
} finally {
in.close();
}
}
use of org.apache.axiom.om.OMDocument in project webservices-axiom by apache.
the class TestClone method runTest.
@Override
protected void runTest() throws Throwable {
OMDocument original = file.getAdapter(XMLSampleAdapter.class).getDocument(metaFactory);
OMDocument clone = (OMDocument) original.clone(new OMCloneOptions());
assertAbout(xml()).that(xml(OMDocument.class, clone)).hasSameContentAs(xml(OMDocument.class, original));
}
Aggregations