final ParserConfig config = new ParserConfig();
config.set(BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES, true);
config.set(BasicParserSettings.FAIL_ON_UNKNOWN_LANGUAGES, true);
rdfParser.setParserConfig(config);
rdfParser.setValueFactory(vf);
final Model model = new LinkedHashModel();
rdfParser.setRDFHandler(new StatementCollector(model));
rdfParser.parse(in, "foo:bar");
assertEquals("Unexpected number of statements", 6, model.size());
final Model bnodeModel = model.filter(null, uri1,
vf.createLiteral(plainLit.getLabel(), XMLSchema.STRING));
assertEquals("Blank node was not round-tripped", 1, bnodeModel.size());
assertTrue("Blank node was not round-tripped as a blank node", bnodeModel.subjects()
.iterator().next() instanceof BNode);
if (rdfParser.getRDFFormat().supportsContexts()) {
assertTrue(model.contains(st2));
} else {
assertTrue(model.contains(vf.createStatement(uri1, uri2, langLit)));
}
assertTrue(model.contains(st3));
assertTrue(
"missing statement with literal ending on newline",
model.contains(vf.createStatement(uri1, uri2,
vf.createLiteral(litWithNewline.getLabel(), XMLSchema.STRING))));
assertTrue(
"missing statement with single quotes",
model.contains(vf.createStatement(uri1, uri2,
vf.createLiteral(litWithSingleQuotes.getLabel(), XMLSchema.STRING))));
assertTrue(
"missing statement with single quotes",
model.contains(vf.createStatement(uri1, uri2,
vf.createLiteral(litWithDoubleQuotes.getLabel(), XMLSchema.STRING))));
}