KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > util > ISO9075Test


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.util;
18
19 import junit.framework.TestCase;
20
21 public class ISO9075Test extends TestCase
22 {
23
24     public ISO9075Test()
25     {
26         super();
27     }
28
29     public ISO9075Test(String JavaDoc arg0)
30     {
31         super(arg0);
32     }
33
34     public void testEncoding()
35     {
36         assertEquals("MyDocuments", ISO9075.encode("MyDocuments"));
37         assertEquals("My_x002f_Documents", ISO9075.encode("My/Documents"));
38         assertEquals("My_Documents", ISO9075.encode("My_Documents"));
39         assertEquals("My_x0020_Documents", ISO9075.encode("My Documents"));
40         assertEquals("My_x0020Documents", ISO9075.encode("My_x0020Documents"));
41         assertEquals("My_x005f_x0020_Documents", ISO9075.encode("My_x0020_Documents"));
42         assertEquals("_x005f_x0020_Documents", ISO9075.encode("_x0020_Documents"));
43         assertEquals("_x0040__x005f_x0020_Documents", ISO9075.encode("@_x0020_Documents"));
44         assertEquals("Andy_x0027_s_x0020_Bits_x0020__x0026__x0020_Bobs_x0020__xabcd__x005c_", ISO9075
45                 .encode("Andy's Bits & Bobs \uabcd\\"));
46         assertEquals(
47                 "_x0020__x0060__x00ac__x00a6__x0021__x0022__x00a3__x0024__x0025__x005e__x0026__x002a__x0028__x0029_-__x003d__x002b__x0009__x000a__x005c__x0000__x005b__x005d__x007b__x007d__x003b__x0027__x0023__x003a__x0040__x007e__x002c_._x002f__x003c__x003e__x003f__x005c__x007c_",
48                 ISO9075.encode(" `¬¦!\"£$%^&*()-_=+\t\n\\\u0000[]{};'#:@~,./<>?\\|"));
49         assertEquals("\u0123_x4567_\u8900_xabcd__xefff__xT65A_", ISO9075.encode("\u0123\u4567\u8900\uabcd\uefff_xT65A_"));
50         assertEquals("_x003a_", ISO9075.encode(":"));
51     }
52
53     public void testDeEncoding()
54     {
55         assertEquals("MyDocuments", ISO9075.decode("MyDocuments"));
56         assertEquals("My_Documents", ISO9075.decode("My_Documents"));
57         assertEquals("My Documents", ISO9075.decode("My_x0020_Documents"));
58         assertEquals("My_x0020Documents", ISO9075.decode("My_x0020Documents"));
59         assertEquals("My_x0020_Documents", ISO9075.decode("My_x005f_x0020_Documents"));
60         assertEquals("_x0020_Documents", ISO9075.decode("_x005f_x0020_Documents"));
61         assertEquals("@_x0020_Documents", ISO9075.decode("_x0040__x005f_x0020_Documents"));
62         assertEquals("Andy's Bits & Bobs \uabcd", ISO9075
63                 .decode("Andy_x0027_s_x0020_Bits_x0020__x0026__x0020_Bobs_x0020__xabcd_"));
64         assertEquals("Andy's Bits & Bobs \uabcd\\", ISO9075
65                 .decode("Andy_x0027_s_x0020_Bits_x0020__x0026__x0020_Bobs_x0020__xabcd__x005c_"));
66         assertEquals(
67                 " `¬¦!\"£$%^&*()-_=+\t\n\\\u0000[]{};'#:@~,./<>?\\|",
68                 ISO9075
69                         .decode("_x0020__x0060__x00ac__x00a6__x0021__x0022__x00a3__x0024__x0025__x005e__x0026__x002a__x0028__x0029_-__x003d__x002b__x0009__x000a__x005c__x0000__x005b__x005d__x007b__x007d__x003b__x0027__x0023__x003a__x0040__x007e__x002c_._x002f__x003c__x003e__x003f__x005c__x007c_"));
70         assertEquals("\u0123\u4567\u8900\uabcd\uefff_xT65A_", ISO9075.decode("\u0123_x4567_\u8900_xabcd__xefff__xT65A_"));
71         System.out.println(" `¬¦!\"£$%^&*()-_=+\t\n\\\u0000[]{};'#:@~,./<>?\\|\u0123\u4567\u8900\uabcd\uefff_xT65A_");
72     }
73
74 }
75
Popular Tags