use of com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer in project jackson-core by FasterXML.
the class UTF8DataInputJsonParserTest method testReadBinaryValueThrowsIOException.
@Test
public void testReadBinaryValueThrowsIOException() {
BufferRecycler bufferRecycler = new BufferRecycler();
IOContext ioContext = new IOContext(bufferRecycler, this, false);
ByteQuadsCanonicalizer byteQuadsCanonicalizer = ByteQuadsCanonicalizer.createRoot();
UTF8DataInputJsonParser uTF8DataInputJsonParser = new UTF8DataInputJsonParser(ObjectReadContext.empty(), ioContext, (-53), null, byteQuadsCanonicalizer, 48);
ByteArrayBuilder byteArrayBuilder = new ByteArrayBuilder(bufferRecycler, 1);
try {
uTF8DataInputJsonParser.readBinaryValue(null, byteArrayBuilder);
fail("Expecting exception: IOException");
} catch (IOException e) {
assertEquals(JsonParser.class.getName(), e.getStackTrace()[0].getClassName());
}
}
use of com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer in project jackson-core by FasterXML.
the class UTF8DataInputJsonParserTest method testGetTextOffsetAndNextFieldName.
@Test
public void testGetTextOffsetAndNextFieldName() throws IOException {
byte[] byteArray = new byte[2];
byteArray[1] = (byte) 91;
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, 42, dataInputStream, byteQuadsCanonicalizer, 0);
assertEquals(0, uTF8DataInputJsonParser.getTextOffset());
assertNull(uTF8DataInputJsonParser.nextFieldName());
}
use of com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer in project jackson-core by FasterXML.
the class AsyncParserNamesTest method testSymbolTable.
public void testSymbolTable() throws IOException {
final String STR1 = "a";
byte[] doc = _jsonDoc("{ " + quote(STR1) + ":1, \"foobar\":2, \"longername\":3 }");
JsonFactory f = JSON_F;
AsyncReaderWrapper p = asyncForBytes(f, 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());
// field names not intern()ed by default any more in 3.x
assertEquals(STR1, p.currentName());
// assertSame(STR1, p.currentName());
assertEquals(1, symbols1.size());
assertEquals(JsonToken.VALUE_NUMBER_INT, p.nextToken());
assertEquals(JsonToken.FIELD_NAME, p.nextToken());
assertEquals("foobar", p.currentName());
assertEquals(2, symbols1.size());
assertEquals(JsonToken.VALUE_NUMBER_INT, p.nextToken());
assertEquals(JsonToken.FIELD_NAME, p.nextToken());
assertEquals("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();
// but let's verify that symbol table gets reused properly
p = asyncForBytes(f, 5, doc, 0);
final ByteQuadsCanonicalizer symbols2 = ((NonBlockingJsonParserBase) p.parser()).symbolTableForTests();
// symbol tables are not reused, but contents are:
assertNotSame(symbols1, symbols2);
assertEquals(3, symbols2.size());
assertEquals(JsonToken.START_OBJECT, p.nextToken());
assertEquals(JsonToken.FIELD_NAME, p.nextToken());
// field names are interned:
assertEquals(STR1, p.currentName());
assertEquals(3, symbols2.size());
assertEquals(JsonToken.VALUE_NUMBER_INT, p.nextToken());
assertEquals(JsonToken.FIELD_NAME, p.nextToken());
assertEquals("foobar", p.currentName());
assertEquals(3, symbols2.size());
assertEquals(JsonToken.VALUE_NUMBER_INT, p.nextToken());
assertEquals(JsonToken.FIELD_NAME, p.nextToken());
assertEquals("longername", p.currentName());
assertEquals(3, symbols2.size());
assertEquals(JsonToken.VALUE_NUMBER_INT, p.nextToken());
assertEquals(JsonToken.END_OBJECT, p.nextToken());
assertNull(p.nextToken());
assertEquals(3, symbols2.size());
p.close();
assertEquals(3, symbols2.size());
p.close();
}
Aggregations