use of com.fasterxml.jackson.core.json.JsonFactory in project jackson-core by FasterXML.
the class NumberParsingTest method testLongNumbers2.
// and alternate take on for #157 (with negative num)
public void testLongNumbers2() throws Exception {
StringBuilder input = new StringBuilder();
// test this with negative
input.append('-');
for (int i = 0; i < 2100; i++) {
input.append(1);
}
final String DOC = input.toString();
JsonFactory f = new JsonFactory();
_testIssue160LongNumbers(f, DOC, false);
_testIssue160LongNumbers(f, DOC, true);
}
use of com.fasterxml.jackson.core.json.JsonFactory in project jackson-core by FasterXML.
the class NumberParsingTest method testLongNumbers.
// [jackson-core#157]
public void testLongNumbers() throws Exception {
StringBuilder sb = new StringBuilder(9000);
for (int i = 0; i < 9000; ++i) {
sb.append('9');
}
String NUM = sb.toString();
// force use of new factory, just in case (might still recycle same buffers tho?)
JsonFactory f = new JsonFactory();
_testLongNumbers(f, NUM, false);
_testLongNumbers(f, NUM, true);
}
use of com.fasterxml.jackson.core.json.JsonFactory in project jackson-core by FasterXML.
the class ParserSymbolHandlingTest method testSymbolsWithNullBytes.
// For [core#148]
public void testSymbolsWithNullBytes() throws Exception {
JsonFactory f = new JsonFactory();
_testSymbolsWithNull(f, true);
// and repeat with same factory, just for fun, and to ensure symbol table is fine
_testSymbolsWithNull(f, true);
}
use of com.fasterxml.jackson.core.json.JsonFactory in project jackson-core by FasterXML.
the class ParserSymbolHandlingTest method testSymbolsWithNullChars.
// For [core#148]
public void testSymbolsWithNullChars() throws Exception {
JsonFactory f = new JsonFactory();
_testSymbolsWithNull(f, false);
_testSymbolsWithNull(f, false);
}
use of com.fasterxml.jackson.core.json.JsonFactory in project jackson-core by FasterXML.
the class TestByteBasedSymbols method testSharedSymbols.
/**
* This unit test checks that [JACKSON-5] is fixed; if not, a
* symbol table corruption should result in odd problems.
*/
public void testSharedSymbols() throws Exception {
// MUST share a single json factory
JsonFactory jf = new JsonFactory();
/* First things first: parse a dummy doc to populate
* shared symbol table with some stuff
*/
String DOC0 = "{ \"a\" : 1, \"x\" : [ ] }";
JsonParser jp0 = createParser(jf, DOC0);
/* Important: don't close, don't traverse past end.
* This is needed to create partial still-in-use symbol
* table...
*/
while (jp0.nextToken() != JsonToken.START_ARRAY) {
}
String doc1 = createDoc(FIELD_NAMES, true);
String doc2 = createDoc(FIELD_NAMES, false);
// Let's run it twice... shouldn't matter
for (int x = 0; x < 2; ++x) {
JsonParser jp1 = createParser(jf, doc1);
JsonParser jp2 = createParser(jf, doc2);
assertToken(JsonToken.START_OBJECT, jp1.nextToken());
assertToken(JsonToken.START_OBJECT, jp2.nextToken());
int len = FIELD_NAMES.length;
for (int i = 0; i < len; ++i) {
assertToken(JsonToken.FIELD_NAME, jp1.nextToken());
assertToken(JsonToken.FIELD_NAME, jp2.nextToken());
assertEquals(FIELD_NAMES[i], jp1.currentName());
assertEquals(FIELD_NAMES[len - (i + 1)], jp2.currentName());
assertToken(JsonToken.VALUE_NUMBER_INT, jp1.nextToken());
assertToken(JsonToken.VALUE_NUMBER_INT, jp2.nextToken());
assertEquals(i, jp1.getIntValue());
assertEquals(i, jp2.getIntValue());
}
assertToken(JsonToken.END_OBJECT, jp1.nextToken());
assertToken(JsonToken.END_OBJECT, jp2.nextToken());
jp1.close();
jp2.close();
}
jp0.close();
}
Aggregations