Skip to content

Commit aa0c588

Browse files
Add unit tests in UriResolverTest. DEVSIX-2880
1 parent 465b7ec commit aa0c588

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ This file is part of the iText (R) project.
4242
*/
4343
package com.itextpdf.styledxmlparser.resolver.resource;
4444

45+
import com.itextpdf.kernel.geom.PageSize;
4546
import com.itextpdf.test.ExtendedITextTest;
4647
import com.itextpdf.test.annotations.type.UnitTest;
4748
import org.junit.Assert;
49+
import org.junit.Ignore;
4850
import org.junit.Rule;
4951
import org.junit.Test;
5052
import org.junit.experimental.categories.Category;
@@ -312,6 +314,50 @@ public void uriResolverTest18() {
312314
Assert.assertFalse(resolver.isLocalBaseUri());
313315
}
314316

317+
@Test
318+
public void singleQuoteRelativePath() throws MalformedURLException {
319+
String expectedUrl = "https://he.wikipedia.org/wiki/%D7%90%D7%91%D7%92'%D7%93";
320+
String baseUri = "https://he.wikipedia.org/wiki/";
321+
String relativePath = "%D7%90%D7%91%D7%92'%D7%93";
322+
UriResolver resolver = new UriResolver(baseUri);
323+
324+
Assert.assertEquals(expectedUrl, resolver.resolveAgainstBaseUri(relativePath).toExternalForm());
325+
}
326+
327+
@Test
328+
@Ignore("DEVSIX-2880: single quote character isn't encoded in Java and .NET 4.0, but it's encoded in .NETCoreApp 1.0" +
329+
" from single quote to %27")
330+
public void quoteInPercentsRelativePath() throws MalformedURLException {
331+
String expectedUrl = "https://he.wikipedia.org/wiki/%D7%90%D7%91%D7%92%27%D7%93";
332+
String baseUri = "https://he.wikipedia.org/wiki/";
333+
String relativePath = "%D7%90%D7%91%D7%92%27%D7%93";
334+
UriResolver resolver = new UriResolver(baseUri);
335+
336+
Assert.assertEquals(expectedUrl, resolver.resolveAgainstBaseUri(relativePath).toExternalForm());
337+
}
338+
339+
@Test
340+
public void singleQuoteBasePath() throws MalformedURLException {
341+
String expectedUrl = "https://he.wikipedia.org/wiki'/%D7%90%D7%91%D7%92%D7%93";
342+
String baseUri = "https://he.wikipedia.org/wiki'/";
343+
String relativePath = "%D7%90%D7%91%D7%92%D7%93";
344+
UriResolver resolver = new UriResolver(baseUri);
345+
346+
Assert.assertEquals(expectedUrl, resolver.resolveAgainstBaseUri(relativePath).toExternalForm());
347+
}
348+
349+
@Test
350+
@Ignore("DEVSIX-2880: single quote character isn't encoded in Java and .NET 4.0, but it's encoded in .NETCoreApp 1.0" +
351+
" from single quote to %27")
352+
public void quoteInPercentsBasePath() throws MalformedURLException {
353+
String expectedUrl = "https://he.wikipedia.org/wiki%27/%D7%90%D7%91%D7%92%D7%93";
354+
String baseUri = "https://he.wikipedia.org/wiki%27/";
355+
String relativePath = "%D7%90%D7%91%D7%92%D7%93";
356+
UriResolver resolver = new UriResolver(baseUri);
357+
358+
Assert.assertEquals(expectedUrl, resolver.resolveAgainstBaseUri(relativePath).toExternalForm());
359+
}
360+
315361
private void testPaths(UriResolver resolver, String path) throws MalformedURLException {
316362
Assert.assertEquals(path + "test/folder/index.html", resolver.getBaseUri());
317363
Assert.assertEquals(path + "test/folder/innerTest", resolver.resolveAgainstBaseUri("innerTest").toExternalForm());

0 commit comments

Comments
 (0)