@Test public void parserTest() { final InputStream in = getClass().getClassLoader().getResourceAsStream("testfiles/product.jsonld"); SimpleMGraph graph = new SimpleMGraph(); parser.parse(graph, in, "application/ld+json"); Assert.assertEquals(13, graph.size()); }
@Test public void serializerTest() { ByteArrayOutputStream out = new ByteArrayOutputStream(); serializer.serialize(out, rdfData, "application/ld+json"); byte[] data = out.toByteArray(); log.info("Serialized Graph: \n {}", new String(data, UTF8)); // Now we reparse the graph to validate it was serialized correctly SimpleMGraph reparsed = new SimpleMGraph(); parser.parse(reparsed, new ByteArrayInputStream(data), "application/ld+json"); Assert.assertEquals(7, reparsed.size()); for (Triple t : rdfData) { Assert.assertTrue(reparsed.contains(t)); } }