aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAdam Domurad <[email protected]>2013-04-23 13:59:20 -0400
committerAdam Domurad <[email protected]>2013-04-23 13:59:20 -0400
commitdfbd349f02bf60a694a80e4c93b24ed2f1413587 (patch)
treecf063cbac8fd68c0ed9413fbaa3284de7884e5e8 /tests
parent75392ff66c30d88fa173a2b38a94ab9f3ddaf39d (diff)
Add tests for newly added UrlUtils functions
Diffstat (limited to 'tests')
-rw-r--r--tests/netx/unit/net/sourceforge/jnlp/util/UrlUtilsTest.java38
1 files changed, 37 insertions, 1 deletions
diff --git a/tests/netx/unit/net/sourceforge/jnlp/util/UrlUtilsTest.java b/tests/netx/unit/net/sourceforge/jnlp/util/UrlUtilsTest.java
index bd0ef17..1a0e69c 100644
--- a/tests/netx/unit/net/sourceforge/jnlp/util/UrlUtilsTest.java
+++ b/tests/netx/unit/net/sourceforge/jnlp/util/UrlUtilsTest.java
@@ -27,4 +27,40 @@ public class UrlUtilsTest {
assertEquals("http://example.com/%20test%20test",
UrlUtils.normalizeUrlAndStripParams(new URL("http://example.com/ test%20test ?test=test")).toString());
}
-}
+
+ @Test
+ public void testDecodeUrlQuietly() throws Exception {
+ // This is a wrapper over URLDecoder.decode, simple test suffices
+ assertEquals("http://example.com/ test test",
+ UrlUtils.decodeUrlQuietly(new URL("http://example.com/%20test%20test")).toString());
+ }
+
+ @Test
+ public void testNormalizeUrl() throws Exception {
+ boolean[] encodeFileUrlPossiblities = {false, true};
+
+ // encodeFileUrl flag should have no effect on non-file URLs, but let's be sure.
+ for (boolean encodeFileUrl : encodeFileUrlPossiblities ) {
+ // Test URL with no previous encoding
+ assertEquals("http://example.com/%20test",
+ UrlUtils.normalizeUrl(new URL("http://example.com/ test"), encodeFileUrl).toString());
+ // Test partially encoded URL with trailing spaces
+ assertEquals("http://example.com/%20test%20test",
+ UrlUtils.normalizeUrl(new URL("http://example.com/ test%20test "), encodeFileUrl).toString());
+ }
+
+ // Test file URL with file URL encoding turned off
+ assertFalse("file://example/%20test".equals(
+ UrlUtils.normalizeUrl(new URL("file://example/ test"), false).toString()));
+
+ // Test file URL with file URL encoding turned on
+ 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());
+ }
+} \ No newline at end of file