Search in sources :

Example 21 with AsyncXMLInputFactory

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

the class TestCharactersParsing method _testTextWithNumericEntities.

private void _testTextWithNumericEntities(final int chunkSize, final boolean checkValues, final String SPC) throws Exception {
    final String XML = SPC + "<root>&#60;tag&#x3e;!</root>";
    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, XML);
        _testTextWithNumericEntities(sr_array, reader_array, checkValues);
    } 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);
        _testTextWithNumericEntities(sr_buffer, reader_buffer, checkValues);
    } 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 22 with AsyncXMLInputFactory

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

the class TestDoctypeParsing method _testFull.

private void _testFull(final String spaces, final boolean checkValue, final int chunkSize) throws Exception {
    final String SYSTEM_ID = "file:/something";
    final String INTERNAL_SUBSET = "<!--My dtd-->\n" + "<!ELEMENT html (head, body)>" + "<!ATTLIST head title CDATA #IMPLIED>";
    String XML = spaces + "<!DOCTYPE root SYSTEM '" + SYSTEM_ID + "' [" + INTERNAL_SUBSET + "]>\n<root/>";
    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, XML);
        _testFull(sr_array, reader_array, checkValue, SYSTEM_ID, INTERNAL_SUBSET);
    } 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);
        _testFull(sr_buffer, reader_buffer, checkValue, SYSTEM_ID, INTERNAL_SUBSET);
    } 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 23 with AsyncXMLInputFactory

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

the class TestDoctypeParsing method _testWithIds.

private void _testWithIds(String spaces, int chunkSize, String PUBLIC_ID, String SYSTEM_ID) throws Exception {
    final String XML = spaces + "<!DOCTYPE root PUBLIC '" + PUBLIC_ID + "' \"" + SYSTEM_ID + "\"><root/>";
    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, XML);
        _testWithIds(sr_array, reader_array, PUBLIC_ID, SYSTEM_ID);
    } 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);
        _testWithIds(sr_buffer, reader_buffer, PUBLIC_ID, SYSTEM_ID);
    } 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 24 with AsyncXMLInputFactory

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

the class TestEntityParsing method _testEntity.

/*
    /**********************************************************************
    /* Secondary test methods
    /**********************************************************************
     */
private void _testEntity(final int chunkSize, final boolean checkValues, final String spaces) throws Exception {
    final String XML = spaces + "<root>&entity1;Some text&entity2;!<leaf>...&leafEntity;</leaf>&last;</root>";
    final AsyncXMLInputFactory f = new InputFactoryImpl();
    // important must not require expansion of general entities
    f.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.FALSE);
    // test for byte array
    AsyncXMLStreamReader<AsyncByteArrayFeeder> sr_array = null;
    try {
        sr_array = f.createAsyncForByteArray();
        final AsyncReaderWrapperForByteArray reader_array = new AsyncReaderWrapperForByteArray(sr_array, chunkSize, XML);
        _testEntity(sr_array, reader_array, checkValues);
    } 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);
        _testEntity(sr_buffer, reader_buffer, checkValues);
    } 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 25 with AsyncXMLInputFactory

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

the class TestAsyncErrorHandling method testSimpleByteArray.

public void testSimpleByteArray() throws Exception {
    final AsyncXMLInputFactory f = newAsyncInputFactory();
    AsyncXMLStreamReader<AsyncByteArrayFeeder> sr = f.createAsyncForByteArray();
    final AsyncReaderWrapperForByteArray asyncR = new AsyncReaderWrapperForByteArray(sr, 1000, "<root>a</root><second>x>/second>");
    int t = verifyStart(asyncR);
    assertTokenType(START_ELEMENT, t);
    assertEquals("root", sr.getLocalName());
    assertEquals(0, sr.getAttributeCount());
    assertTokenType(CHARACTERS, sr.next());
    assertTokenType(END_ELEMENT, sr.next());
    // and now expect problems
    try {
        sr.next();
        fail("Should not pass");
    } catch (XMLStreamException e) {
        verifyException(e, "Second root element in content");
    }
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) AsyncByteArrayFeeder(com.fasterxml.aalto.AsyncByteArrayFeeder) AsyncXMLInputFactory(com.fasterxml.aalto.AsyncXMLInputFactory)

Aggregations

AsyncXMLInputFactory (com.fasterxml.aalto.AsyncXMLInputFactory)25 AsyncByteArrayFeeder (com.fasterxml.aalto.AsyncByteArrayFeeder)24 InputFactoryImpl (com.fasterxml.aalto.stax.InputFactoryImpl)24 AsyncByteBufferFeeder (com.fasterxml.aalto.AsyncByteBufferFeeder)22 Result (io.georocket.input.Splitter.Result)1 XMLChunkMeta (io.georocket.storage.XMLChunkMeta)1 Window (io.georocket.util.Window)1 XMLStreamEvent (io.georocket.util.XMLStreamEvent)1 ArrayList (java.util.ArrayList)1 XMLStreamException (javax.xml.stream.XMLStreamException)1