use of com.fasterxml.jackson.core.exc.StreamReadException in project jackson-core by FasterXML.
the class CoreJDKSerializabilityTest method testParseException.
public void testParseException() throws Exception {
JsonFactory jf = new JsonFactory();
JsonParser p = jf.createParser(ObjectReadContext.empty(), " { garbage! }");
StreamReadException exc = null;
try {
p.nextToken();
p.nextToken();
fail("Should not get here");
} catch (StreamReadException e) {
exc = e;
}
p.close();
byte[] stuff = jdkSerialize(exc);
StreamReadException result = jdkDeserialize(stuff);
assertNotNull(result);
}
use of com.fasterxml.jackson.core.exc.StreamReadException in project jackson-core by FasterXML.
the class ParserErrorHandling679Test method _testNonRootMangledInts.
private void _testNonRootMangledInts(int mode, String value) throws Exception {
// Also test with floats
JsonParser p = createParser(mode, "[ " + value + " ]");
assertEquals(JsonToken.START_ARRAY, p.nextToken());
try {
JsonToken t = p.nextToken();
int v = p.getIntValue();
fail("Should have gotten an exception for '" + value + "'; instead got (" + t + ") number: " + v);
} catch (StreamReadException e) {
verifyException(e, "expected ");
}
p.close();
}
use of com.fasterxml.jackson.core.exc.StreamReadException in project jackson-core by FasterXML.
the class AsyncTokenErrorTest method testMangledNonRootInts.
public void testMangledNonRootInts() {
AsyncReaderWrapper p = _createParser("[ 123true ]");
assertToken(JsonToken.START_ARRAY, p.nextToken());
try {
JsonToken t = p.nextToken();
fail("Should have gotten an exception; instead got token: " + t);
} catch (StreamReadException e) {
verifyException(e, "expected space");
}
p.close();
}
use of com.fasterxml.jackson.core.exc.StreamReadException in project jackson-dataformats-binary by FasterXML.
the class UncaughtException303Test method testUncaughtException303.
// [dataformats-binary#303]
@Test
public void testUncaughtException303() throws Exception {
URL poc = getClass().getResource("/data/issue-303.ion");
try {
MAPPER.readTree(poc);
fail("Should not pass with invalid content");
} catch (StreamReadException e) {
// !!! TODO: change to match what we actually expect
verifyException(e, "MATCH MESSAGE");
}
}
use of com.fasterxml.jackson.core.exc.StreamReadException in project jackson-dataformats-binary by FasterXML.
the class Fuzz272_32722_ChunkedTextTest method testChunkedWithUTF8_4Bytes.
// [dataformats-binary#272]
public void testChunkedWithUTF8_4Bytes() throws Exception {
final byte[] input = new byte[] { // text, chunked (length marker 0x1F)
(byte) 0x7F, // text segment of 0 bytes. Legal but weird
0x60, // "simple value" 16, reported as "int" 16.
(byte) 0xF0, // ... whatever this would be, fuzzer playing with stuff
0x70 };
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, "Mismatched chunk in chunked content");
verifyException(e, "(byte 0xF0)");
}
}
}
Aggregations