use of com.fasterxml.jackson.core.testsupport.AsyncReaderWrapper 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 (JsonParseException 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.testsupport.AsyncReaderWrapper in project jackson-core by FasterXML.
the class AsyncCommentParsingTest method _testCommentsBeforePropValue.
private void _testCommentsBeforePropValue(JsonFactory f, String comment, int bytesPerRead) throws Exception {
for (String arg : new String[] { ":%s123", " :%s123", "\t:%s123", ": %s123", ":\t%s123" }) {
String commented = String.format(arg, comment);
final String DOC = "{\"abc\"" + commented + "}";
AsyncReaderWrapper p = _createParser(f, DOC, bytesPerRead);
assertEquals(JsonToken.START_OBJECT, p.nextToken());
JsonToken t = null;
try {
t = p.nextToken();
} catch (Exception e) {
throw new RuntimeException("Failed on '" + DOC + "' due to " + e, e);
}
assertEquals(JsonToken.FIELD_NAME, t);
try {
t = p.nextToken();
} catch (Exception e) {
throw new RuntimeException("Failed on '" + DOC + "' due to " + e, e);
}
assertEquals(JsonToken.VALUE_NUMBER_INT, t);
assertEquals(123, p.getIntValue());
assertEquals(JsonToken.END_OBJECT, p.nextToken());
p.close();
}
}
use of com.fasterxml.jackson.core.testsupport.AsyncReaderWrapper in project jackson-core by FasterXML.
the class AsyncCommentParsingTest method _testWithUTF8Chars.
/*
/**********************************************************
/* Helper methods
/**********************************************************
*/
private void _testWithUTF8Chars(String doc, int bytesPerRead) throws IOException {
// should basically just stream through
AsyncReaderWrapper p = _createParser(doc, true, bytesPerRead);
assertToken(JsonToken.START_ARRAY, p.nextToken());
assertToken(JsonToken.VALUE_STRING, p.nextToken());
assertToken(JsonToken.END_ARRAY, p.nextToken());
assertNull(p.nextToken());
p.close();
}
use of com.fasterxml.jackson.core.testsupport.AsyncReaderWrapper in project jackson-core by FasterXML.
the class AsyncCharEscapingTest method test8DigitSequence.
public void test8DigitSequence() throws Exception {
String DOC = "[\"\\u00411234\"]";
AsyncReaderWrapper r = asyncForBytes(JSON_F, 1, _jsonDoc(DOC), 1);
assertToken(JsonToken.START_ARRAY, r.nextToken());
assertToken(JsonToken.VALUE_STRING, r.nextToken());
assertEquals("A1234", r.currentText());
r.close();
}
use of com.fasterxml.jackson.core.testsupport.AsyncReaderWrapper in project jackson-core by FasterXML.
the class AsyncFieldNamesTest method _testSimpleFieldName.
private void _testSimpleFieldName(String fieldName) throws IOException {
// use long buffer to ensure fast decoding may be used
AsyncReaderWrapper r = asyncForBytes(JSON_F, 99, _jsonDoc(String.format("{\"%s\":true} \r", fieldName)), 0);
assertNull(r.currentToken());
assertToken(JsonToken.START_OBJECT, r.nextToken());
assertToken(JsonToken.FIELD_NAME, r.nextToken());
assertEquals(fieldName, r.currentName());
assertToken(JsonToken.VALUE_TRUE, r.nextToken());
assertToken(JsonToken.END_OBJECT, r.nextToken());
assertNull(r.nextToken());
JsonLocation loc = r.parser().getCurrentLocation();
assertEquals(2, loc.getLineNr());
assertEquals(1, loc.getColumnNr());
}
Aggregations