Search in sources :

Example 1 with InstrumentedStream

use of org.apache.axiom.testutils.io.InstrumentedStream in project webservices-axiom by apache.

the class TestClose method runTest.

protected void runTest() throws Throwable {
    InstrumentedStream in = streamType.instrumentStream(streamType.getStream(XMLSample.SIMPLE));
    XMLStreamReader reader = streamType.createXMLStreamReader(staxImpl.newNormalizedXMLInputFactory(), in);
    reader.close();
    assertFalse(in.isClosed());
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) InstrumentedStream(org.apache.axiom.testutils.io.InstrumentedStream)

Example 2 with InstrumentedStream

use of org.apache.axiom.testutils.io.InstrumentedStream in project webservices-axiom by apache.

the class TestDetachWithStream method runTest.

@Override
protected final void runTest() throws Throwable {
    InstrumentedStream stream = streamType.instrumentStream(streamType.getStream(XMLSample.LARGE));
    OMXMLParserWrapper builder;
    if (useStreamSource) {
        builder = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(), streamType.createStreamSource(stream));
    } else {
        builder = streamType.getAdapter(StreamTypeAdapter.class).createOMBuilder(metaFactory.getOMFactory(), stream);
    }
    long countBeforeDetach = stream.getCount();
    builder.detach();
    assertThat(stream.getCount()).isGreaterThan(countBeforeDetach);
    assertThat(stream.isClosed()).isFalse();
    stream.close();
    builder.getDocument().build();
}
Also used : InstrumentedStream(org.apache.axiom.testutils.io.InstrumentedStream) OMXMLParserWrapper(org.apache.axiom.om.OMXMLParserWrapper)

Example 3 with InstrumentedStream

use of org.apache.axiom.testutils.io.InstrumentedStream in project webservices-axiom by apache.

the class TestCloseWithStream method runTest.

@Override
protected void runTest() throws Throwable {
    InstrumentedStream in = streamType.instrumentStream(streamType.getStream(XMLSample.SIMPLE));
    try {
        OMXMLParserWrapper builder = streamType.getAdapter(StreamTypeAdapter.class).createOMBuilder(metaFactory.getOMFactory(), in);
        builder.getDocument().build();
        builder.close();
        // OMXMLParserWrapper#close() does _not_ close the underlying input stream
        assertFalse(in.isClosed());
    } finally {
        in.close();
    }
}
Also used : StreamTypeAdapter(org.apache.axiom.ts.StreamTypeAdapter) InstrumentedStream(org.apache.axiom.testutils.io.InstrumentedStream) OMXMLParserWrapper(org.apache.axiom.om.OMXMLParserWrapper)

Aggregations

InstrumentedStream (org.apache.axiom.testutils.io.InstrumentedStream)3 OMXMLParserWrapper (org.apache.axiom.om.OMXMLParserWrapper)2 XMLStreamReader (javax.xml.stream.XMLStreamReader)1 StreamTypeAdapter (org.apache.axiom.ts.StreamTypeAdapter)1