use of com.fasterxml.jackson.core.testsupport.AsyncReaderWrapper in project jackson-core by FasterXML.
the class AsyncSimpleNestedTest method _testStuffInArray.
private void _testStuffInArray(JsonFactory f, byte[] data, int offset, int readSize) throws IOException {
AsyncReaderWrapper r = asyncForBytes(f, readSize, data, offset);
assertToken(JsonToken.START_ARRAY, r.nextToken());
assertFalse(r.parser().hasTextCharacters());
assertToken(JsonToken.VALUE_TRUE, r.nextToken());
assertToken(JsonToken.START_OBJECT, r.nextToken());
assertEquals("{", r.currentText());
assertToken(JsonToken.FIELD_NAME, r.nextToken());
assertEquals("moreStuff", r.currentName());
assertToken(JsonToken.VALUE_NUMBER_INT, r.nextToken());
assertEquals(0L, r.getLongValue());
assertToken(JsonToken.END_OBJECT, r.nextToken());
assertToken(JsonToken.START_ARRAY, r.nextToken());
assertToken(JsonToken.VALUE_NULL, r.nextToken());
assertToken(JsonToken.END_ARRAY, r.nextToken());
assertToken(JsonToken.START_OBJECT, r.nextToken());
assertToken(JsonToken.FIELD_NAME, r.nextToken());
assertEquals("extraOrdinary", r.currentName());
assertToken(JsonToken.VALUE_NUMBER_INT, r.nextToken());
assertEquals(23, r.getIntValue());
assertToken(JsonToken.END_OBJECT, r.nextToken());
assertToken(JsonToken.END_ARRAY, r.nextToken());
}
use of com.fasterxml.jackson.core.testsupport.AsyncReaderWrapper in project jackson-core by FasterXML.
the class AsyncUnicodeHandlingTest method _testUnicodeWithSurrogates.
private void _testUnicodeWithSurrogates(JsonFactory f, int length, int readSize) throws IOException {
final String SURROGATE_CHARS = "\ud834\udd1e";
StringBuilder sb = new StringBuilder(length + 200);
while (sb.length() < length) {
sb.append(SURROGATE_CHARS);
sb.append(sb.length());
if ((sb.length() & 1) == 1) {
sb.append("\u00A3");
} else {
sb.append("\u3800");
}
}
final String TEXT = sb.toString();
final String quoted = quote(TEXT);
byte[] data = _jsonDoc(quoted);
AsyncReaderWrapper r = asyncForBytes(f, readSize, data, 0);
assertToken(JsonToken.VALUE_STRING, r.nextToken());
assertEquals(TEXT, r.currentText());
assertNull(r.nextToken());
r.close();
// Then same but skipping
r = asyncForBytes(f, readSize, data, 0);
assertToken(JsonToken.VALUE_STRING, r.nextToken());
assertNull(r.nextToken());
r.close();
// Also, verify that it works as field name
data = _jsonDoc("{" + quoted + ":true}");
r = asyncForBytes(f, readSize, data, 0);
assertToken(JsonToken.START_OBJECT, r.nextToken());
assertToken(JsonToken.FIELD_NAME, r.nextToken());
assertEquals(TEXT, r.currentName());
assertToken(JsonToken.VALUE_TRUE, r.nextToken());
assertToken(JsonToken.END_OBJECT, r.nextToken());
assertNull(r.nextToken());
r.close();
// and skipping
r = asyncForBytes(f, readSize, data, 0);
assertToken(JsonToken.START_OBJECT, r.nextToken());
assertToken(JsonToken.FIELD_NAME, r.nextToken());
assertToken(JsonToken.VALUE_TRUE, r.nextToken());
assertToken(JsonToken.END_OBJECT, r.nextToken());
r.close();
}
Aggregations