use of com.fasterxml.jackson.core.exc.StreamReadException in project jackson-core by FasterXML.
the class AsyncCharEscapingTest method _testMissingLinefeedEscaping.
private void _testMissingLinefeedEscaping(byte[] doc, int offset, int readSize) throws Exception {
AsyncReaderWrapper r = asyncForBytes(JSON_F, readSize, doc, offset);
assertToken(JsonToken.START_ARRAY, r.nextToken());
try {
// This may or may not trigger exception
JsonToken t = r.nextToken();
assertToken(JsonToken.VALUE_STRING, t);
fail("Expected an exception for un-escaped linefeed in string value");
} catch (StreamReadException jex) {
verifyException(jex, "has to be escaped");
}
r.close();
}
use of com.fasterxml.jackson.core.exc.StreamReadException in project jackson-core by FasterXML.
the class AsyncCommentParsingTest method _testDisabled.
private void _testDisabled(String doc) throws IOException {
AsyncReaderWrapper p = _createParser(doc, false, 3);
assertToken(JsonToken.START_ARRAY, p.nextToken());
try {
p.nextToken();
fail("Expected exception for unrecognized comment");
} catch (StreamReadException je) {
// Should have something denoting that user may want to enable 'ALLOW_COMMENTS'
verifyException(je, "ALLOW_COMMENTS");
}
p.close();
}
use of com.fasterxml.jackson.core.exc.StreamReadException in project jackson-core by FasterXML.
the class AsyncInvalidCharsTest method _testHandlingOfInvalidSpace.
private void _testHandlingOfInvalidSpace(int offset, int readSize) throws Exception {
final String doc = "{ \u0008 \"a\":1}";
AsyncReaderWrapper p = asyncForBytes(JSON_F, readSize, _jsonDoc(doc), offset);
assertToken(JsonToken.START_OBJECT, p.nextToken());
try {
p.nextToken();
fail("Should have failed");
} catch (StreamReadException e) {
verifyException(e, "Illegal character");
// and correct error code
verifyException(e, "code 8");
}
p.close();
}
use of com.fasterxml.jackson.core.exc.StreamReadException in project jackson-core by FasterXML.
the class AsyncInvalidCharsTest method _testUTF8BomFail.
private void _testUTF8BomFail(int offset, int readSize, int okBytes, String verify) throws Exception {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
bytes.write(0xEF);
if (okBytes > 1) {
bytes.write(0xBB);
}
bytes.write("[ 1 ]".getBytes("UTF-8"));
byte[] doc = bytes.toByteArray();
AsyncReaderWrapper p = asyncForBytes(JSON_F, readSize, doc, offset);
try {
assertEquals(JsonToken.START_ARRAY, p.nextToken());
fail("Should not pass");
} catch (StreamReadException e) {
verifyException(e, verify);
}
}
use of com.fasterxml.jackson.core.exc.StreamReadException in project jackson-core by FasterXML.
the class AsyncNonStdParsingTest method _testNonStandarBackslashQuoting.
private void _testNonStandarBackslashQuoting(int offset, int readSize) {
// first: verify that we get an exception
JsonFactory f = new JsonFactory();
final String JSON = quote("\\'");
AsyncReaderWrapper p = createParser(f, JSON, offset, readSize);
try {
p.nextToken();
p.currentText();
fail("Should have thrown an exception for doc <" + JSON + ">");
} catch (StreamReadException e) {
verifyException(e, "unrecognized character escape");
} finally {
p.close();
}
// and then verify it's ok...
f = f.rebuild().enable(JsonReadFeature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER).build();
p = createParser(f, JSON, offset, readSize);
assertToken(JsonToken.VALUE_STRING, p.nextToken());
assertEquals("'", p.currentText());
p.close();
}
Aggregations