use of org.apache.axiom.testutils.activation.InstrumentedDataSource in project webservices-axiom by apache.
the class TestCloseWithSystemId method runTest.
@Override
protected void runTest() throws Throwable {
InstrumentedDataSource ds = new InstrumentedDataSource(new URLDataSource(XMLSample.SIMPLE.getUrl()));
DataSourceRegistration registration = DataSourceRegistry.registerDataSource(ds);
try {
OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(), new StreamSource(registration.getURL().toExternalForm()));
builder.getDocumentElement();
builder.close();
// Since the caller doesn't have control over the stream, the builder is responsible
// for closing it.
assertThat(ds.getOpenStreamCount()).isEqualTo(0);
} finally {
registration.unregister();
}
}
use of org.apache.axiom.testutils.activation.InstrumentedDataSource in project webservices-axiom by apache.
the class TestParseURI method runTest.
protected void runTest() throws Throwable {
InstrumentedDataSource ds = new InstrumentedDataSource(new URLDataSource(XMLSample.SIMPLE.getUrl()));
DataSourceRegistration registration = DataSourceRegistry.registerDataSource(ds);
try {
DocumentBuilder builder = dbf.newDocumentBuilder();
Document document = builder.parse(registration.getURL().toExternalForm());
assertThat(document.getDocumentElement().getLocalName()).isEqualTo("root");
assertThat(ds.getOpenStreamCount()).isEqualTo(0);
} finally {
registration.unregister();
}
}
Aggregations