ResourceResolver { @Deprecated public InputStream retrieveStyleSheet(String uri) throws IOException { return retriever.getInputStreamByUrl(uriResolver.resolveAgainstBaseUri(uri)); } ResourceResolver(String baseUri);  ResourceResolver(String baseUri, IResourceRetriever retriever); IResourceRetriever getRetriever(); ResourceResolver setRetriever(IResourceRetriever retriever); @Deprecated PdfImageXObject retrieveImage(String src); PdfXObject retrieveImageExtended(String src); @Deprecated InputStream retrieveStyleSheet(String uri); @Deprecated byte[] retrieveStream(String src); byte[] retrieveBytesFromResource(String src); InputStream retrieveResourceAsInputStream(String src); boolean isDataSrc(String src); URL resolveAgainstBaseUri(String uri); void resetCache(); @Deprecated boolean isImageTypeSupportedByImageDataFactory(String src); static final String BASE64IDENTIFIER; static final String DATA_SCHEMA_PREFIX; }
@Test public void retrieveStyleSheetByMalformedResourceNameTest() throws IOException { junitExpectedException.expect(IOException.class); String fileName = "retrieveStyl eSheetTest.css"; ResourceResolver resourceResolver = new ResourceResolver(baseUri); resourceResolver.retrieveStyleSheet(fileName); }
@Test public void malformedResourceNameTest07() throws IOException { String fileName = "%23%5B%5D@!$&'()+,;=._~-/styles09.css"; InputStream expected = new FileInputStream(baseUri + "#[]@!$&'()+,;=._~-/styles09.css"); ResourceResolver resourceResolver = new ResourceResolver(baseUri); InputStream stream = resourceResolver.retrieveStyleSheet(fileName); Assert.assertNotNull(stream); Assert.assertEquals(expected.read(), stream.read()); }
@Test public void retrieveStyleSheetTest() throws IOException { String fileName = "retrieveStyleSheetTest.css"; InputStream expected = new FileInputStream(baseUri + fileName); ResourceResolver resourceResolver = new ResourceResolver(baseUri); InputStream stream = resourceResolver.retrieveStyleSheet(fileName); Assert.assertNotNull(stream); Assert.assertEquals(expected.read(), stream.read()); }
@Test public void retrieveStyleSheetAbsolutePathTest() throws IOException { String fileName = "retrieveStyleSheetTest.css"; String absolutePath = Paths.get(baseUri, fileName).toFile().getAbsolutePath(); ResourceResolver resourceResolver = new ResourceResolver(baseUri); try (InputStream stream = resourceResolver.retrieveStyleSheet(absolutePath); InputStream expected = new FileInputStream(absolutePath);) { Assert.assertNotNull(stream); Assert.assertEquals(expected.read(), stream.read()); } }
@Test public void retrieveStyleSheetFileUrlTest() throws IOException { String fileName = "retrieveStyleSheetTest.css"; URL url = Paths.get(baseUri, fileName).toUri().toURL(); String fileUrlString = url.toExternalForm(); ResourceResolver resourceResolver = new ResourceResolver(baseUri); try (InputStream stream = resourceResolver.retrieveStyleSheet(fileUrlString); InputStream expected = url.openStream()) { Assert.assertNotNull(stream); Assert.assertEquals(expected.read(), stream.read()); } }