use of com.fasterxml.jackson.core.testsupport.AsyncReaderWrapper 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 (JsonParseException e) {
verifyException(e, "Illegal character");
// and correct error code
verifyException(e, "code 8");
}
p.close();
}
use of com.fasterxml.jackson.core.testsupport.AsyncReaderWrapper 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 (JsonParseException e) {
verifyException(e, verify);
}
}
use of com.fasterxml.jackson.core.testsupport.AsyncReaderWrapper in project jackson-core by FasterXML.
the class AsyncMissingValuesInObjectTest method testObjectTrailingComma.
@Test
public void testObjectTrailingComma() throws Exception {
String json = "{\"a\": true, \"b\": false,}";
AsyncReaderWrapper p = createParser(factory, json);
assertEquals(JsonToken.START_OBJECT, p.nextToken());
assertToken(JsonToken.FIELD_NAME, p.nextToken());
assertEquals("a", p.currentText());
assertToken(JsonToken.VALUE_TRUE, p.nextToken());
assertToken(JsonToken.FIELD_NAME, p.nextToken());
assertEquals("b", p.currentText());
assertToken(JsonToken.VALUE_FALSE, p.nextToken());
if (features.contains(Feature.ALLOW_TRAILING_COMMA)) {
assertToken(JsonToken.END_OBJECT, p.nextToken());
assertEnd(p);
} else {
assertUnexpected(p, '}');
}
p.close();
}
use of com.fasterxml.jackson.core.testsupport.AsyncReaderWrapper in project jackson-core by FasterXML.
the class AsyncMissingValuesInObjectTest method testObjectInnerComma.
@Test
public void testObjectInnerComma() throws Exception {
String json = "{\"a\": true,, \"b\": false}";
AsyncReaderWrapper p = createParser(factory, json);
assertEquals(JsonToken.START_OBJECT, p.nextToken());
assertToken(JsonToken.FIELD_NAME, p.nextToken());
assertEquals("a", p.currentText());
assertToken(JsonToken.VALUE_TRUE, p.nextToken());
assertUnexpected(p, ',');
p.close();
}
use of com.fasterxml.jackson.core.testsupport.AsyncReaderWrapper in project jackson-core by FasterXML.
the class AsyncMissingValuesInObjectTest method testObjectBasic.
@Test
public void testObjectBasic() throws Exception {
String json = "{\"a\": true, \"b\": false}";
AsyncReaderWrapper p = createParser(factory, json);
assertEquals(JsonToken.START_OBJECT, p.nextToken());
assertToken(JsonToken.FIELD_NAME, p.nextToken());
assertEquals("a", p.currentText());
assertToken(JsonToken.VALUE_TRUE, p.nextToken());
assertToken(JsonToken.FIELD_NAME, p.nextToken());
assertEquals("b", p.currentText());
assertToken(JsonToken.VALUE_FALSE, p.nextToken());
assertEquals(JsonToken.END_OBJECT, p.nextToken());
assertEnd(p);
p.close();
}
Aggregations