Search in sources :

Example 21 with BufferRecycler

use of com.fasterxml.jackson.core.util.BufferRecycler 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());
    }
}
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 22 with BufferRecycler

use of com.fasterxml.jackson.core.util.BufferRecycler 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());
    }
}
Also used : BufferRecycler(com.fasterxml.jackson.core.util.BufferRecycler) IOContext(com.fasterxml.jackson.core.io.IOContext) ByteQuadsCanonicalizer(com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer) ByteArrayBuilder(com.fasterxml.jackson.core.util.ByteArrayBuilder) BaseTest(com.fasterxml.jackson.core.BaseTest) Test(org.junit.Test)

Example 23 with BufferRecycler

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

the class UTF8DataInputJsonParserTest method testGetValueAsIntTakingNoArguments.

@Test
public void testGetValueAsIntTakingNoArguments() throws IOException {
    byte[] byteArray = new byte[2];
    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);
    assertEquals(0, uTF8DataInputJsonParser.getValueAsInt());
}
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 24 with BufferRecycler

use of com.fasterxml.jackson.core.util.BufferRecycler 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());
}
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 25 with BufferRecycler

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

the class UTF8DataInputJsonParserTest method test_skipStringThrowsIOException.

@Test
public void test_skipStringThrowsIOException() {
    IOContext ioContext = new IOContext(new BufferRecycler(), this, false);
    byte[] byteArray = new byte[12];
    byteArray[4] = (byte) (-10);
    InputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
    DataInputStream dataInputStream = new DataInputStream(byteArrayInputStream);
    UTF8DataInputJsonParser uTF8DataInputJsonParser = new UTF8DataInputJsonParser(ObjectReadContext.empty(), ioContext, 100, dataInputStream, null, 11);
    try {
        uTF8DataInputJsonParser._skipString();
        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