KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > urls > TestURICodec


1 package org.jahia.urls;
2
3 import junit.framework.*;
4 import org.jahia.services.database.*;
5 import java.io.*;
6
7 public class TestURICodec extends TestCase {
8     private URICodec uRICodec = null;
9
10     public TestURICodec(String JavaDoc name) {
11         super(name);
12     }
13
14     protected void setUp() throws Exception JavaDoc {
15         super.setUp();
16         /**@todo verify the constructors*/
17         uRICodec = new URICodec();
18     }
19
20     protected void tearDown() throws Exception JavaDoc {
21         uRICodec = null;
22         super.tearDown();
23     }
24
25     public void testEncode() throws UnsupportedEncodingException {
26         String JavaDoc input = null;
27         String JavaDoc encoding = null;
28         String JavaDoc authorizedChars = null;
29         String JavaDoc expectedReturn = null;
30         String JavaDoc actualReturn = uRICodec.encode(input, encoding, authorizedChars);
31         assertEquals("return value", expectedReturn, actualReturn);
32         /**@todo fill in the test code*/
33         input = "abcdef éàèäöü+_&%~ó;//_$*";
34         encoding = "ISO-8859-1";
35         actualReturn = uRICodec.decode(uRICodec.encode(input, encoding, URICodec.DEFAULT_AUTHORIZEDCHARS), encoding);
36         assertEquals("return value", input, actualReturn);
37         input = "abcdef éàèäöü+_&%~ó;//_$*";
38         encoding = "UTF-8";
39         actualReturn = uRICodec.decode(uRICodec.encode(input, encoding, URICodec.DEFAULT_AUTHORIZEDCHARS), encoding);
40         assertEquals("return value", input, actualReturn);
41     }
42
43 }
44
Popular Tags