Skip to content

Commit 7f177b4

Browse files
nikitakovaliov92Ubuntu
authored andcommitted
Add test for UriResolver#resolveAgainstBaseUri method
DEVSIX-6137
1 parent 47990ec commit 7f177b4

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/resolver/resource/UriResolverTest.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,19 @@ This file is part of the iText (R) project.
4545
import com.itextpdf.test.ExtendedITextTest;
4646
import com.itextpdf.test.annotations.type.UnitTest;
4747

48+
import java.net.MalformedURLException;
49+
import java.nio.file.Paths;
4850
import org.junit.Assert;
4951
import org.junit.Ignore;
5052
import org.junit.Test;
5153
import org.junit.experimental.categories.Category;
5254

53-
import java.net.MalformedURLException;
54-
import java.nio.file.Paths;
55-
5655
@Category(UnitTest.class)
5756
public class UriResolverTest extends ExtendedITextTest {
5857

58+
private static final String SOURCE_FOLDER =
59+
"./src/test/resources/com/itextpdfstyledxmlparser/resolver/resource/UriResolverTest/";
60+
5961
@Test
6062
public void uriResolverTest01() throws MalformedURLException {
6163
String absolutePathRoot = Paths.get("").toAbsolutePath().getRoot().toUri().toURL().toExternalForm();
@@ -112,6 +114,15 @@ public void uriResolverTest06() throws MalformedURLException {
112114
testPaths(resolver, parentFolder);
113115
}
114116

117+
@Test
118+
public void resolveAgainstBaseUriTest() throws MalformedURLException {
119+
String baseUrl = "https://test";
120+
UriResolver resolver = new UriResolver(SOURCE_FOLDER);
121+
resolver.resolveAgainstBaseUri(baseUrl);
122+
Assert.assertTrue(resolver.isLocalBaseUri());
123+
Assert.assertTrue(resolver.getBaseUri().startsWith("file:"));
124+
}
125+
115126
@Test
116127
public void uriResolverTest07() throws MalformedURLException {
117128
UriResolver resolver = new UriResolver("http://itextpdf.com/itext7");
@@ -120,6 +131,7 @@ public void uriResolverTest07() throws MalformedURLException {
120131
Assert.assertEquals("http://itextpdf.com/folder2/innerTest2", resolver.resolveAgainstBaseUri("/folder2/innerTest2").toExternalForm());
121132
Assert.assertEquals("http://folder2.com/innerTest2", resolver.resolveAgainstBaseUri("//folder2.com/innerTest2").toExternalForm());
122133
}
134+
123135
@Test
124136
public void uriResolverTest07A() throws MalformedURLException {
125137
String absolutePathRoot = Paths.get("").toAbsolutePath().getRoot().toUri().toURL().toString();

0 commit comments

Comments
 (0)