use of com.fasterxml.aalto.stax.InputFactoryImpl in project aalto-xml by FasterXML.
the class TestXmlDeclaration method testVersionOnlyDeclaration.
public void testVersionOnlyDeclaration() throws Exception {
final String XML = "<?xml version='1.0' ?><root />";
final AsyncXMLInputFactory f = new InputFactoryImpl();
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);
_testVersionOnlyDeclaration(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);
_testVersionOnlyDeclaration(sr_buffer, reader_buffer);
} finally {
if (sr_buffer != null) {
sr_buffer.close();
}
}
}
}
use of com.fasterxml.aalto.stax.InputFactoryImpl 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><tag>!</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();
}
}
}
use of com.fasterxml.aalto.stax.InputFactoryImpl 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();
}
}
}
use of com.fasterxml.aalto.stax.InputFactoryImpl 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();
}
}
}
use of com.fasterxml.aalto.stax.InputFactoryImpl 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();
}
}
}
Aggregations