@@ -69,64 +69,17 @@ public static void beforeClass() {
6969 createOrClearDestinationFolder (destinationFolder );
7070 }
7171
72- @ Test
73- public void resourceResolverTest01 () throws IOException , InterruptedException {
74- String baseUri = sourceFolder + "resourceResolverTest01.html" ;
75- String outPdf = destinationFolder + "resourceResolverTest01.pdf" ;
76- String cmpPdf = sourceFolder + "cmp_resourceResolverTest01.pdf" ;
77- HtmlConverter .convertToPdf (new FileInputStream (sourceFolder + "resourceResolverTest01.html" ), new FileOutputStream (outPdf ), new ConverterProperties ().setBaseUri (baseUri ));
78- Assert .assertNull (new CompareTool ().compareByContent (outPdf , cmpPdf , destinationFolder , "diff01_" ));
79- }
80-
81- @ Test
82- @ LogMessages (messages = {@ LogMessage (messageTemplate = LogMessageConstant .UNABLE_TO_RETRIEVE_IMAGE_WITH_GIVEN_BASE_URI ),
83- @ LogMessage (messageTemplate = LogMessageConstant .UNABLE_TO_PROCESS_EXTERNAL_CSS_FILE ),
84- @ LogMessage (messageTemplate = LogMessageConstant .WORKER_UNABLE_TO_PROCESS_OTHER_WORKER )})
85- public void resourceResolverTest02 () throws IOException , InterruptedException {
86- String baseUri = "/folderInDiskRoot" ;
87- String outPdf = destinationFolder + "resourceResolverTest02.pdf" ;
88- String cmpPdf = sourceFolder + "cmp_resourceResolverTest02.pdf" ;
89- HtmlConverter .convertToPdf (new FileInputStream (sourceFolder + "resourceResolverTest01.html" ), new FileOutputStream (outPdf ), new ConverterProperties ().setBaseUri (baseUri ));
90- Assert .assertNull (new CompareTool ().compareByContent (outPdf , cmpPdf , destinationFolder , "diff02_" ));
91- }
92-
9372 @ Test
9473 public void resourceResolverTest03 () throws IOException , InterruptedException {
9574 String baseUri = sourceFolder + "res" ;
9675 String outPdf = destinationFolder + "resourceResolverTest03.pdf" ;
9776 String cmpPdf = sourceFolder + "cmp_resourceResolverTest03.pdf" ;
98- HtmlConverter .convertToPdf (new FileInputStream (sourceFolder + "resourceResolverTest03.html" ), new FileOutputStream (outPdf ), new ConverterProperties ().setBaseUri (baseUri ));
77+ try (FileInputStream fileInputStream = new FileInputStream (sourceFolder + "resourceResolverTest03.html" );
78+ FileOutputStream fileOutputStream = new FileOutputStream (outPdf )) {
79+ HtmlConverter .convertToPdf (fileInputStream , fileOutputStream , new ConverterProperties ().setBaseUri (baseUri ));
80+ }
9981 Assert .assertNull (new CompareTool ().compareByContent (outPdf , cmpPdf , destinationFolder , "diff03_" ));
10082 }
101-
102- @ Test
103- public void resourceResolverTest04 () throws IOException , InterruptedException {
104- String invalidBaseUri = Paths .get ("" ).toAbsolutePath ().toString () + "/src/test/resources/com/itextpdf/html2pdf/ResourceResolverTest/" + "res" ;
105- String outPdf = destinationFolder + "resourceResolverTest04.pdf" ;
106- String cmpPdf = sourceFolder + "cmp_resourceResolverTest04.pdf" ;
107- HtmlConverter .convertToPdf (new FileInputStream (sourceFolder + "resourceResolverTest03.html" ), new FileOutputStream (outPdf ), new ConverterProperties ().setBaseUri (invalidBaseUri ));
108- Assert .assertNull (new CompareTool ().compareByContent (outPdf , cmpPdf , destinationFolder , "diff04_" ));
109- }
110-
111- @ Test
112- public void resourceResolverTest05 () throws IOException , InterruptedException {
113- // It is important to put a trailing slash in the end: if you specify base URI via absolute URI string,
114- // you need to follow URI standards, in which a path without trailing slash is referring to a file.
115- String baseUri = Paths .get ("" ).toUri () + "src/test/resources/com/itextpdf/html2pdf/ResourceResolverTest/res/" ;
116- String outPdf = destinationFolder + "resourceResolverTest05.pdf" ;
117- String cmpPdf = sourceFolder + "cmp_resourceResolverTest05.pdf" ;
118- HtmlConverter .convertToPdf (new FileInputStream (sourceFolder + "resourceResolverTest03.html" ), new FileOutputStream (outPdf ), new ConverterProperties ().setBaseUri (baseUri ));
119- Assert .assertNull (new CompareTool ().compareByContent (outPdf , cmpPdf , destinationFolder , "diff05_" ));
120- }
121-
122- @ Test
123- public void resourceResolverTest06 () throws IOException , InterruptedException {
124- String outPdf = destinationFolder + "resourceResolverTest06.pdf" ;
125- String cmpPdf = sourceFolder + "cmp_resourceResolverTest06.pdf" ;
126- HtmlConverter .convertToPdf (new File (sourceFolder + "resourceResolverTest01.html" ), new File (outPdf ));
127- Assert .assertNull (new CompareTool ().compareByContent (outPdf , cmpPdf , destinationFolder , "diff06_" ));
128- }
129-
13083 @ Test
13184 public void resourceResolverTest07 () throws IOException , InterruptedException {
13285 String outPdf = destinationFolder + "resourceResolverTest07.pdf" ;
0 commit comments