@@ -49,13 +49,16 @@ source product.
4949using iText . Kernel ;
5050using iText . Test ;
5151using iText . Test . Attributes ;
52+ using NUnit . Framework ;
5253
5354namespace iText . Html2pdf {
5455 public class ResourceResolverTest : ExtendedITextTest {
55- public static readonly String sourceFolder = TestUtil . GetParentProjectDirectory ( NUnit . Framework . TestContext . CurrentContext . TestDirectory ) + "/resources/itext/html2pdf/ResourceResolverTest/" ;
56+ public static readonly String sourceFolder =
57+ TestUtil . GetParentProjectDirectory ( NUnit . Framework . TestContext . CurrentContext . TestDirectory ) +
58+ "/resources/itext/html2pdf/ResourceResolverTest/" ;
5659
5760 public static readonly String destinationFolder = NUnit . Framework . TestContext . CurrentContext . TestDirectory
58- + "/test/itext/html2pdf/ResourceResolverTest/" ;
61+ + "/test/itext/html2pdf/ResourceResolverTest/" ;
5962
6063 [ NUnit . Framework . OneTimeSetUp ]
6164 public static void BeforeClass ( ) {
@@ -70,71 +73,149 @@ public virtual void ResourceResolverTest03() {
7073 String outPdf = destinationFolder + "resourceResolverTest03.pdf" ;
7174 String cmpPdf = sourceFolder + "cmp_resourceResolverTest03.pdf" ;
7275
73- using ( FileStream fileInputStream = new FileStream ( sourceFolder + "resourceResolverTest03.html" , FileMode . Open , FileAccess . Read ) ,
74- fileOutputStream = new FileStream ( outPdf , FileMode . Create ) ) {
75- HtmlConverter . ConvertToPdf ( fileInputStream , fileOutputStream , new ConverterProperties ( ) . SetBaseUri ( baseUri ) ) ;
76- NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( outPdf , cmpPdf , destinationFolder , "diff03_"
76+ using (
77+ FileStream fileInputStream = new FileStream ( sourceFolder + "resourceResolverTest03.html" , FileMode . Open ,
78+ FileAccess . Read ) ,
79+ fileOutputStream = new FileStream ( outPdf , FileMode . Create ) ) {
80+ HtmlConverter . ConvertToPdf ( fileInputStream , fileOutputStream ,
81+ new ConverterProperties ( ) . SetBaseUri ( baseUri ) ) ;
82+ NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( outPdf , cmpPdf , destinationFolder ,
83+ "diff03_"
7784 ) ) ;
7885 }
7986 }
80-
87+
8188 /// <exception cref="System.IO.IOException"/>
8289 /// <exception cref="System.Exception"/>
8390 [ NUnit . Framework . Test ]
84- public virtual void ResourceResolverTest07 ( )
85- {
91+ public virtual void ResourceResolverTest07 ( ) {
8692 String outPdf = destinationFolder + "resourceResolverTest07.pdf" ;
8793 String cmpPdf = sourceFolder + "cmp_resourceResolverTest07.pdf" ;
8894 HtmlConverter . ConvertToPdf ( new FileInfo ( sourceFolder + "resourceResolverTest07.html" ) , new FileInfo ( outPdf
8995 ) ) ;
90- NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( outPdf , cmpPdf , destinationFolder , "diff07_"
96+ NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( outPdf , cmpPdf , destinationFolder ,
97+ "diff07_"
9198 ) ) ;
9299 }
93100
94101 /// <exception cref="System.IO.IOException"/>
95102 /// <exception cref="System.Exception"/>
96103 [ NUnit . Framework . Test ]
97- public virtual void ResourceResolverTest09 ( )
98- {
104+ public virtual void ResourceResolverTest09 ( ) {
99105 String outPdf = destinationFolder + "resourceResolverTest09.pdf" ;
100106 String cmpPdf = sourceFolder + "cmp_resourceResolverTest09.pdf" ;
101107 HtmlConverter . ConvertToPdf ( new FileInfo ( sourceFolder + "resourceResolverTest09.html" ) , new FileInfo ( outPdf
102108 ) ) ;
103- NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( outPdf , cmpPdf , destinationFolder , "diff09_"
109+ NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( outPdf , cmpPdf , destinationFolder ,
110+ "diff09_"
104111 ) ) ;
105112 }
106113
107114 /// <exception cref="System.IO.IOException"/>
108115 /// <exception cref="System.Exception"/>
109116 [ NUnit . Framework . Test ]
110- public virtual void ResourceResolverTest10 ( )
111- {
117+ public virtual void ResourceResolverTest10 ( ) {
112118 String outPdf = destinationFolder + "resourceResolverTest10.pdf" ;
113119 String cmpPdf = sourceFolder + "cmp_resourceResolverTest10.pdf" ;
114- using ( FileStream fileInputStream = new FileStream ( sourceFolder + "resourceResolverTest10.html" , FileMode . Open , FileAccess . Read ) ,
115- fileOutputStream = new FileStream ( outPdf , FileMode . Create ) ) {
116- HtmlConverter . ConvertToPdf ( fileInputStream , fileOutputStream , new ConverterProperties ( ) . SetBaseUri ( "%homepath%" ) ) ;
120+ using (
121+ FileStream fileInputStream = new FileStream ( sourceFolder + "resourceResolverTest10.html" , FileMode . Open ,
122+ FileAccess . Read ) ,
123+ fileOutputStream = new FileStream ( outPdf , FileMode . Create ) ) {
124+ HtmlConverter . ConvertToPdf ( fileInputStream , fileOutputStream ,
125+ new ConverterProperties ( ) . SetBaseUri ( "%homepath%" ) ) ;
117126 NUnit . Framework . Assert . IsNull (
118127 new CompareTool ( ) . CompareByContent ( outPdf , cmpPdf , destinationFolder , "diff10_" ) ) ;
119- }
128+ }
120129 }
121130
122131 /// <exception cref="System.IO.IOException"/>
123132 /// <exception cref="System.Exception"/>
124133 [ NUnit . Framework . Test ]
125- public virtual void ResourceResolverTest11 ( )
126- {
134+ public virtual void ResourceResolverTest11 ( ) {
127135 String outPdf = destinationFolder + "resourceResolverTest11.pdf" ;
128136 String cmpPdf = sourceFolder + "cmp_resourceResolverTest11.pdf" ;
129- using ( FileStream fileInputStream = new FileStream ( sourceFolder + "resourceResolverTest11.html" , FileMode . Open , FileAccess . Read ) ,
130- fileOutputStream = new FileStream ( outPdf , FileMode . Create ) )
131- {
132- HtmlConverter . ConvertToPdf ( fileInputStream , fileOutputStream , new ConverterProperties ( ) . SetBaseUri ( "https://en.wikipedia.org/wiki/Welsh_Corgi" ) ) ;
137+ using (
138+ FileStream fileInputStream = new FileStream ( sourceFolder + "resourceResolverTest11.html" , FileMode . Open ,
139+ FileAccess . Read ) ,
140+ fileOutputStream = new FileStream ( outPdf , FileMode . Create ) ) {
141+ HtmlConverter . ConvertToPdf ( fileInputStream , fileOutputStream ,
142+ new ConverterProperties ( ) . SetBaseUri ( "https://en.wikipedia.org/wiki/Welsh_Corgi" ) ) ;
133143 NUnit . Framework . Assert . IsNull (
134144 new CompareTool ( ) . CompareByContent ( outPdf , cmpPdf , destinationFolder , "diff11_" ) ) ;
135145 }
136146 }
137147
148+ [ NUnit . Framework . Test ]
149+ [ Ignore ( "DEVSIX-1668" ) ]
150+ public void ResourceResolverTest12 ( ) {
151+ String baseUri = sourceFolder + "path with spaces" ;
152+
153+ String outPdf = destinationFolder + "resourceResolverTest12.pdf" ;
154+ String cmpPdf = sourceFolder + "cmp_resourceResolverTest12.pdf" ;
155+ using (
156+ FileStream fileInputStream = new FileStream ( sourceFolder + "resourceResolverTest12.html" , FileMode . Open ,
157+ FileAccess . Read ) ,
158+ fileOutputStream = new FileStream ( outPdf , FileMode . Create ) ) {
159+ HtmlConverter . ConvertToPdf ( fileInputStream , fileOutputStream ,
160+ new ConverterProperties ( ) . SetBaseUri ( baseUri ) ) ;
161+ NUnit . Framework . Assert . IsNull (
162+ new CompareTool ( ) . CompareByContent ( outPdf , cmpPdf , destinationFolder , "diff12_" ) ) ;
163+ }
164+ }
165+
166+ [ NUnit . Framework . Test ]
167+ public void ResourceResolverTest13 ( ) {
168+ String baseUri = sourceFolder ;
169+
170+ String outPdf = destinationFolder + "resourceResolverTest13.pdf" ;
171+ String cmpPdf = sourceFolder + "cmp_resourceResolverTest13.pdf" ;
172+ using (
173+ FileStream fileInputStream = new FileStream ( sourceFolder + "resourceResolverTest13.html" , FileMode . Open ,
174+ FileAccess . Read ) ,
175+ fileOutputStream = new FileStream ( outPdf , FileMode . Create ) ) {
176+ HtmlConverter . ConvertToPdf ( fileInputStream , fileOutputStream ,
177+ new ConverterProperties ( ) . SetBaseUri ( baseUri ) ) ;
178+ NUnit . Framework . Assert . IsNull (
179+ new CompareTool ( ) . CompareByContent ( outPdf , cmpPdf , destinationFolder , "diff13_" ) ) ;
180+ }
181+ }
182+
183+ [ NUnit . Framework . Test ]
184+ [ Ignore ( "DEVSIX-1668" ) ]
185+ public void ResourceResolverTest14 ( ) {
186+ String baseUri = sourceFolder + "path%20with%20spaces" ;
187+
188+ String outPdf = destinationFolder + "resourceResolverTest14.pdf" ;
189+ String cmpPdf = sourceFolder + "cmp_resourceResolverTest14.pdf" ;
190+ using (
191+ FileStream fileInputStream = new FileStream ( sourceFolder + "resourceResolverTest12.html" , FileMode . Open ,
192+ FileAccess . Read ) ,
193+ fileOutputStream = new FileStream ( outPdf , FileMode . Create ) ) {
194+ HtmlConverter . ConvertToPdf ( fileInputStream , fileOutputStream ,
195+ new ConverterProperties ( ) . SetBaseUri ( baseUri ) ) ;
196+ NUnit . Framework . Assert . IsNull (
197+ new CompareTool ( ) . CompareByContent ( outPdf , cmpPdf , destinationFolder , "diff14_" ) ) ;
198+ }
199+ }
200+
201+ [ NUnit . Framework . Test ]
202+
203+ public void ResourceResolverTest15 ( ) {
204+ String baseUri = sourceFolder ;
205+
206+ String outPdf = destinationFolder + "resourceResolverTest15.pdf" ;
207+ String cmpPdf = sourceFolder + "cmp_resourceResolverTest15.pdf" ;
208+ using (
209+ FileStream fileInputStream = new FileStream ( sourceFolder + "resourceResolverTest15.html" , FileMode . Open ,
210+ FileAccess . Read ) ,
211+ fileOutputStream = new FileStream ( outPdf , FileMode . Create ) ) {
212+ HtmlConverter . ConvertToPdf ( fileInputStream , fileOutputStream ,
213+ new ConverterProperties ( ) . SetBaseUri ( baseUri ) ) ;
214+ NUnit . Framework . Assert . IsNull (
215+ new CompareTool ( ) . CompareByContent ( outPdf , cmpPdf , destinationFolder , "diff15_" ) ) ;
216+ }
217+ }
218+
138219
139220 // TODO test with absolute http links for resources?
140221 // TODO test with http base URI?
0 commit comments