use of org.apache.axiom.testutils.net.protocol.mem.DataSourceRegistration 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.net.protocol.mem.DataSourceRegistration 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();
}
}
use of org.apache.axiom.testutils.net.protocol.mem.DataSourceRegistration in project webservices-axiom by apache.
the class DataSourceRegistryTest method test.
public void test() throws Exception {
RandomDataSource ds = new RandomDataSource(1000);
DataSourceRegistration registration = DataSourceRegistry.registerDataSource(ds);
try {
// We must be able to connect to the URL after converting it to a String
URL url = new URL(registration.getURL().toString());
URLConnection connection = url.openConnection();
IOTestUtils.compareStreams(connection.getInputStream(), "actual", ds.getInputStream(), "expected");
} finally {
registration.unregister();
}
}
Aggregations