Search in sources :

Example 11 with AsyncByteBufferFeeder

use of com.fasterxml.aalto.AsyncByteBufferFeeder in project aalto-xml by FasterXML.

the class TestCommentParsing method _testSkipComments.

private void _testSkipComments(final String spaces, final int chunkSize) throws Exception {
    final AsyncXMLInputFactory f = new InputFactoryImpl();
    // test for byte array
    AsyncXMLStreamReader<AsyncByteArrayFeeder> sr_array = null;
    try {
        sr_array = f.createAsyncForByteArray();
        final AsyncReaderWrapperForByteArray reader_array = new AsyncReaderWrapperForByteArray(sr_array, chunkSize, spaces + XML);
        _testSkipComments(sr_array, reader_array);
    } finally {
        if (sr_array != null) {
            sr_array.close();
        }
    }
    // test for byte buffer
    AsyncXMLStreamReader<AsyncByteBufferFeeder> sr_buffer = null;
    try {
        sr_buffer = f.createAsyncForByteBuffer();
        final AsyncReaderWrapperForByteBuffer reader_buffer = new AsyncReaderWrapperForByteBuffer(sr_buffer, chunkSize, spaces + XML);
        _testSkipComments(sr_buffer, reader_buffer);
    } finally {
        if (sr_buffer != null) {
            sr_buffer.close();
        }
    }
}
Also used : AsyncByteBufferFeeder(com.fasterxml.aalto.AsyncByteBufferFeeder) AsyncByteArrayFeeder(com.fasterxml.aalto.AsyncByteArrayFeeder) InputFactoryImpl(com.fasterxml.aalto.stax.InputFactoryImpl) AsyncXMLInputFactory(com.fasterxml.aalto.AsyncXMLInputFactory)

Example 12 with AsyncByteBufferFeeder

use of com.fasterxml.aalto.AsyncByteBufferFeeder in project aalto-xml by FasterXML.

the class TestElementParsing method testTrivial_buffer.

/**
 * Trivial test to verify basic operation with a full buffer.
 */
public void testTrivial_buffer() throws Exception {
    final AsyncXMLInputFactory f = new InputFactoryImpl();
    AsyncXMLStreamReader<AsyncByteBufferFeeder> sr = null;
    try {
        sr = f.createAsyncFor(ByteBuffer.wrap("<root>a</root>".getBytes("UTF-8")));
        assertTokenType(START_DOCUMENT, sr.next());
        assertTokenType(START_ELEMENT, sr.next());
        assertEquals("root", sr.getLocalName());
        assertTokenType(CHARACTERS, sr.next());
        assertEquals("a", sr.getText());
        assertTokenType(END_ELEMENT, sr.next());
        assertEquals("root", sr.getLocalName());
        // no input to see (could still get a PI, comment etc), so
        assertTokenType(AsyncXMLStreamReader.EVENT_INCOMPLETE, sr.next());
        sr.getInputFeeder().endOfInput();
        assertTokenType(END_DOCUMENT, sr.next());
    } finally {
        if (sr != null) {
            sr.close();
        }
    }
}
Also used : AsyncByteBufferFeeder(com.fasterxml.aalto.AsyncByteBufferFeeder) InputFactoryImpl(com.fasterxml.aalto.stax.InputFactoryImpl) AsyncXMLInputFactory(com.fasterxml.aalto.AsyncXMLInputFactory)

Example 13 with AsyncByteBufferFeeder

use of com.fasterxml.aalto.AsyncByteBufferFeeder in project aalto-xml by FasterXML.

the class TestPIParsing method _testPI.

private void _testPI(final String spaces, final int chunkSize) throws Exception {
    final AsyncXMLInputFactory f = new InputFactoryImpl();
    // test for byte array
    AsyncXMLStreamReader<AsyncByteArrayFeeder> sr_array = null;
    try {
        sr_array = f.createAsyncForByteArray();
        final AsyncReaderWrapperForByteArray reader_array = new AsyncReaderWrapperForByteArray(sr_array, chunkSize, spaces + XML);
        _testPI(sr_array, reader_array);
    } finally {
        if (sr_array != null) {
            sr_array.close();
        }
    }
    // test for byte buffer
    AsyncXMLStreamReader<AsyncByteBufferFeeder> sr_buffer = null;
    try {
        sr_buffer = f.createAsyncForByteBuffer();
        final AsyncReaderWrapperForByteBuffer reader_buffer = new AsyncReaderWrapperForByteBuffer(sr_buffer, chunkSize, spaces + XML);
        _testPI(sr_buffer, reader_buffer);
    } finally {
        if (sr_buffer != null) {
            sr_buffer.close();
        }
    }
}
Also used : AsyncByteBufferFeeder(com.fasterxml.aalto.AsyncByteBufferFeeder) AsyncByteArrayFeeder(com.fasterxml.aalto.AsyncByteArrayFeeder) InputFactoryImpl(com.fasterxml.aalto.stax.InputFactoryImpl) AsyncXMLInputFactory(com.fasterxml.aalto.AsyncXMLInputFactory)

Example 14 with AsyncByteBufferFeeder

use of com.fasterxml.aalto.AsyncByteBufferFeeder in project aalto-xml by FasterXML.

the class TestPIParsing method _testPISkip.

private void _testPISkip(final String spaces, final int chunkSize) throws Exception {
    final AsyncXMLInputFactory f = new InputFactoryImpl();
    // test for byte array
    AsyncXMLStreamReader<AsyncByteArrayFeeder> sr_array = null;
    try {
        sr_array = f.createAsyncForByteArray();
        final AsyncReaderWrapperForByteArray reader_array = new AsyncReaderWrapperForByteArray(sr_array, chunkSize, spaces + XML);
        _testPISkip(sr_array, reader_array);
    } finally {
        if (sr_array != null) {
            sr_array.close();
        }
    }
    // test for byte buffer
    AsyncXMLStreamReader<AsyncByteBufferFeeder> sr_buffer = null;
    try {
        sr_buffer = f.createAsyncForByteBuffer();
        final AsyncReaderWrapperForByteBuffer reader_buffer = new AsyncReaderWrapperForByteBuffer(sr_buffer, chunkSize, spaces + XML);
        _testPISkip(sr_buffer, reader_buffer);
    } finally {
        if (sr_buffer != null) {
            sr_buffer.close();
        }
    }
}
Also used : AsyncByteBufferFeeder(com.fasterxml.aalto.AsyncByteBufferFeeder) AsyncByteArrayFeeder(com.fasterxml.aalto.AsyncByteArrayFeeder) InputFactoryImpl(com.fasterxml.aalto.stax.InputFactoryImpl) AsyncXMLInputFactory(com.fasterxml.aalto.AsyncXMLInputFactory)

Example 15 with AsyncByteBufferFeeder

use of com.fasterxml.aalto.AsyncByteBufferFeeder in project aalto-xml by FasterXML.

the class TestXmlDeclaration method testNoDeclaration.

public void testNoDeclaration() throws Exception {
    final AsyncXMLInputFactory f = new InputFactoryImpl();
    for (final String XML : new String[] { "   <root />", "<root/>" }) {
        for (final int chunkSize : CHUNK_SIZES) {
            // test for byte array
            AsyncXMLStreamReader<AsyncByteArrayFeeder> sr_array = null;
            try {
                sr_array = f.createAsyncForByteArray();
                final AsyncReaderWrapperForByteArray reader_array = new AsyncReaderWrapperForByteArray(sr_array, chunkSize, XML);
                _testNoDeclaration(sr_array, reader_array);
            } finally {
                if (sr_array != null) {
                    sr_array.close();
                }
            }
            // test for byte buffer
            AsyncXMLStreamReader<AsyncByteBufferFeeder> sr_buffer = null;
            try {
                sr_buffer = f.createAsyncForByteBuffer();
                final AsyncReaderWrapperForByteBuffer reader_buffer = new AsyncReaderWrapperForByteBuffer(sr_buffer, chunkSize, XML);
                _testNoDeclaration(sr_buffer, reader_buffer);
            } finally {
                if (sr_buffer != null) {
                    sr_buffer.close();
                }
            }
        }
    }
}
Also used : AsyncByteBufferFeeder(com.fasterxml.aalto.AsyncByteBufferFeeder) AsyncByteArrayFeeder(com.fasterxml.aalto.AsyncByteArrayFeeder) InputFactoryImpl(com.fasterxml.aalto.stax.InputFactoryImpl) AsyncXMLInputFactory(com.fasterxml.aalto.AsyncXMLInputFactory)

Aggregations

AsyncByteBufferFeeder (com.fasterxml.aalto.AsyncByteBufferFeeder)24 AsyncXMLInputFactory (com.fasterxml.aalto.AsyncXMLInputFactory)22 InputFactoryImpl (com.fasterxml.aalto.stax.InputFactoryImpl)22 AsyncByteArrayFeeder (com.fasterxml.aalto.AsyncByteArrayFeeder)21 ByteBuffer (java.nio.ByteBuffer)1