4444
4545import static org .junit .Assert .assertEquals ;
4646import static org .junit .Assert .assertFalse ;
47+ import static org .junit .Assert .assertNotEquals ;
4748import static org .junit .Assert .assertTrue ;
4849
4950public class UrlUtilsTest {
@@ -90,13 +91,16 @@ public void testNormalizeUrl() throws Exception {
9091 }
9192
9293 // Test file URL with file URL encoding turned off
93- assertFalse ("file://example/%20test" . equals (
94- UrlUtils .normalizeUrl (new URL ("file://example/ test" ), false ).toString () ));
94+ assertNotEquals ("file://example/%20test" ,
95+ UrlUtils .normalizeUrl (new URL ("file://example/ test" ), false ).toString ());
9596
9697 // Test file URL with file URL encoding turned on
9798 assertEquals ("file://example/%20test" ,
9899 UrlUtils .normalizeUrl (new URL ("file://example/ test" ), true ).toString ());
99100
101+ final String largeUrl = "https://www.kursweb.ch/webstart/webstart.selfsigned.jnlp?db=C:%5CUsers%5CFabian%5Cmerkisoft%5Cferienplausch-uster%5C&name=C:%5CUsers%5CFabian%5Cmerkisoft%5Cferienplausch-uster%5C" ;
102+ assertEquals (largeUrl , UrlUtils .normalizeUrl (new URL (largeUrl )).toString ());
103+
100104 // PR1465: Test that RFC2396-compliant URLs are not touched
101105 // Example taken from bug report: http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=1465
102106 String rfc2396Valid = "https://example.com/,DSID=64c19c5b657df383835706571a7c7216,DanaInfo=example.com,CT=java+JICAComponents/JICA-sicaN.jar" ;
@@ -138,8 +142,7 @@ public void testDecodeUrlAsFile() throws Exception {
138142 assertEquals ("Encoded url as file" , testFile .getAbsoluteFile (), UrlUtils .decodeUrlAsFile (encodedUrl ));
139143 }
140144 }
141-
142-
145+
143146 @ Test
144147 public void testNormalizeUrlSlashStrings () throws Exception {
145148 String u11 = UrlUtils .sanitizeLastSlash ("http://aa.bb/aaa/bbb////" );
@@ -152,7 +155,7 @@ public void testNormalizeUrlSlashStrings() throws Exception {
152155 assertEquals (u1 , u2 );
153156 assertEquals (u1 , ("http://aa.bb/aaa\\ bbb" ));
154157 }
155-
158+
156159 @ Test
157160 public void testNormalizeUrlSlashUrls () throws Exception {
158161 URL u11 = UrlUtils .sanitizeLastSlash (new URL ("http://aa.bb/aaa/bbb////" ));
@@ -203,30 +206,30 @@ public void removeFileName2() throws Exception {
203206
204207 URL l2 = UrlUtils .removeFileName (new URL ("http://aaa.bb/xyz\\ hchkr\\ " ));
205208 assertEquals (l2 , new URL ("http://aaa.bb/xyz\\ hchkr" ));
206-
209+
207210 URL l3 = UrlUtils .removeFileName (new URL ("http://aaa.bb/xyz\\ hchkr" ));
208211 assertEquals (l3 , new URL ("http://aaa.bb/xyz" ));
209-
212+
210213 URL l4 = UrlUtils .removeFileName (new URL ("http://aaa.bb/xyz\\ jar.jar" ));
211214 assertEquals (l4 , new URL ("http://aaa.bb/xyz" ));
212-
215+
213216 URL l5 = UrlUtils .removeFileName (new URL ("http://aaa.bb/xyz\\ " ));
214217 assertEquals (l5 , new URL ("http://aaa.bb/xyz" ));
215-
218+
216219 URL l6 = UrlUtils .removeFileName (new URL ("http://aaa.bb/xyz" ));
217220 assertEquals (l6 , new URL ("http://aaa.bb" ));
218-
221+
219222 URL l7 = UrlUtils .removeFileName (new URL ("http://aaa.bb/jar.jar" ));
220223 assertEquals (l7 , new URL ("http://aaa.bb" ));
221-
224+
222225 URL l8 = UrlUtils .removeFileName (new URL ("http://aaa.bb/" ));
223226 assertEquals (l8 , new URL ("http://aaa.bb" ));
224-
227+
225228 URL l9 = UrlUtils .removeFileName (new URL ("http://aaa.bb" ));
226229 assertEquals (l9 , new URL ("http://aaa.bb" ));
227-
230+
228231 }
229-
232+
230233 @ Test
231234 public void removeFileName3 () throws Exception {
232235 URL l1 = UrlUtils .removeFileName (new URL ("http://aaa.bb/xyz/hchkr/jar.jar?someParam=some¶m=very\\ evil\\ " ));
@@ -254,7 +257,7 @@ public void removeFileName3() throws Exception {
254257 assertEquals (l8 , new URL ("http://aaa.bb" ));
255258
256259 }
257-
260+
258261 @ Test
259262 public void testUrlEquals () throws Exception {
260263 final URL n1 = null , n2 = null , u1 = new URL ("http://example.com" ), u2 = u1 , u3 = new URL ("http://example.com" );
@@ -336,7 +339,7 @@ public void testCompareNullableStrings_values() throws Exception {
336339 Assert .assertFalse (UrlUtils .compareNullableStrings ("BBB" , "aaa" , false ));
337340
338341 }
339-
342+
340343 @ Test
341344 public void sanitizePortTest () throws MalformedURLException {
342345 Assert .assertEquals (0 , UrlUtils .getSanitizedPort (new URL ("http://aaa.cz:0" )));
@@ -347,7 +350,7 @@ public void sanitizePortTest() throws MalformedURLException {
347350 Assert .assertEquals (80 , UrlUtils .getSanitizedPort (new URL ("http://aaa.cz" )));
348351 Assert .assertEquals (443 , UrlUtils .getSanitizedPort (new URL ("https://aaa.cz" )));
349352 Assert .assertEquals (21 , UrlUtils .getSanitizedPort (new URL ("ftp://aaa.cz" )));
350-
353+
351354 }
352355
353356 @ Test
@@ -369,26 +372,26 @@ public void getHostAndPortTest() throws MalformedURLException {
369372 Assert .assertEquals ("aa.bb:80" , UrlUtils .getHostAndPort (new URL ("http://aa.bb" )));
370373 Assert .assertEquals ("aa.bb:80" , UrlUtils .getHostAndPort (new URL ("http://aa.bb:80/a/b/c" )));
371374 }
372-
375+
373376 @ Test
374377 public void ensureSlashTailTest () {
375378 Assert .assertEquals ("a/" , UrlUtils .ensureSlashTail ("a" ));
376379 Assert .assertEquals ("aa/a/" , UrlUtils .ensureSlashTail ("aa/a" ));
377380 Assert .assertEquals ("aa/a/" , UrlUtils .ensureSlashTail ("aa/a/" ));
378381 Assert .assertEquals ("/aa/a/" , UrlUtils .ensureSlashTail ("/aa/a/" ));
379382 Assert .assertEquals ("/aa/a/" , UrlUtils .ensureSlashTail ("/aa/a" ));
380-
383+
381384 Assert .assertEquals ("aa\\ a\\ " , UrlUtils .ensureSlashTail ("aa\\ a" ));
382385 Assert .assertEquals ("aa\\ a\\ " , UrlUtils .ensureSlashTail ("aa\\ a\\ " ));
383386 Assert .assertEquals ("\\ aa\\ a\\ " , UrlUtils .ensureSlashTail ("\\ aa\\ a\\ " ));
384387 Assert .assertEquals ("\\ aa\\ a\\ " , UrlUtils .ensureSlashTail ("\\ aa\\ a" ));
385-
388+
386389 Assert .assertEquals ("\\ aa/a/" , UrlUtils .ensureSlashTail ("\\ aa/a" ));
387390 Assert .assertEquals ("//aa\\ a/" , UrlUtils .ensureSlashTail ("//aa\\ a" ));
388391 Assert .assertEquals ("\\ aa/a/" , UrlUtils .ensureSlashTail ("\\ aa/a/" ));
389392 Assert .assertEquals ("\\ aa/a\\ " , UrlUtils .ensureSlashTail ("\\ aa/a\\ " ));
390393 }
391-
394+
392395 @ Test
393396 public void ensureSlashTailTest3 () throws MalformedURLException {
394397 Assert .assertEquals ("http://aa.bb:2/aa/" , UrlUtils .ensureSlashTail (new URL ("http://aa.bb:2/aa" )).toExternalForm ());
0 commit comments