Search in sources :

Example 6 with BufferRecycler

use of com.fasterxml.jackson.core.util.BufferRecycler in project jackson-core by FasterXML.

the class UTF8DataInputJsonParserTest method test_parseAposNameThrowsEOFException.

@Test
public void test_parseAposNameThrowsEOFException() throws IOException {
    IOContext ioContext = new IOContext(new BufferRecycler(), this, false);
    byte[] byteArray = new byte[17];
    byteArray[4] = (byte) 43;
    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);
    try {
        uTF8DataInputJsonParser._parseAposName();
        fail("Expecting exception: EOFException");
    } catch (EOFException e) {
        assertEquals(DataInputStream.class.getName(), e.getStackTrace()[0].getClassName());
    }
}
Also used : BufferRecycler(com.fasterxml.jackson.core.util.BufferRecycler) IOContext(com.fasterxml.jackson.core.io.IOContext) ByteQuadsCanonicalizer(com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer) BaseTest(com.fasterxml.jackson.core.BaseTest) Test(org.junit.Test)

Example 7 with BufferRecycler

use of com.fasterxml.jackson.core.util.BufferRecycler in project jackson-core by FasterXML.

the class UTF8DataInputJsonParserTest method testGetNextFieldNameAndGetTextLength.

@Test
public void testGetNextFieldNameAndGetTextLength() 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);
    UTF8DataInputJsonParser uTF8DataInputJsonParser = new UTF8DataInputJsonParser(ObjectReadContext.empty(), ioContext, 42, dataInputStream, ByteQuadsCanonicalizer.createRoot(), 0);
    uTF8DataInputJsonParser.nextFieldName();
    assertNull(uTF8DataInputJsonParser.getObjectId());
    assertEquals(1, uTF8DataInputJsonParser.getTextLength());
}
Also used : BufferRecycler(com.fasterxml.jackson.core.util.BufferRecycler) IOContext(com.fasterxml.jackson.core.io.IOContext) BaseTest(com.fasterxml.jackson.core.BaseTest) Test(org.junit.Test)

Example 8 with BufferRecycler

use of com.fasterxml.jackson.core.util.BufferRecycler in project jackson-core by FasterXML.

the class UTF8DataInputJsonParserTest method test_parsePosNumber.

@Test
public void test_parsePosNumber() throws IOException {
    byte[] byteArray = new byte[2];
    byteArray[0] = (byte) 51;
    byteArray[1] = (byte) 22;
    IOContext ioContext = new IOContext(new BufferRecycler(), byteArray, false);
    InputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
    ByteQuadsCanonicalizer byteQuadsCanonicalizer = ByteQuadsCanonicalizer.createRoot();
    DataInputStream dataInputStream = new DataInputStream(byteArrayInputStream);
    UTF8DataInputJsonParser uTF8DataInputJsonParser = new UTF8DataInputJsonParser(ObjectReadContext.empty(), ioContext, 1568, dataInputStream, byteQuadsCanonicalizer, 13);
    JsonToken jsonToken = uTF8DataInputJsonParser._parsePosNumber(7);
    assertEquals(7, jsonToken.id());
    assertNull(jsonToken.asString());
}
Also used : BufferRecycler(com.fasterxml.jackson.core.util.BufferRecycler) IOContext(com.fasterxml.jackson.core.io.IOContext) ByteQuadsCanonicalizer(com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer) JsonToken(com.fasterxml.jackson.core.JsonToken) BaseTest(com.fasterxml.jackson.core.BaseTest) Test(org.junit.Test)

Example 9 with BufferRecycler

use of com.fasterxml.jackson.core.util.BufferRecycler in project jackson-core by FasterXML.

the class UTF8DataInputJsonParserTest method test_parseNegNumberThrowsIOException.

@Test
public void test_parseNegNumberThrowsIOException() throws IOException {
    IOContext ioContext = new IOContext(new BufferRecycler(), this, false);
    byte[] byteArray = new byte[20];
    byteArray[2] = (byte) 73;
    InputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
    DataInputStream dataInputStream = new DataInputStream(byteArrayInputStream);
    UTF8DataInputJsonParser uTF8DataInputJsonParser = new UTF8DataInputJsonParser(ObjectReadContext.empty(), ioContext, 100, dataInputStream, null, 3);
    dataInputStream.readUnsignedShort();
    try {
        uTF8DataInputJsonParser._parseNegNumber();
        fail("Expecting exception: IOException");
    } catch (IOException e) {
        assertEquals(JsonParser.class.getName(), e.getStackTrace()[0].getClassName());
    }
}
Also used : BufferRecycler(com.fasterxml.jackson.core.util.BufferRecycler) IOContext(com.fasterxml.jackson.core.io.IOContext) BaseTest(com.fasterxml.jackson.core.BaseTest) Test(org.junit.Test)

Example 10 with BufferRecycler

use of com.fasterxml.jackson.core.util.BufferRecycler in project jackson-core by FasterXML.

the class UTF8DataInputJsonParserTest method testNextFieldNameThrowsIOException.

@Test
public void testNextFieldNameThrowsIOException() {
    IOContext ioContext = new IOContext(new BufferRecycler(), this, false);
    byte[] byteArray = new byte[20];
    byteArray[0] = (byte) 47;
    InputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
    DataInputStream dataInputStream = new DataInputStream(byteArrayInputStream);
    UTF8DataInputJsonParser uTF8DataInputJsonParser = new UTF8DataInputJsonParser(ObjectReadContext.empty(), ioContext, 100, dataInputStream, null, -2624);
    try {
        uTF8DataInputJsonParser.nextFieldName();
        fail("Expecting exception: IOException");
    } catch (IOException e) {
        assertEquals(JsonParser.class.getName(), e.getStackTrace()[0].getClassName());
    }
}
Also used : BufferRecycler(com.fasterxml.jackson.core.util.BufferRecycler) IOContext(com.fasterxml.jackson.core.io.IOContext) BaseTest(com.fasterxml.jackson.core.BaseTest) Test(org.junit.Test)

Aggregations

BufferRecycler (com.fasterxml.jackson.core.util.BufferRecycler)26 IOContext (com.fasterxml.jackson.core.io.IOContext)23 Test (org.junit.Test)16 BaseTest (com.fasterxml.jackson.core.BaseTest)15 ByteQuadsCanonicalizer (com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer)7 UTF8Writer (com.fasterxml.jackson.core.io.UTF8Writer)5 ByteArrayBuilder (com.fasterxml.jackson.core.util.ByteArrayBuilder)2 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)1 JsonParser (com.fasterxml.jackson.core.JsonParser)1 JsonToken (com.fasterxml.jackson.core.JsonToken)1 MergedStream (com.fasterxml.jackson.core.io.MergedStream)1 SegmentedStringWriter (com.fasterxml.jackson.core.io.SegmentedStringWriter)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1