-
Notifications
You must be signed in to change notification settings - Fork 563
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
263 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
flying-saucer-core/src/test/java/org/xhtmlrenderer/simple/Graphics2DRendererTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 31 additions & 31 deletions
62
flying-saucer-core/src/test/java/org/xhtmlrenderer/swing/NaiveUserAgentTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,66 @@ | ||
package org.xhtmlrenderer.swing; | ||
|
||
import junit.framework.TestCase; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class NaiveUserAgentTest | ||
extends TestCase | ||
{ | ||
private static String resolve(String baseUri, String uri) | ||
{ | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class NaiveUserAgentTest { | ||
private static String resolve(String baseUri, String uri) { | ||
NaiveUserAgent userAgent=new NaiveUserAgent(); | ||
userAgent.setBaseURL(baseUri); | ||
return userAgent.resolveURI(uri); | ||
} | ||
|
||
public void testBasicResolve() | ||
{ | ||
@Test | ||
public void basicResolve() { | ||
// absolute uris should be unchanged | ||
assertEquals("http://www.example.com", resolve(null, "http://www.example.com")); | ||
assertEquals("http://www.example.com", resolve("ftp://www.example.com/other","http://www.example.com")); | ||
assertThat(resolve(null, "http://www.example.com")).isEqualTo("http://www.example.com"); | ||
assertThat(resolve("ftp://www.example.com/other", "http://www.example.com")).isEqualTo("http://www.example.com"); | ||
|
||
// by default relative uris resolves as file | ||
assertNotNull(resolve(null, "www.example.com")); | ||
assertTrue(resolve(null, "www.example.com").startsWith("file:")); | ||
assertThat(resolve(null, "www.example.com")) | ||
.isNotNull() | ||
.startsWith("file:"); | ||
|
||
// relative uris without slash | ||
assertEquals("ftp://www.example.com/test", resolve("ftp://www.example.com/other","test")); | ||
assertThat(resolve("ftp://www.example.com/other", "test")).isEqualTo("ftp://www.example.com/test"); | ||
|
||
// relative uris with slash | ||
assertEquals("ftp://www.example.com/other/test", resolve("ftp://www.example.com/other/","test")); | ||
assertEquals("ftp://www.example.com/test", resolve("ftp://www.example.com/other/","/test")); | ||
assertThat(resolve("ftp://www.example.com/other/", "test")).isEqualTo("ftp://www.example.com/other/test"); | ||
assertThat(resolve("ftp://www.example.com/other/", "/test")).isEqualTo("ftp://www.example.com/test"); | ||
} | ||
|
||
public void testCustomProtocolResolve() | ||
{ | ||
@Test | ||
public void customProtocolResolve() { | ||
// absolute uris should be unchanged | ||
assertEquals("custom://www.example.com", resolve(null, "custom://www.example.com")); | ||
assertEquals("custom://www.example.com", resolve("ftp://www.example.com/other","custom://www.example.com")); | ||
assertThat(resolve(null, "custom://www.example.com")).isEqualTo("custom://www.example.com"); | ||
assertThat(resolve("ftp://www.example.com/other", "custom://www.example.com")).isEqualTo("custom://www.example.com"); | ||
|
||
// relative uris without slash | ||
assertEquals("custom://www.example.com/test", resolve("custom://www.example.com/other","test")); | ||
assertThat(resolve("custom://www.example.com/other", "test")).isEqualTo("custom://www.example.com/test"); | ||
|
||
// relative uris with slash | ||
assertEquals("custom://www.example.com/other/test", resolve("custom://www.example.com/other/","test")); | ||
assertEquals("custom://www.example.com/test", resolve("custom://www.example.com/other/","/test")); | ||
assertThat(resolve("custom://www.example.com/other/", "test")).isEqualTo("custom://www.example.com/other/test"); | ||
assertThat(resolve("custom://www.example.com/other/", "/test")).isEqualTo("custom://www.example.com/test"); | ||
} | ||
|
||
/** | ||
* This reproduces https://code.google.com/archive/p/flying-saucer/issues/262 | ||
* | ||
* This reproduces <a href="https://code.google.com/archive/p/flying-saucer/issues/262">...</a> | ||
* <p> | ||
* Below test was green with 9.0.6 and turned red in 9.0.7 | ||
*/ | ||
public void testJarFileUriResolve() | ||
{ | ||
@Test | ||
public void jarFileUriResolve() { | ||
// absolute uris should be unchanged | ||
assertEquals("jar:file:/path/jarfile.jar!/foo/index.xhtml", resolve(null, "jar:file:/path/jarfile.jar!/foo/index.xhtml")); | ||
assertEquals("jar:file:/path/jarfile.jar!/foo/index.xhtml", resolve("ftp://www.example.com/other","jar:file:/path/jarfile.jar!/foo/index.xhtml")); | ||
assertThat(resolve(null, "jar:file:/path/jarfile.jar!/foo/index.xhtml")).isEqualTo("jar:file:/path/jarfile.jar!/foo/index.xhtml"); | ||
assertThat(resolve("ftp://www.example.com/other", "jar:file:/path/jarfile.jar!/foo/index.xhtml")).isEqualTo("jar:file:/path/jarfile.jar!/foo/index.xhtml"); | ||
|
||
// relative uris without slash | ||
assertEquals("jar:file:/path/jarfile.jar!/foo/other.xhtml", resolve("jar:file:/path/jarfile.jar!/foo/index.xhtml","other.xhtml")); | ||
assertThat(resolve("jar:file:/path/jarfile.jar!/foo/index.xhtml", "other.xhtml")).isEqualTo("jar:file:/path/jarfile.jar!/foo/other.xhtml"); | ||
|
||
// relative uris with slash | ||
assertEquals("jar:file:/path/jarfile.jar!/foo/other.xhtml", resolve("jar:file:/path/jarfile.jar!/foo/","other.xhtml")); | ||
assertEquals("jar:file:/path/jarfile.jar!/other.xhtml", resolve("jar:file:/path/jarfile.jar!/foo/","/other.xhtml")); | ||
assertThat(resolve("jar:file:/path/jarfile.jar!/foo/", "other.xhtml")).isEqualTo("jar:file:/path/jarfile.jar!/foo/other.xhtml"); | ||
assertThat(resolve("jar:file:/path/jarfile.jar!/foo/", "/other.xhtml")).isEqualTo("jar:file:/path/jarfile.jar!/other.xhtml"); | ||
} | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
flying-saucer-core/src/test/java/org/xhtmlrenderer/util/ConfigurationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.