use of com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer in project jackson-core by FasterXML.
the class UTF8DataInputJsonParserTest method testParseEscapedNameThrowsArrayIndexOutOfBoundsException.
@Test
public void testParseEscapedNameThrowsArrayIndexOutOfBoundsException() throws IOException {
IOContext ioContext = new IOContext((BufferRecycler) null, null, false);
PipedOutputStream pipedOutputStream = new PipedOutputStream();
PipedInputStream pipedInputStream = new PipedInputStream(pipedOutputStream, 131);
DataInputStream dataInputStream = new DataInputStream(pipedInputStream);
ByteQuadsCanonicalizer byteQuadsCanonicalizer = ByteQuadsCanonicalizer.createRoot();
UTF8DataInputJsonParser uTF8DataInputJsonParser = new UTF8DataInputJsonParser(ObjectReadContext.empty(), ioContext, 131, dataInputStream, byteQuadsCanonicalizer, (byte) 57);
int[] intArray = new int[3];
try {
uTF8DataInputJsonParser.parseEscapedName(intArray, 56, (byte) 72, (byte) 127, (byte) 57);
fail("Expecting exception: ArrayIndexOutOfBoundsException");
} catch (ArrayIndexOutOfBoundsException e) {
assertEquals(UTF8DataInputJsonParser.class.getName(), e.getStackTrace()[0].getClassName());
}
}
use of com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer in project jackson-core by FasterXML.
the class AsyncParserNamesTest method testSymbolTableWithIntern.
public void testSymbolTableWithIntern() throws IOException {
JsonFactory internF = JsonFactory.builder().enable(TokenStreamFactory.Feature.INTERN_FIELD_NAMES).build();
final String STR1 = "a";
byte[] doc = _jsonDoc("{ " + quote(STR1) + ":1, \"foobar\":2, \"longername\":3 }");
AsyncReaderWrapper p = asyncForBytes(internF, 5, doc, 0);
final ByteQuadsCanonicalizer symbols1 = ((NonBlockingJsonParserBase) p.parser()).symbolTableForTests();
assertEquals(0, symbols1.size());
assertEquals(JsonToken.START_OBJECT, p.nextToken());
assertEquals(JsonToken.FIELD_NAME, p.nextToken());
assertSame(STR1, p.currentName());
assertEquals(1, symbols1.size());
assertEquals(JsonToken.VALUE_NUMBER_INT, p.nextToken());
assertEquals(JsonToken.FIELD_NAME, p.nextToken());
assertSame("foobar", p.currentName());
assertEquals(2, symbols1.size());
assertEquals(JsonToken.VALUE_NUMBER_INT, p.nextToken());
assertEquals(JsonToken.FIELD_NAME, p.nextToken());
assertSame("longername", p.currentName());
assertEquals(3, symbols1.size());
assertEquals(JsonToken.VALUE_NUMBER_INT, p.nextToken());
assertEquals(JsonToken.END_OBJECT, p.nextToken());
assertNull(p.nextToken());
assertEquals(3, symbols1.size());
p.close();
}
use of com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer in project jackson-core by FasterXML.
the class JsonFactory method _createParser.
/**
* @since 2.8
*/
protected JsonParser _createParser(DataInput input, IOContext ctxt) throws IOException {
// 13-May-2016, tatu: Need to take care not to accidentally create JSON parser for
// non-JSON input. So, bit unclean but...
String format = getFormatName();
if (format != FORMAT_NAME_JSON) {
// NOTE: only ensure override; full equality NOT needed
throw new UnsupportedOperationException(String.format("InputData source not (yet?) support for this format (%s)", format));
}
// Also: while we can't do full bootstrapping (due to read-ahead limitations), should
// at least handle possible UTF-8 BOM
int firstByte = ByteSourceJsonBootstrapper.skipUTF8BOM(input);
ByteQuadsCanonicalizer can = _byteSymbolCanonicalizer.makeChild(_factoryFeatures);
return new UTF8DataInputJsonParser(ctxt, _parserFeatures, input, _objectCodec, can, firstByte);
}
use of com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer in project jackson-core by FasterXML.
the class UTF8DataInputJsonParserTest method test_readBinaryThrowsNullPointerException.
@Test
public void test_readBinaryThrowsNullPointerException() throws IOException {
byte[] byteArray = new byte[5];
byteArray[4] = (byte) 43;
IOContext ioContext = new IOContext(new BufferRecycler(), byteArray, false);
InputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
DataInputStream dataInputStream = new DataInputStream(byteArrayInputStream);
ByteQuadsCanonicalizer byteQuadsCanonicalizer = ByteQuadsCanonicalizer.createRoot();
UTF8DataInputJsonParser uTF8DataInputJsonParser = new UTF8DataInputJsonParser(ObjectReadContext.empty(), ioContext, 500, dataInputStream, byteQuadsCanonicalizer, 1);
try {
uTF8DataInputJsonParser._readBinary(null, null, byteArray);
fail("Expecting exception: NullPointerException");
} catch (NullPointerException e) {
assertEquals(UTF8DataInputJsonParser.class.getName(), e.getStackTrace()[0].getClassName());
}
}
use of com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer in project jackson-core by FasterXML.
the class UTF8DataInputJsonParserTest method test_decodeBase64ThrowsEOFException.
@Test
public void test_decodeBase64ThrowsEOFException() throws IOException {
IOContext ioContext = new IOContext(new BufferRecycler(), this, true);
byte[] byteArray = new byte[5];
InputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
DataInputStream dataInputStream = new DataInputStream(byteArrayInputStream);
ByteQuadsCanonicalizer byteQuadsCanonicalizer = ByteQuadsCanonicalizer.createRoot();
UTF8DataInputJsonParser uTF8DataInputJsonParser = new UTF8DataInputJsonParser(ObjectReadContext.empty(), ioContext, (byte) 26, dataInputStream, byteQuadsCanonicalizer, 3);
try {
uTF8DataInputJsonParser._decodeBase64(null);
fail("Expecting exception: EOFException");
} catch (EOFException e) {
assertEquals(DataInputStream.class.getName(), e.getStackTrace()[0].getClassName());
}
}
Aggregations