Refactored URLEncoing code

This commit is contained in:
Pablo Fernandez committed 2010-11-20 19:27:04 -03:00
1 parent 99a03b4679
commit c0d24b556c
6 files changed
+53 -45

No files matched your search

@@ -8,13 +8,6 @@ import org.junit.*;
public class URLUtilsTest
{
@Before
public void setup()
{
}
@Test
public void shouldPercentEncodeMap()
{
@@ -51,6 +44,23 @@ public class URLUtilsTest
assertEquals(expected, URLUtils.percentDecode(toDecode));
}
@Test
public void shouldEncodeAllSpecialCharacters()
{
String plain = "!*'();:@&=+$,/?#[]";
String encoded = "%21%2A%27%28%29%3B%3A%40%26%3D%2B%24%2C%2F%3F%23%5B%5D";
assertEquals(encoded, URLUtils.percentEncode(plain));
assertEquals(plain, URLUtils.percentDecode(encoded));
}
@Test
public void shouldNotEncodeReservedCharacters()
{
String plain = "abcde123456-._~";
String encoded = plain;
assertEquals(encoded, URLUtils.percentEncode(plain));
}
@Test(expected = IllegalArgumentException.class)
public void shouldThrowExceptionIfMapIsNull()
{