private void testJenaWriterRdfJson()
{
Model results = FileManager.get().loadModel(output) ;
RDFWriter writer = new JenaWriterRdfJson() ;
ByteArrayOutputStream baos = new ByteArrayOutputStream() ;
writer.write(results, baos, baseIRI) ;
// Parse the JSON back to make sure we always write valid JSON
JSON.parse(new ByteArrayInputStream(baos.toByteArray())) ;
InputStream in = new ByteArrayInputStream(baos.toByteArray()) ;
Model model = ModelFactory.createDefaultModel() ;
RDFReader reader = new JenaReaderRdfJson() ;
try {
if ( baseIRI != null )
{
Reader r = PeekReader.makeUTF8(in) ;
reader.read(model, r, baseIRI) ;
}
else
reader.read(model, in, null) ;
boolean b = model.isIsomorphicWith(results) ;
if ( !b )
{
write ( model, results ) ;
System.out.println("---- Parsed");
// model.write(System.out, "RDF/JSON") ;
writer.write(model, System.out, baseIRI) ; // for now, until the plumbing with Jena gets released. See JENA-135
System.out.println("---- Expected");
// results.write(System.out, "RDF/JSON") ;
writer.write(results, System.out, baseIRI) ;
System.out.println("--------");
}
assertTrue("Models not isomorphic", b) ;
} catch (RiotParseException ex)