use of com.fasterxml.jackson.core.json.JsonFactory in project jackson-core by FasterXML.
the class AsyncStringArrayTest method testLongAsciiStrings.
public void testLongAsciiStrings() throws IOException {
final String[] input = new String[] { // ~100 chars for long(er) content
String.format("%s %s %s %s %s %s %s %s %s %s %s %s", str0to9, str0to9, "...", str0to9, "/", str0to9, str0to9, "", str0to9, str0to9, "...", str0to9), LONG_ASCII };
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, 1);
_testStrings(f, input, data, 0, 3);
// then with some offsets:
_testStrings(f, input, data, 1, 9000);
_testStrings(f, input, data, 1, 3);
_testStrings(f, input, data, 1, 1);
}
use of com.fasterxml.jackson.core.json.JsonFactory in project jackson-core by FasterXML.
the class AsyncNonStdParsingTest method testNonStandardNameChars.
public void testNonStandardNameChars() throws Exception {
JsonFactory f = JsonFactory.builder().enable(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES).build();
_testNonStandardNameChars(f, 0, 99);
_testNonStandardNameChars(f, 0, 6);
_testNonStandardNameChars(f, 0, 3);
_testNonStandardNameChars(f, 0, 1);
_testNonStandardNameChars(f, 1, 99);
_testNonStandardNameChars(f, 2, 1);
}
use of com.fasterxml.jackson.core.json.JsonFactory in project jackson-core by FasterXML.
the class AsyncNonStdParsingTest method testSingleQuotesEscaped.
// test to verify that we implicitly allow escaping of apostrophe
public void testSingleQuotesEscaped() throws Exception {
JsonFactory f = JsonFactory.builder().enable(JsonParser.Feature.ALLOW_SINGLE_QUOTES).build();
_testSingleQuotesEscaped(f, 0, 99);
_testSingleQuotesEscaped(f, 0, 5);
_testSingleQuotesEscaped(f, 0, 3);
_testSingleQuotesEscaped(f, 0, 1);
_testSingleQuotesEscaped(f, 1, 99);
_testSingleQuotesEscaped(f, 1, 1);
}
use of com.fasterxml.jackson.core.json.JsonFactory in project jackson-core by FasterXML.
the class AsyncNonStdParsingTest method testAposQuotingEnabled.
/**
* Test to verify optional handling of
* single quotes, to allow handling invalid (but, alas, common)
* JSON.
*/
public void testAposQuotingEnabled() throws Exception {
JsonFactory f = JsonFactory.builder().enable(JsonParser.Feature.ALLOW_SINGLE_QUOTES).build();
_testAposQuotingEnabled(f, 0, 99);
_testAposQuotingEnabled(f, 0, 5);
_testAposQuotingEnabled(f, 0, 3);
_testAposQuotingEnabled(f, 0, 2);
_testAposQuotingEnabled(f, 0, 1);
_testAposQuotingEnabled(f, 1, 99);
_testAposQuotingEnabled(f, 2, 1);
_testAposQuotingEnabled(f, 1, 1);
}
use of com.fasterxml.jackson.core.json.JsonFactory in project jackson-core by FasterXML.
the class AsyncNonStdParsingTest method _testNonStandarBackslashQuoting.
private void _testNonStandarBackslashQuoting(int offset, int readSize) throws Exception {
// first: verify that we get an exception
JsonFactory f = new JsonFactory();
assertFalse(f.isEnabled(JsonParser.Feature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER));
final String JSON = quote("\\'");
AsyncReaderWrapper p = createParser(f, JSON, offset, readSize);
try {
p.nextToken();
p.currentText();
fail("Should have thrown an exception for doc <" + JSON + ">");
} catch (JsonParseException e) {
verifyException(e, "unrecognized character escape");
} finally {
p.close();
}
// and then verify it's ok...
f = f.rebuild().enable(JsonParser.Feature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER).build();
assertTrue(f.isEnabled(JsonParser.Feature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER));
p = createParser(f, JSON, offset, readSize);
assertToken(JsonToken.VALUE_STRING, p.nextToken());
assertEquals("'", p.currentText());
p.close();
}
Aggregations