public void testUrlFormParameterEscaper() { UnicodeEscaper e = (UnicodeEscaper) urlFormParameterEscaper(); // Verify that these are the same escaper (as documented) assertSame(e, urlFormParameterEscaper()); assertBasicUrlEscaper(e); /* * Specified as safe by RFC 2396 but not by java.net.URLEncoder. These tests will start failing * when the escaper is made compliant with RFC 2396, but that's a good thing (just change them * to assertUnescaped). */ assertEscaping(e, "%21", '!'); assertEscaping(e, "%28", '('); assertEscaping(e, "%29", ')'); assertEscaping(e, "%7E", '~'); assertEscaping(e, "%27", '\''); // Plus for spaces assertEscaping(e, "+", ' '); assertEscaping(e, "%2B", '+'); assertEquals("safe+with+spaces", e.escape("safe with spaces")); assertEquals("foo%40bar.com", e.escape("foo@bar.com")); }
public void testUrlFormParameterEscaper() { UnicodeEscaper e = (UnicodeEscaper) urlFormParameterEscaper(); // Verify that these are the same escaper (as documented) assertSame(e, urlFormParameterEscaper()); assertBasicUrlEscaper(e); /* * Specified as safe by RFC 2396 but not by java.net.URLEncoder. These tests will start failing * when the escaper is made compliant with RFC 2396, but that's a good thing (just change them * to assertUnescaped). */ assertEscaping(e, "%21", '!'); assertEscaping(e, "%28", '('); assertEscaping(e, "%29", ')'); assertEscaping(e, "%7E", '~'); assertEscaping(e, "%27", '\''); // Plus for spaces assertEscaping(e, "+", ' '); assertEscaping(e, "%2B", '+'); assertEquals("safe+with+spaces", e.escape("safe with spaces")); assertEquals("foo%40bar.com", e.escape("foo@bar.com")); }