use of com.fasterxml.jackson.core.exc.StreamReadException in project jackson-dataformats-binary by FasterXML.
the class ParserInternalsTest method _verifyVIntBad.
private void _verifyVIntBad(byte[] doc, String... msgs) throws Exception {
// First, read with no boundaries
try (SmileParser p = _minimalParser(doc)) {
try {
int val = p._readUnsignedVInt();
fail("Should not pass, got 0x" + Integer.toHexString(val));
} catch (StreamReadException e) {
verifyException(e, msgs);
}
}
// Then incremental read
try (SmileParser p = _minimalParser(new ThrottledInputStream(doc, 1))) {
try {
int val = p._readUnsignedVInt();
fail("Should not pass, got 0x" + Integer.toHexString(val));
} catch (StreamReadException e) {
verifyException(e, msgs);
}
}
}
use of com.fasterxml.jackson.core.exc.StreamReadException in project jackson-core by FasterXML.
the class ParserErrorHandling679Test method _testNonRootMangledFloats679.
private void _testNonRootMangledFloats679(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();
Double v = p.getDoubleValue();
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 _doTestInvalidKeyword.
private void _doTestInvalidKeyword(String value) {
String doc = "{ \"key1\" : " + value + " }";
AsyncReaderWrapper p = _createParser(doc);
assertToken(JsonToken.START_OBJECT, p.nextToken());
// get the exception early or late...
try {
assertToken(JsonToken.PROPERTY_NAME, p.nextToken());
p.nextToken();
fail("Expected an exception for malformed value keyword");
} catch (StreamReadException jex) {
verifyException(jex, "Unrecognized token");
verifyException(jex, value);
} finally {
p.close();
}
// Try as root-level value as well:
// may need space after for DataInput
doc = value + " ";
p = _createParser(doc);
try {
p.nextToken();
fail("Expected an exception for malformed value keyword");
} catch (StreamReadException jex) {
verifyException(jex, "Unrecognized token");
verifyException(jex, value);
} finally {
p.close();
}
}
use of com.fasterxml.jackson.core.exc.StreamReadException in project jackson-core by FasterXML.
the class AsyncTokenErrorTest method testMangledRootInts.
public void testMangledRootInts() {
AsyncReaderWrapper p = _createParser("123true");
try {
JsonToken t = p.nextToken();
fail("Should have gotten an exception; instead got token: " + t + "; number: " + p.getNumberValue());
} catch (StreamReadException e) {
verifyException(e, "expected space");
}
p.close();
}
use of com.fasterxml.jackson.core.exc.StreamReadException in project jackson-core by FasterXML.
the class AsyncTokenErrorTest method testMangledNonRootFloats.
public void testMangledNonRootFloats() {
AsyncReaderWrapper p = _createParser("[ 1.5false ]");
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();
}
Aggregations