ResourceResolver { public PdfXObject retrieveImageExtended(String src) { if (src != null) { if (isContains64Mark(src)) { PdfXObject imageXObject = tryResolveBase64ImageSource(src); if (imageXObject != null) { return imageXObject; } } PdfXObject imageXObject = tryResolveUrlImageSource(src); if (imageXObject != null) { return imageXObject; } } logger.error(MessageFormatUtil.format(LogMessageConstant.UNABLE_TO_RETRIEVE_IMAGE_WITH_GIVEN_BASE_URI, uriResolver.getBaseUri(), src)); 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_IMAGE_WITH_GIVEN_BASE_URI, logLevel = LogLevelConstants.ERROR)) public void retrieveImageExtendedByMalformedResourceNameTest() { String fileName = "retrieveStyl eSheetTest.css"; ResourceResolver resourceResolver = new ResourceResolver(baseUri); PdfXObject pdfXObject = resourceResolver.retrieveImageExtended(fileName); Assert.assertNull(pdfXObject); }
@Test public void retrieveImageExtendedBase64Test() { ResourceResolver resourceResolver = new ResourceResolver(baseUri); PdfXObject image = resourceResolver.retrieveImageExtended(bLogo); Assert.assertNotNull(image); }
@Test @LogMessages(messages = @LogMessage(messageTemplate = LogMessageConstant.UNABLE_TO_RETRIEVE_IMAGE_WITH_GIVEN_BASE_URI)) public void retrieveImageExtendedIncorrectBase64Test() { ResourceResolver resourceResolver = new ResourceResolver(baseUri); PdfXObject image = resourceResolver.retrieveImageExtended(bLogoCorruptedData); Assert.assertNull(image); }
@Test @LogMessages(messages = @LogMessage(messageTemplate = LogMessageConstant.UNABLE_TO_RETRIEVE_IMAGE_WITH_GIVEN_BASE_URI, logLevel = LogLevelConstants.ERROR)) public void retrieveImageExtendedCorruptedDataBase64Test() { ResourceResolver resourceResolver = new ResourceResolver(baseUri); PdfXObject image = resourceResolver.retrieveImageExtended(bLogoCorruptedData); Assert.assertNull(image); }
@Test @LogMessages(messages = @LogMessage(messageTemplate = LogMessageConstant.UNABLE_TO_RETRIEVE_IMAGE_WITH_GIVEN_BASE_URI, logLevel = LogLevelConstants.ERROR)) public void retrieveImageExtendedNullTest() { ResourceResolver resourceResolver = new ResourceResolver(baseUri); PdfXObject image = resourceResolver.retrieveImageExtended(null); Assert.assertNull(image); }