Skip to content

Commit 5d5de8b

Browse files
Add tests for resource paths resolving if base URI contains spaces
DEVSIX-1668
1 parent 8333e12 commit 5d5de8b

File tree

7 files changed

+103
-0
lines changed

7 files changed

+103
-0
lines changed

src/test/java/com/itextpdf/html2pdf/ResourceResolverTest.java

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ This file is part of the iText (R) project.
4949
import com.itextpdf.test.annotations.type.IntegrationTest;
5050
import org.junit.Assert;
5151
import org.junit.BeforeClass;
52+
import org.junit.Ignore;
5253
import org.junit.Test;
5354
import org.junit.experimental.categories.Category;
5455

@@ -118,6 +119,60 @@ public void resourceResolverTest11() throws IOException, InterruptedException {
118119
Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff11_"));
119120
}
120121

122+
@Test
123+
@Ignore("DEVSIX-1668")
124+
public void resourceResolverTest12() throws IOException, InterruptedException {
125+
String baseUri = sourceFolder + "path with spaces";
126+
127+
String outPdf = destinationFolder + "resourceResolverTest12.pdf";
128+
String cmpPdf = sourceFolder + "cmp_resourceResolverTest12.pdf";
129+
try (FileInputStream fileInputStream = new FileInputStream(sourceFolder + "resourceResolverTest12.html");
130+
FileOutputStream fileOutputStream = new FileOutputStream(outPdf)) {
131+
HtmlConverter.convertToPdf(fileInputStream, fileOutputStream, new ConverterProperties().setBaseUri(baseUri));
132+
}
133+
Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff12_"));
134+
}
135+
136+
@Test
137+
public void resourceResolverTest13() throws IOException, InterruptedException {
138+
String baseUri = sourceFolder;
139+
140+
String outPdf = destinationFolder + "resourceResolverTest13.pdf";
141+
String cmpPdf = sourceFolder + "cmp_resourceResolverTest13.pdf";
142+
try (FileInputStream fileInputStream = new FileInputStream(sourceFolder + "resourceResolverTest13.html");
143+
FileOutputStream fileOutputStream = new FileOutputStream(outPdf)) {
144+
HtmlConverter.convertToPdf(fileInputStream, fileOutputStream, new ConverterProperties().setBaseUri(baseUri));
145+
}
146+
Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff13_"));
147+
}
148+
149+
@Test
150+
@Ignore("DEVSIX-1668")
151+
public void resourceResolverTest14() throws IOException, InterruptedException {
152+
String baseUri = sourceFolder + "path%20with%20spaces";
153+
154+
String outPdf = destinationFolder + "resourceResolverTest14.pdf";
155+
String cmpPdf = sourceFolder + "cmp_resourceResolverTest14.pdf";
156+
try (FileInputStream fileInputStream = new FileInputStream(sourceFolder + "resourceResolverTest12.html");
157+
FileOutputStream fileOutputStream = new FileOutputStream(outPdf)) {
158+
HtmlConverter.convertToPdf(fileInputStream, fileOutputStream, new ConverterProperties().setBaseUri(baseUri));
159+
}
160+
Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff14_"));
161+
}
162+
163+
@Test
164+
public void resourceResolverTest15() throws IOException, InterruptedException {
165+
String baseUri = sourceFolder;
166+
167+
String outPdf = destinationFolder + "resourceResolverTest15.pdf";
168+
String cmpPdf = sourceFolder + "cmp_resourceResolverTest15.pdf";
169+
try (FileInputStream fileInputStream = new FileInputStream(sourceFolder + "resourceResolverTest15.html");
170+
FileOutputStream fileOutputStream = new FileOutputStream(outPdf)) {
171+
HtmlConverter.convertToPdf(fileInputStream, fileOutputStream, new ConverterProperties().setBaseUri(baseUri));
172+
}
173+
Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff15_"));
174+
}
175+
121176
// TODO test with absolute http links for resources?
122177
// TODO test with http base URI?
123178
}
Binary file not shown.
Binary file not shown.
12.3 KB
Loading
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<title>Page Title</title>
6+
</head>
7+
8+
<body>
9+
<div>
10+
<img src="itis.jpg">
11+
</div>
12+
<div><b>The content of the document......</b></div>
13+
14+
</body>
15+
16+
</html>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<title>Page Title</title>
6+
</head>
7+
8+
<body>
9+
<div>
10+
<img src="path with spaces/itis.jpg">
11+
</div>
12+
<div><b>The content of the document......</b></div>
13+
14+
</body>
15+
16+
</html>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<title>Page Title</title>
6+
</head>
7+
8+
<body>
9+
<div>
10+
<img src="path%20with%20spaces/itis.jpg">
11+
</div>
12+
<div><b>The content of the document......</b></div>
13+
14+
</body>
15+
16+
</html>

0 commit comments

Comments
 (0)