ResourceResolver { @Deprecated public byte[] retrieveStream(String src) { try { return retrieveBytesFromResource(src); } catch (Exception e) { logger.error(MessageFormatUtil.format(LogMessageConstant.UNABLE_TO_RETRIEVE_STREAM_WITH_GIVEN_BASE_URI, uriResolver.getBaseUri(), src), e); return null; } } 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 @LogMessages(messages = @LogMessage(messageTemplate = LogMessageConstant.UNABLE_TO_RETRIEVE_STREAM_WITH_GIVEN_BASE_URI, logLevel = LogLevelConstants.ERROR)) public void retrieveStreamByMalformedResourceNameTest() { String fileName = "resourceResolverTest .png"; ResourceResolver resourceResolver = new ResourceResolver(baseUri); byte[] bytes = resourceResolver.retrieveStream(fileName); Assert.assertNull(bytes); }
@Test public void retrieveStreamPngImageTest() throws IOException { String fileName = "resourceResolverTest.png"; ResourceResolver resourceResolver = new ResourceResolver(baseUri); byte[] expected = Files.readAllBytes(new File(baseUri + fileName).toPath()); byte[] stream = resourceResolver.retrieveStream(fileName); Assert.assertNotNull(resourceResolver.retrieveStream(fileName)); Assert.assertEquals(expected.length, stream.length); }