@BeforeEach @SuppressWarnings("unchecked") public void setUp() { initMocks(this); final Map<String, String> namespaces = new HashMap<>(); namespaces.put("dc", DCTerms.NS); namespaces.put("rdf", RDF.uri); namespaces.put("dcmitype", "http://purl.org/dc/dcmitype/"); when(mockNamespaceService.getNamespaces()).thenReturn(namespaces); service = new HtmlSerializer(mockNamespaceService); }
@Test public void testHtmlSerializer4() throws Exception { final String path = getClass().getResource("/resource-test.mustache").toURI().getPath(); final ByteArrayOutputStream out = new ByteArrayOutputStream(); final RDFaWriterService service4 = new HtmlSerializer(mockNamespaceService, path, "//www.trellisldp.org/assets/css/trellis.css", "", null); service4.write(getTriples(), out, "http://example.com/"); assertAll("HTML check", checkHtmlFromTriples(new String(out.toByteArray(), UTF_8))); }
@Test public void testHtmlSerializer5() throws Exception { final String path = getClass().getResource("/resource-test.mustache").toURI().getPath(); final ByteArrayOutputStream out = new ByteArrayOutputStream(); final RDFaWriterService service4 = new HtmlSerializer(new NoopNamespaceService(), path, "//www.trellisldp.org/assets/css/trellis.css", "", null); service4.write(getTriples2(), out, "http://example.com/"); assertAll("HTML check", checkHtmlWithoutNamespaces(new String(out.toByteArray(), UTF_8))); }
@Test public void testDefaultSerializer() { final RDFaWriterService svc = new HtmlSerializer(); final ByteArrayOutputStream out = new ByteArrayOutputStream(); svc.write(getTriples2(), out, "http://example.com/"); assertAll("HTML check", checkHtmlWithoutNamespaces(new String(out.toByteArray(), UTF_8))); }
@Test public void testHtmlSerializer3() { final ByteArrayOutputStream out = new ByteArrayOutputStream(); final RDFaWriterService service4 = new HtmlSerializer(mockNamespaceService, "/resource-test.mustache", "//www.trellisldp.org/assets/css/trellis.css", "", "//www.trellisldp.org/assets/img/trellis.png"); service4.write(getTriples(), out, "http://example.com/"); assertAll("HTML check", checkHtmlFromTriples(new String(out.toByteArray(), UTF_8))); }
private static IOService buildIoService(final AppConfiguration config) { final long cacheSize = config.getJsonld().getCacheSize(); final long hours = config.getJsonld().getCacheExpireHours(); final Cache<String, String> cache = newBuilder().maximumSize(cacheSize).expireAfterAccess(hours, HOURS).build(); final TrellisCache<String, String> profileCache = new TrellisCache<>(cache); final NamespaceService namespaceService = new NamespacesJsonContext(config.getNamespaces()); final RDFaWriterService htmlSerializer = new HtmlSerializer(namespaceService, config.getAssets().getTemplate(), config.getAssets().getCss(), config.getAssets().getJs(), config.getAssets().getIcon()); return new JenaIOService(namespaceService, htmlSerializer, profileCache, config.getJsonld().getContextWhitelist(), config.getJsonld().getContextDomainWhitelist()); }