16
16
17
17
package org .metafacture .metamorph .functions ;
18
18
19
+ import java .io .UnsupportedEncodingException ;
20
+ import java .net .URLEncoder ;
21
+
19
22
import static org .junit .Assert .*;
20
23
import org .junit .Test ;
21
24
@@ -31,10 +34,15 @@ public final class URLEncodeTest {
31
34
private static final String CAFE_ENCODED = "caf%C3%A9" ;
32
35
private static final String SOME_CHARS = "/&%\\ +" ;
33
36
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" ;
34
41
private static final String WHITESPACE = " " ;
35
42
private static final String WHITESPACE_AS_PLUS_ENCODED = "+" ;
36
43
private static final String WHITESPACE_PERCENT_ENCODED = "%20" ;
37
44
45
+ URLEncoder urlEncoder ;
38
46
@ Test
39
47
public void testUtf8 (){
40
48
final URLEncode urlEncode = new URLEncode ();
@@ -64,5 +72,15 @@ public void testSafeChars(){
64
72
urlEncode .setSafeChars (SOME_CHARS );
65
73
assertEquals (SOME_CHARS , urlEncode .process (SOME_CHARS ));
66
74
}
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
+ }
67
85
68
86
}
0 commit comments