/** * Create a serialization service. * * @param namespaceService the namespace service * @param htmlSerializer the HTML serializer service */ public JenaIOService(final NamespaceService namespaceService, final RDFaWriterService htmlSerializer) { this(namespaceService, htmlSerializer, new NoopProfileCache()); }
/** * Create a serialization service. * * @param namespaceService the namespace service * @param htmlSerializer the HTML serializer service */ public JenaIOService(final NamespaceService namespaceService, final RDFaWriterService htmlSerializer) { this(namespaceService, htmlSerializer, new NoopProfileCache()); }
@Test public void testJsonLdCustomSerializerNoopCache() throws UnsupportedEncodingException { final ByteArrayOutputStream out = new ByteArrayOutputStream(); final IOService svc = new JenaIOService(mockNamespaceService, null, new NoopProfileCache(), "http://www.w3.org/ns/anno.jsonld,,,", "http://www.trellisldp.org/ns/"); svc.write(getTriples(), out, JSONLD, rdf.createIRI("http://www.w3.org/ns/anno.jsonld")); final String output = out.toString("UTF-8"); final Graph graph = rdf.createGraph(); service.read(new ByteArrayInputStream(output.getBytes(UTF_8)), JSONLD, null).forEach(graph::add); assertTrue(validateGraph(graph), "Not all triples present in output graph!"); }
@Test public void testPassthroughCache() { final List<String> list = new CopyOnWriteArrayList<>(); final Function<String, String> mapper = key -> { list.add(key); return key + "-some-suffix"; }; final CacheService<String, String> cache = new NoopProfileCache(); assertEquals("one-some-suffix", cache.get("one", mapper), "Cache response didn't match!"); assertEquals("two-some-suffix", cache.get("two", mapper), "Cache response didn't match!"); assertEquals("one-some-suffix", cache.get("one", mapper), "Cache response didn't match!"); assertEquals(3L, list.size(), "Incorrect invocation count!"); } }