Search in sources :

Example 61 with AsyncReaderWrapper

use of com.fasterxml.jackson.core.testsupport.AsyncReaderWrapper in project jackson-core by FasterXML.

the class AsyncMissingValuesInObjectTest method createParser.

private AsyncReaderWrapper createParser(JsonFactory f, String doc) throws IOException {
    // should vary but...
    int bytesPerRead = 3;
    AsyncReaderWrapper p = asyncForBytes(f, bytesPerRead, _jsonDoc(doc), 0);
    return p;
}
Also used : AsyncReaderWrapper(com.fasterxml.jackson.core.testsupport.AsyncReaderWrapper)

Example 62 with AsyncReaderWrapper

use of com.fasterxml.jackson.core.testsupport.AsyncReaderWrapper in project jackson-core by FasterXML.

the class AsyncMissingValuesInObjectTest method testObjectLeadingComma.

@Test
public void testObjectLeadingComma() throws Exception {
    String json = "{,\"a\": true, \"b\": false}";
    AsyncReaderWrapper p = createParser(factory, json);
    assertEquals(JsonToken.START_OBJECT, p.nextToken());
    assertUnexpected(p, ',');
    p.close();
}
Also used : AsyncReaderWrapper(com.fasterxml.jackson.core.testsupport.AsyncReaderWrapper) Test(org.junit.Test)

Example 63 with AsyncReaderWrapper

use of com.fasterxml.jackson.core.testsupport.AsyncReaderWrapper in project jackson-core by FasterXML.

the class AsyncNonStdParsingTest method _testLargeUnquoted.

private void _testLargeUnquoted(JsonFactory f, int reps, String doc, int offset, int readSize) throws Exception {
    AsyncReaderWrapper p = createParser(f, doc, offset, readSize);
    assertToken(JsonToken.START_ARRAY, p.nextToken());
    for (int i = 0; i < reps; ++i) {
        assertToken(JsonToken.START_OBJECT, p.nextToken());
        assertToken(JsonToken.FIELD_NAME, p.nextToken());
        assertEquals("abc" + (i & 127), p.currentName());
        assertToken(((i & 1) != 0) ? JsonToken.VALUE_TRUE : JsonToken.VALUE_FALSE, p.nextToken());
        assertToken(JsonToken.END_OBJECT, p.nextToken());
    }
    assertToken(JsonToken.END_ARRAY, p.nextToken());
    p.close();
}
Also used : AsyncReaderWrapper(com.fasterxml.jackson.core.testsupport.AsyncReaderWrapper)

Example 64 with AsyncReaderWrapper

use of com.fasterxml.jackson.core.testsupport.AsyncReaderWrapper in project jackson-core by FasterXML.

the class AsyncNonStdParsingTest method _testSingleQuotesEscaped.

private void _testSingleQuotesEscaped(JsonFactory f, int offset, int readSize) throws Exception {
    String JSON = "[ '16\\'' ]";
    AsyncReaderWrapper p = createParser(f, JSON, offset, readSize);
    assertToken(JsonToken.START_ARRAY, p.nextToken());
    assertToken(JsonToken.VALUE_STRING, p.nextToken());
    assertEquals("16'", p.currentText());
    assertToken(JsonToken.END_ARRAY, p.nextToken());
    p.close();
}
Also used : AsyncReaderWrapper(com.fasterxml.jackson.core.testsupport.AsyncReaderWrapper)

Example 65 with AsyncReaderWrapper

use of com.fasterxml.jackson.core.testsupport.AsyncReaderWrapper in project jackson-core by FasterXML.

the class AsyncNonStdParsingTest method _testNonStandardNameChars.

private void _testNonStandardNameChars(JsonFactory f, int offset, int readSize) throws Exception {
    String JSON = "{ @type : \"mytype\", #color : 123, *error* : true, " + " hyphen-ated : \"yes\", me+my : null" + "}";
    AsyncReaderWrapper p = createParser(f, JSON, offset, readSize);
    assertToken(JsonToken.START_OBJECT, p.nextToken());
    assertToken(JsonToken.FIELD_NAME, p.nextToken());
    assertEquals("@type", p.currentText());
    assertToken(JsonToken.VALUE_STRING, p.nextToken());
    assertEquals("mytype", p.currentText());
    assertToken(JsonToken.FIELD_NAME, p.nextToken());
    assertEquals("#color", p.currentText());
    assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken());
    assertEquals(123, p.getIntValue());
    assertToken(JsonToken.FIELD_NAME, p.nextToken());
    assertEquals("*error*", p.currentText());
    assertToken(JsonToken.VALUE_TRUE, p.nextToken());
    assertToken(JsonToken.FIELD_NAME, p.nextToken());
    assertEquals("hyphen-ated", p.currentText());
    assertToken(JsonToken.VALUE_STRING, p.nextToken());
    assertEquals("yes", p.currentText());
    assertToken(JsonToken.FIELD_NAME, p.nextToken());
    assertEquals("me+my", p.currentText());
    assertToken(JsonToken.VALUE_NULL, p.nextToken());
    assertToken(JsonToken.END_OBJECT, p.nextToken());
    p.close();
}
Also used : AsyncReaderWrapper(com.fasterxml.jackson.core.testsupport.AsyncReaderWrapper)

Aggregations

AsyncReaderWrapper (com.fasterxml.jackson.core.testsupport.AsyncReaderWrapper)87 Test (org.junit.Test)10 JsonFactory (com.fasterxml.jackson.core.json.JsonFactory)5 BigDecimal (java.math.BigDecimal)4 IOException (java.io.IOException)3 BigInteger (java.math.BigInteger)3 JsonParseException (com.fasterxml.jackson.core.JsonParseException)2 NonBlockingJsonParserBase (com.fasterxml.jackson.core.json.async.NonBlockingJsonParserBase)2 ByteQuadsCanonicalizer (com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2