aboutsummaryrefslogtreecommitdiffstats
path: root/tests/netx/unit/net/sourceforge
diff options
context:
space:
mode:
authorAdam Domurad <[email protected]>2013-06-05 15:12:01 -0400
committerAdam Domurad <[email protected]>2013-06-05 15:12:01 -0400
commit6b9db3b5496e986d9cbe16f94d65c6bb49aa6df7 (patch)
tree560fe41682dc8ea36843759d3de3402532131170 /tests/netx/unit/net/sourceforge
parentd529b383c65853c4c02276bd3eab2988b5a5370b (diff)
Fix PR1465 - java.io.FileNotFoundException while trying to download a JAR file
Diffstat (limited to 'tests/netx/unit/net/sourceforge')
-rw-r--r--tests/netx/unit/net/sourceforge/jnlp/cache/ResourceTrackerTest.java4
-rw-r--r--tests/netx/unit/net/sourceforge/jnlp/util/UrlUtilsTest.java26
2 files changed, 27 insertions, 3 deletions
diff --git a/tests/netx/unit/net/sourceforge/jnlp/cache/ResourceTrackerTest.java b/tests/netx/unit/net/sourceforge/jnlp/cache/ResourceTrackerTest.java
index 0b19668..03d942b 100644
--- a/tests/netx/unit/net/sourceforge/jnlp/cache/ResourceTrackerTest.java
+++ b/tests/netx/unit/net/sourceforge/jnlp/cache/ResourceTrackerTest.java
@@ -80,7 +80,7 @@ public class ResourceTrackerTest {
Assert.assertFalse("url " + i + " must be normalized (and so not equals) too normalized url " + i, u[i].equals(n[i]));
}
}
- public static final int CHANGE_BORDER = 6;
+ public static final int CHANGE_BORDER = 8;
public static URL[] getUrls() throws MalformedURLException {
URL[] u = {
@@ -91,9 +91,9 @@ public class ResourceTrackerTest {
new URL("http:///SpacesCanBeEverywhere1.jnlp"),
new URL("file://localhost/home/jvanek/Desktop/icedtea-web/tests.build/jnlp_test_server/Spaces can be everywhere2.jnlp"),
new URL("http://localhost:44321/testpage.jnlp?applicationID=25"),
- /*changing*/
new URL("http://localhost:44321/Spaces%20Can%20Be%20Everyw%2Fhere1.jnlp"),
new URL("http://localhost/Spaces+Can+Be+Everywhere1.jnlp"),
+ /*changing*/
new URL("http://localhost/SpacesC anBeEverywhere1.jnlp?a=5&b=10#df"),
new URL("http:///oook.jnlp?a=5&b=ahoj šš dd#df"),
new URL("http://localhost/Spacesěčšžšřýžčřú can !@^*(){}[].jnlp?a=5&ahoj šš dd#df"),
diff --git a/tests/netx/unit/net/sourceforge/jnlp/util/UrlUtilsTest.java b/tests/netx/unit/net/sourceforge/jnlp/util/UrlUtilsTest.java
index b6cf760..587915f 100644
--- a/tests/netx/unit/net/sourceforge/jnlp/util/UrlUtilsTest.java
+++ b/tests/netx/unit/net/sourceforge/jnlp/util/UrlUtilsTest.java
@@ -39,8 +39,11 @@ package net.sourceforge.jnlp.util;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
import java.net.URL;
import org.junit.Test;
@@ -95,6 +98,27 @@ public class UrlUtilsTest {
// Test file URL with file URL encoding turned on
assertEquals("file://example/%20test",
UrlUtils.normalizeUrl(new URL("file://example/ test"), true).toString());
+
+ // PR1465: Test that RFC2396-compliant URLs are not touched
+ // Example taken from bug report: http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=1465
+ String rfc2396Valid = "https://example.com/,DSID=64c19c5b657df383835706571a7c7216,DanaInfo=example.com,CT=java+JICAComponents/JICA-sicaN.jar";
+ assertEquals(rfc2396Valid,
+ UrlUtils.normalizeUrl(new URL(rfc2396Valid)).toString());
+ }
+
+ @Test
+ public void testIsValidRFC2396Url() throws Exception {
+ String rfc2396Valid = "https://example.com/,foo=bar+baz/JICA-sicaN.jar";
+ assertTrue(UrlUtils.isValidRFC2396Url(new URL(rfc2396Valid)));
+
+ // These should invalidate the URL
+ // See http://www.ietf.org/rfc/rfc2396.txt (2.4.3. Excluded US-ASCII Characters)
+ char[] invalidCharacters = {'<', '>', '%', '"', };
+ for (char chr : invalidCharacters) {
+ assertFalse("validation failed with '" + chr + "'",UrlUtils.isValidRFC2396Url(new URL(rfc2396Valid + chr)));
+ }
+ //special test for space inisde. Space at the end can be trimmed
+ assertFalse("validation failed with '" + ' ' + "'",UrlUtils.isValidRFC2396Url(new URL("https://example.com/,foo=bar+ba z/JICA-sicaN.jar")));
}
@Test
@@ -116,4 +140,4 @@ public class UrlUtilsTest {
assertEquals(testFile, UrlUtils.decodeUrlAsFile(encodedUrl));
}
}
-} \ No newline at end of file
+}