use of com.fasterxml.jackson.core.exc.StreamReadException in project jackson-dataformats-binary by FasterXML.
the class BrokenLongBinary186Test method _testCorruptLong.
private void _testCorruptLong(int allegedLength, int actualIncluded) {
JsonParser p = MAPPER.createParser(_createBrokenDoc(allegedLength, actualIncluded));
assertEquals(JsonToken.VALUE_EMBEDDED_OBJECT, p.nextToken());
try {
p.getBinaryValue();
fail("Should fail");
} catch (StreamReadException e) {
verifyException(e, "Unexpected end-of-input for Binary value");
verifyException(e, "expected " + allegedLength + " bytes, only found " + actualIncluded);
}
}
use of com.fasterxml.jackson.core.exc.StreamReadException in project jackson-dataformats-binary by FasterXML.
the class BrokenLongBinary186Test method testQuiteLongStreaming.
/*
/**********************************************************************
/* And then "streaming" access
/**********************************************************************
*/
// [dataformats-binary#186]
public void testQuiteLongStreaming() throws Exception {
// Can try bit shorter here, like 500 megs
final int allegedLength = 500_000_000;
JsonParser p = MAPPER.createParser(_createBrokenDoc(allegedLength, 72000));
assertEquals(JsonToken.VALUE_EMBEDDED_OBJECT, p.nextToken());
try {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
p.readBinaryValue(bytes);
fail("Should fail");
} catch (StreamReadException e) {
verifyException(e, "Unexpected end-of-input for Binary value");
verifyException(e, "expected " + allegedLength + " bytes, only found 72000");
}
}
use of com.fasterxml.jackson.core.exc.StreamReadException in project jackson-dataformats-binary by FasterXML.
the class Fuzz273_32912_ChunkedTextTest method testChunkedWithUTF8_4Bytes_v2.
// [dataformats-binary#273]
// (see https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=32912)
public void testChunkedWithUTF8_4Bytes_v2() throws Exception {
final byte[] input = new byte[] { // text, chunked (length marker 0x1F)
(byte) 0x7F, // text segment of 1 bytes.
0x61, // First byte of 4-byte UTF-8 character
(byte) 0xF3, // (invalid) second byte of 4-byte UTF-8 character
0x61 };
try (JsonParser p = MAPPER.createParser(input)) {
assertToken(JsonToken.VALUE_STRING, p.nextToken());
try {
p.getText();
fail("Should not pass, invalid content");
} catch (StreamReadException e) {
verifyException(e, "Unexpected end-of-input in VALUE_STRING");
}
}
}
use of com.fasterxml.jackson.core.exc.StreamReadException in project jackson-dataformats-binary by FasterXML.
the class SimpleValuesTest method testInvalidByteLengthMinimalValues.
public void testInvalidByteLengthMinimalValues() {
// Values 0..31 are invalid for variant that takes 2 bytes...
for (int v = 0; v <= 31; ++v) {
byte[] doc = { (byte) (CBORConstants.PREFIX_TYPE_MISC + 24), (byte) v };
try (JsonParser p = cborParser(doc)) {
try {
p.nextToken();
fail("Should not pass");
} catch (StreamReadException e) {
verifyException(e, "Invalid second byte for simple value:");
verifyException(e, "0x" + Integer.toHexString(v));
}
}
}
}
use of com.fasterxml.jackson.core.exc.StreamReadException in project jackson-dataformats-binary by FasterXML.
the class POJOSimpleReadTest method testMissingSchema.
public void testMissingSchema() throws Exception {
Employee empl = _simpleEmployee();
byte[] avro = toAvro(empl);
JsonParser p = MAPPER.createParser(avro);
try {
p.nextToken();
fail("Should not pass");
} catch (StreamReadException e) {
verifyException(e, "No AvroSchema set");
}
p.close();
}
Aggregations