Search in sources :

Example 41 with JsonFactory

use of com.fasterxml.jackson.core.json.JsonFactory in project jackson-core by FasterXML.

the class AsyncSimpleNestedTest method testStuffInObject.

/*
    /**********************************************************************
    /* Test methods, success
    /**********************************************************************
     */
public void testStuffInObject() throws Exception {
    byte[] data = _jsonDoc(aposToQuotes("{'foobar':[1,2,-999],'emptyObject':{},'emptyArray':[], 'other':{'':null} }"));
    JsonFactory f = JSON_F;
    _testStuffInObject(f, data, 0, 100);
    _testStuffInObject(f, data, 0, 3);
    _testStuffInObject(f, data, 0, 1);
    _testStuffInObject(f, data, 1, 100);
    _testStuffInObject(f, data, 1, 3);
    _testStuffInObject(f, data, 1, 1);
}
Also used : JsonFactory(com.fasterxml.jackson.core.json.JsonFactory)

Example 42 with JsonFactory

use of com.fasterxml.jackson.core.json.JsonFactory in project jackson-core by FasterXML.

the class AsyncSimpleNestedTest method testStuffInArray2.

public void testStuffInArray2() throws Exception {
    byte[] data = _jsonDoc(aposToQuotes(String.format("[{'%s':true},{'%s':false},{'%s':true},{'%s':false}]", SHORT_NAME, LONG_NAME, LONG_NAME, SHORT_NAME)));
    JsonFactory f = JSON_F;
    _testStuffInArray2(f, data, 0, 100);
    _testStuffInArray2(f, data, 0, 3);
    _testStuffInArray2(f, data, 0, 1);
    _testStuffInArray2(f, data, 3, 100);
    _testStuffInArray2(f, data, 3, 3);
    _testStuffInArray2(f, data, 3, 1);
}
Also used : JsonFactory(com.fasterxml.jackson.core.json.JsonFactory)

Example 43 with JsonFactory

use of com.fasterxml.jackson.core.json.JsonFactory in project jackson-core by FasterXML.

the class AsyncSimpleNestedTest method testMismatchedObject.

public void testMismatchedObject() throws Exception {
    byte[] data = _jsonDoc(aposToQuotes("{ ]"));
    JsonFactory f = JSON_F;
    _testMismatchedObject(f, data, 0, 99);
    _testMismatchedObject(f, data, 0, 3);
    _testMismatchedObject(f, data, 0, 2);
    _testMismatchedObject(f, data, 0, 1);
    _testMismatchedObject(f, data, 1, 3);
    _testMismatchedObject(f, data, 1, 1);
}
Also used : JsonFactory(com.fasterxml.jackson.core.json.JsonFactory)

Example 44 with JsonFactory

use of com.fasterxml.jackson.core.json.JsonFactory in project jackson-core by FasterXML.

the class AsyncStringArrayTest method testShortAsciiStrings.

public void testShortAsciiStrings() throws IOException {
    final String[] input = new String[] { "Test", "", "1", // 60 chars, to stay short
    String.format("%s%s%s%s%s%s%s", str0to9, str0to9, str0to9, str0to9, str0to9, str0to9, str0to9), // plus let's do back refs:
    "Test", "124" };
    JsonFactory f = JSON_F;
    byte[] data = _stringDoc(f, input);
    // first: require headers, no offsets
    _testStrings(f, input, data, 0, 100);
    _testStrings(f, input, data, 0, 3);
    _testStrings(f, input, data, 0, 1);
    // then with some offsets:
    _testStrings(f, input, data, 1, 100);
    _testStrings(f, input, data, 1, 3);
    _testStrings(f, input, data, 1, 1);
}
Also used : JsonFactory(com.fasterxml.jackson.core.json.JsonFactory)

Example 45 with JsonFactory

use of com.fasterxml.jackson.core.json.JsonFactory in project jackson-core by FasterXML.

the class AsyncStringArrayTest method testLongUnicodeStrings.

public void testLongUnicodeStrings() throws IOException {
    // ~100 chars for long(er) content
    final String LONG = String.format("%s %s %s %s %s%s %s %s %s %s %s %s%c %s", str0to9, str0to9, UNICODE_2BYTES, str0to9, UNICODE_3BYTES, UNICODE_3BYTES, str0to9, str0to9, UNICODE_3BYTES, str0to9, str0to9, UNICODE_2BYTES, UNICODE_2BYTES, str0to9);
    final String[] input = new String[] { // let's vary length slightly to try to trigger edge conditions
    LONG, LONG + ".", LONG + "..", LONG + "..." };
    JsonFactory f = JSON_F;
    byte[] data = _stringDoc(f, input);
    // first: require headers, no offsets
    _testStrings(f, input, data, 0, 9000);
    _testStrings(f, input, data, 0, 3);
    _testStrings(f, input, data, 0, 1);
    // then with some offsets:
    _testStrings(f, input, data, 1, 9000);
    _testStrings(f, input, data, 1, 3);
    _testStrings(f, input, data, 1, 1);
}
Also used : JsonFactory(com.fasterxml.jackson.core.json.JsonFactory)

Aggregations

JsonFactory (com.fasterxml.jackson.core.json.JsonFactory)137 AsyncReaderWrapper (com.fasterxml.jackson.core.testsupport.AsyncReaderWrapper)5 DefaultPrettyPrinter (com.fasterxml.jackson.core.util.DefaultPrettyPrinter)3 JsonParser (com.fasterxml.jackson.core.JsonParser)2 SerializedString (com.fasterxml.jackson.core.io.SerializedString)2 NonBlockingJsonParserBase (com.fasterxml.jackson.core.json.async.NonBlockingJsonParserBase)2 ByteQuadsCanonicalizer (com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer)2 MinimalPrettyPrinter (com.fasterxml.jackson.core.util.MinimalPrettyPrinter)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 BigDecimal (java.math.BigDecimal)2 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)1 StringWriter (java.io.StringWriter)1 Field (java.lang.reflect.Field)1 BigInteger (java.math.BigInteger)1 HashSet (java.util.HashSet)1