use of com.fasterxml.jackson.core.json.JsonFactory in project jackson-core by FasterXML.
the class AsyncCommentParsingTest method testYAMLCommentsEnabled.
public void testYAMLCommentsEnabled() throws Exception {
JsonFactory f = JsonFactory.builder().enable(JsonParser.Feature.ALLOW_YAML_COMMENTS).build();
_testYAMLComments(f, 99);
_testYAMLComments(f, 3);
_testYAMLComments(f, 1);
_testCommentsBeforePropValue(f, "# foo\n", 99);
_testCommentsBeforePropValue(f, "# foo\n", 3);
_testCommentsBeforePropValue(f, "# foo\n", 1);
_testCommentsBetweenArrayValues(f, "# foo\n", 99);
_testCommentsBetweenArrayValues(f, "# foo\n", 3);
_testCommentsBetweenArrayValues(f, "# foo\n", 1);
}
use of com.fasterxml.jackson.core.json.JsonFactory in project jackson-core by FasterXML.
the class AsyncCommentParsingTest method testCppCommentsEnabled.
public void testCppCommentsEnabled() throws Exception {
JsonFactory f = JsonFactory.builder().enable(JsonParser.Feature.ALLOW_COMMENTS).build();
final String COMMENT = "// foo\n";
_testCommentsBeforePropValue(f, COMMENT, 99);
_testCommentsBeforePropValue(f, COMMENT, 3);
_testCommentsBeforePropValue(f, COMMENT, 1);
}
use of com.fasterxml.jackson.core.json.JsonFactory in project jackson-core by FasterXML.
the class JsonParserTest method _testIntern.
private void _testIntern(boolean useStream, boolean enableIntern, String expName) throws IOException {
JsonFactory f = JsonFactory.builder().configure(JsonFactory.Feature.INTERN_FIELD_NAMES, enableIntern).build();
assertEquals(enableIntern, f.isEnabled(JsonFactory.Feature.INTERN_FIELD_NAMES));
final String JSON = "{ \"" + expName + "\" : 1}";
JsonParser p = useStream ? createParserUsingStream(f, JSON, "UTF-8") : createParserUsingReader(f, JSON);
assertToken(JsonToken.START_OBJECT, p.nextToken());
assertToken(JsonToken.FIELD_NAME, p.nextToken());
// needs to be same of cours
String actName = p.currentName();
assertEquals(expName, actName);
if (enableIntern) {
assertSame(expName, actName);
} else {
assertNotSame(expName, actName);
}
p.close();
}
use of com.fasterxml.jackson.core.json.JsonFactory in project jackson-core by FasterXML.
the class ParserDupHandlingTest method testSimpleDupsChars.
public void testSimpleDupsChars() throws Exception {
JsonFactory nonDupF = new JsonFactory();
JsonFactory dupF = JsonFactory.builder().enable(JsonParser.Feature.STRICT_DUPLICATE_DETECTION).build();
for (String doc : DUP_DOCS) {
_testSimpleDupsFail(doc, dupF, MODE_READER, "a", false);
_testSimpleDupsFail(doc, nonDupF, MODE_READER, "a", true);
}
}
use of com.fasterxml.jackson.core.json.JsonFactory in project jackson-core by FasterXML.
the class ParserDupHandlingTest method testSimpleDupsBytes.
public void testSimpleDupsBytes() throws Exception {
JsonFactory nonDupF = new JsonFactory();
JsonFactory dupF = JsonFactory.builder().enable(JsonParser.Feature.STRICT_DUPLICATE_DETECTION).build();
for (String doc : DUP_DOCS) {
// First, with static setting
_testSimpleDupsFail(doc, dupF, MODE_INPUT_STREAM, "a", false);
// and then dynamic
_testSimpleDupsFail(doc, nonDupF, MODE_INPUT_STREAM, "a", true);
_testSimpleDupsFail(doc, dupF, MODE_INPUT_STREAM_THROTTLED, "a", false);
_testSimpleDupsFail(doc, nonDupF, MODE_INPUT_STREAM_THROTTLED, "a", true);
}
}
Aggregations