diff options
author | Adam Domurad <[email protected]> | 2013-04-26 12:44:48 -0400 |
---|---|---|
committer | Adam Domurad <[email protected]> | 2013-04-26 12:44:48 -0400 |
commit | 1970f53722f544819fd7b00698c79785c79b3df9 (patch) | |
tree | ba16cc19be024896f96efd1b4793f820261d88f1 /tests/netx/unit/net/sourceforge/jnlp | |
parent | bb0ced031fcb71d5d93d0a87744689444c5bd948 (diff) |
Decode local-file URLs leniently
Diffstat (limited to 'tests/netx/unit/net/sourceforge/jnlp')
-rw-r--r-- | tests/netx/unit/net/sourceforge/jnlp/util/UrlUtilsTest.java | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/tests/netx/unit/net/sourceforge/jnlp/util/UrlUtilsTest.java b/tests/netx/unit/net/sourceforge/jnlp/util/UrlUtilsTest.java index 1a0e69c..251dfb2 100644 --- a/tests/netx/unit/net/sourceforge/jnlp/util/UrlUtilsTest.java +++ b/tests/netx/unit/net/sourceforge/jnlp/util/UrlUtilsTest.java @@ -1,9 +1,11 @@ package net.sourceforge.jnlp.util; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import java.io.File; import java.net.URL; - + import org.junit.Test; public class UrlUtilsTest { @@ -57,10 +59,24 @@ public class UrlUtilsTest { assertEquals("file://example/%20test", UrlUtils.normalizeUrl(new URL("file://example/ test"), true).toString()); } + @Test public void testNormalizeUrlQuietly() throws Exception { // This is a wrapper over UrlUtils.normalizeUrl(), simple test suffices assertEquals("http://example.com/%20test%20test", UrlUtils.normalizeUrl(new URL("http://example.com/ test%20test ")).toString()); } + + @Test + public void testDecodeUrlAsFile() throws Exception { + String[] testPaths = {"/simple", "/ with spaces", "/with /multiple=/ odd characters?"}; + + for (String testPath : testPaths) { + File testFile = new File(testPath); + URL notEncodedUrl = testFile.toURL(); + URL encodedUrl = testFile.toURI().toURL(); + assertEquals(testFile, UrlUtils.decodeUrlAsFile(notEncodedUrl)); + assertEquals(testFile, UrlUtils.decodeUrlAsFile(encodedUrl)); + } + } }
\ No newline at end of file |