@@ -69,64 +69,17 @@ public static void beforeClass() {
69
69
createOrClearDestinationFolder (destinationFolder );
70
70
}
71
71
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
-
93
72
@ Test
94
73
public void resourceResolverTest03 () throws IOException , InterruptedException {
95
74
String baseUri = sourceFolder + "res" ;
96
75
String outPdf = destinationFolder + "resourceResolverTest03.pdf" ;
97
76
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
+ }
99
81
Assert .assertNull (new CompareTool ().compareByContent (outPdf , cmpPdf , destinationFolder , "diff03_" ));
100
82
}
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
-
130
83
@ Test
131
84
public void resourceResolverTest07 () throws IOException , InterruptedException {
132
85
String outPdf = destinationFolder + "resourceResolverTest07.pdf" ;
0 commit comments