use of com.fasterxml.jackson.core.json.JsonFactory in project jackson-core by FasterXML.
the class TestByteBasedSymbols method testIssue207.
// as per name, for [core#207]
public void testIssue207() throws Exception {
ByteQuadsCanonicalizer nc = ByteQuadsCanonicalizer.createRoot(-523743345);
Field byteSymbolCanonicalizerField = JsonFactory.class.getDeclaredField("_byteSymbolCanonicalizer");
byteSymbolCanonicalizerField.setAccessible(true);
JsonFactory jsonF = new JsonFactory();
byteSymbolCanonicalizerField.set(jsonF, nc);
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("{\n");
stringBuilder.append(" \"expectedGCperPosition\": null");
for (int i = 0; i < 60; ++i) {
stringBuilder.append(",\n \"").append(i + 1).append("\": null");
}
stringBuilder.append("\n}");
JsonParser p = jsonF.createParser(ObjectReadContext.empty(), stringBuilder.toString().getBytes("UTF-8"));
while (p.nextToken() != null) {
}
p.close();
}
use of com.fasterxml.jackson.core.json.JsonFactory in project jackson-core by FasterXML.
the class TestSymbolTables method testShortNameCollisionsViaParser.
// [core#191]: similarly, but for "short" symbols:
public void testShortNameCollisionsViaParser() throws Exception {
JsonFactory f = new JsonFactory();
String json = _shortDoc191();
JsonParser p;
// First: ensure that char-based is fine
p = f.createParser(ObjectReadContext.empty(), json);
while (p.nextToken() != null) {
}
p.close();
// and then that byte-based
p = f.createParser(ObjectReadContext.empty(), json.getBytes("UTF-8"));
while (p.nextToken() != null) {
}
p.close();
}
use of com.fasterxml.jackson.core.json.JsonFactory in project jackson-core by FasterXML.
the class AsyncNonStdNumbersTest method testAllowInf.
public void testAllowInf() throws Exception {
JsonFactory f = JsonFactory.builder().enable(JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS).build();
String JSON = "[ Infinity, +Infinity, -Infinity ]";
_testAllowInf(f, JSON, 99);
_testAllowInf(f, JSON, 5);
_testAllowInf(f, JSON, 3);
_testAllowInf(f, JSON, 2);
_testAllowInf(f, JSON, 1);
JSON = "[Infinity,+Infinity,-Infinity]";
_testAllowInf(f, JSON, 99);
_testAllowInf(f, JSON, 1);
JSON = "[Infinity , +Infinity , -Infinity]";
_testAllowInf(f, JSON, 99);
_testAllowInf(f, JSON, 1);
}
use of com.fasterxml.jackson.core.json.JsonFactory in project jackson-core by FasterXML.
the class AsyncParserNamesTest method testSymbolTableWithIntern.
public void testSymbolTableWithIntern() throws IOException {
JsonFactory internF = JsonFactory.builder().enable(TokenStreamFactory.Feature.INTERN_FIELD_NAMES).build();
final String STR1 = "a";
byte[] doc = _jsonDoc("{ " + quote(STR1) + ":1, \"foobar\":2, \"longername\":3 }");
AsyncReaderWrapper p = asyncForBytes(internF, 5, doc, 0);
final ByteQuadsCanonicalizer symbols1 = ((NonBlockingJsonParserBase) p.parser()).symbolTableForTests();
assertEquals(0, symbols1.size());
assertEquals(JsonToken.START_OBJECT, p.nextToken());
assertEquals(JsonToken.FIELD_NAME, p.nextToken());
assertSame(STR1, p.currentName());
assertEquals(1, symbols1.size());
assertEquals(JsonToken.VALUE_NUMBER_INT, p.nextToken());
assertEquals(JsonToken.FIELD_NAME, p.nextToken());
assertSame("foobar", p.currentName());
assertEquals(2, symbols1.size());
assertEquals(JsonToken.VALUE_NUMBER_INT, p.nextToken());
assertEquals(JsonToken.FIELD_NAME, p.nextToken());
assertSame("longername", p.currentName());
assertEquals(3, symbols1.size());
assertEquals(JsonToken.VALUE_NUMBER_INT, p.nextToken());
assertEquals(JsonToken.END_OBJECT, p.nextToken());
assertNull(p.nextToken());
assertEquals(3, symbols1.size());
p.close();
}
use of com.fasterxml.jackson.core.json.JsonFactory in project jackson-core by FasterXML.
the class AsyncRootValuesTest method _testTokenRootTokens.
private void _testTokenRootTokens(JsonToken expToken, String doc) throws Exception {
byte[] input = _jsonDoc(doc);
JsonFactory f = JSON_F;
_testTokenRootTokens(expToken, f, input, 0, 90);
_testTokenRootTokens(expToken, f, input, 0, 3);
_testTokenRootTokens(expToken, f, input, 0, 2);
_testTokenRootTokens(expToken, f, input, 0, 1);
_testTokenRootTokens(expToken, f, input, 1, 90);
_testTokenRootTokens(expToken, f, input, 1, 3);
_testTokenRootTokens(expToken, f, input, 1, 1);
}
Aggregations