1616
1717package org .metafacture .metamorph .functions ;
1818
19+ import java .io .UnsupportedEncodingException ;
20+ import java .net .URLEncoder ;
21+
1922import static org .junit .Assert .*;
2023import org .junit .Test ;
2124
@@ -31,10 +34,15 @@ public final class URLEncodeTest {
3134 private static final String CAFE_ENCODED = "caf%C3%A9" ;
3235 private static final String SOME_CHARS = "/&%\\ +" ;
3336 private static final String SOME_CHARS_ENCODED = "%2F%26%25%5C%2B" ;
37+ private static final String SPECIAL_CHARACTERS = ".-*_" ;
38+ private static final String URL =
39+ "http://lobid.org/resources/search?q=hasItem.hasItem.heldBy.id:\" http://lobid" +
40+ ".org/organisations/DE-290#!\" &format=json" ;
3441 private static final String WHITESPACE = " " ;
3542 private static final String WHITESPACE_AS_PLUS_ENCODED = "+" ;
3643 private static final String WHITESPACE_PERCENT_ENCODED = "%20" ;
3744
45+ URLEncoder urlEncoder ;
3846 @ Test
3947 public void testUtf8 (){
4048 final URLEncode urlEncode = new URLEncode ();
@@ -64,5 +72,15 @@ public void testSafeChars(){
6472 urlEncode .setSafeChars (SOME_CHARS );
6573 assertEquals (SOME_CHARS , urlEncode .process (SOME_CHARS ));
6674 }
75+ @ Test
76+ public void testSpecialChars (){
77+ final URLEncode urlEncode = new URLEncode ();
78+ assertEquals (SPECIAL_CHARACTERS , urlEncode .process (SPECIAL_CHARACTERS ));
79+ }
80+ @ Test
81+ public void testBackwardsCompatibility () throws UnsupportedEncodingException {
82+ final URLEncode urlEncode = new URLEncode ();
83+ assertEquals (urlEncode .process (URL ), URLEncoder .encode (URL , "UTF-8" ));
84+ }
6785
6886}
0 commit comments