SerializingProvider provider = new RdfJsonSerializingProvider();
ByteArrayOutputStream serializedGraph = new ByteArrayOutputStream();
long start = System.currentTimeMillis();
provider.serialize(serializedGraph, mGraph, "application/rdf+json");
System.out.println("Serialized " + mGraph.size() + " Triples in " + (System.currentTimeMillis() - start) + " ms");
ParsingProvider parsingProvider = new RdfJsonParsingProvider();
ByteArrayInputStream jsonIn = new ByteArrayInputStream(serializedGraph.toByteArray());
MGraph parsedMGraph = new SimpleMGraph();
parsingProvider.parse(parsedMGraph, jsonIn, "application/rdf+json", null);
Assert.assertEquals(originalSize, parsedMGraph.size());
sortedTriples = parsedMGraph.toArray(new Triple[parsedMGraph.size()]);
Arrays.sort(sortedTriples, RdfJsonSerializingProvider.SUBJECT_COMPARATOR);
Assert.assertEquals(mGraph.getGraph(), parsedMGraph.getGraph());
}