rdfWriter.endRDF();
StringReader reader = new StringReader(writer.toString());
RDFParser rdfParser = rdfParserFactory.getParser();
rdfParser.setValueFactory(vf);
StatementCollector stCollector = new StatementCollector();
rdfParser.setRDFHandler(stCollector);
try {
rdfParser.parse(reader, "foo:bar");
}
catch (RDFParseException e) {
System.err.println("Failed to parse generated RDF document:");
System.err.println(writer.toString());
throw e;
}
Collection<Statement> statements = stCollector.getStatements();
assertEquals("Unexpected number of statements", 1, statements.size());
Statement parsedSt = statements.iterator().next();
assertEquals("Written and parsed statements are not equal", st, parsedSt);
}