KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > xml > xmlc > html > EncodingTests


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  *
21  * $Id: EncodingTests.java,v 1.2 2005/01/26 08:29:25 jkjome Exp $
22  */

23
24 package org.enhydra.xml.xmlc.html;
25 import java.lang.reflect.Method JavaDoc;
26
27 import junit.framework.Test;
28
29 import org.enhydra.xml.xmlc.driver.ExecXmlc;
30
31 /**
32  * Tests of character set and encoding.
33  */

34 public class EncodingTests extends HtmlTestCaseBase {
35
36     /** Factory method to create suite of these tests */
37     public static Test suite() {
38         return createSuite(EncodingTests.class, null);
39     }
40     
41     /** Constructor */
42     public EncodingTests(Method JavaDoc method) {
43         super(method);
44     }
45
46     /** Create a new test object with encoding */
47     private HtmlBasicTest createTest(String JavaDoc encoding,
48                                      String JavaDoc inputDoc) {
49         HtmlBasicTest test = createTest(inputDoc);
50         test.getOutputOptions().setEncoding(encoding);
51         test.addBoth(ExecXmlc.OPT_HTML_ENCODING, encoding);
52         return test;
53     }
54
55     /*
56      * Test 1: Chinese big-5 (This page has illegal HTML and tidy
57      * discards several bogus constructs).
58      */

59     public void test1() {
60         HtmlBasicTest test = createTest("BIG5",
61                                         "encodings/newscontent_big5.html");
62         test.basicTest();
63     }
64
65     /*
66      * Test 2: Chinese big-5
67      */

68     public void test2() {
69         HtmlBasicTest test = createTest("BIG5",
70                                         "encodings/big5.page1.html");
71         test.basicTest();
72     }
73
74     /*
75      * Test 3: Chinese GB
76      */

77     public void test3() {
78         HtmlBasicTest test = createTest("GB2312",
79                                         "encodings/gb.page1.html");
80         test.basicTest();
81     }
82
83     /*
84      * Test 4: Japanese
85      */

86     public void test4() {
87         HtmlBasicTest test = createTest("ISO-2022-JP",
88                                         "encodings/iso-2022-jp.page1.html");
89         
90         // FIXME: reversing the test in the page generates an invalid
91
// character that generates an error when java reads it. Not sure
92
// why, as should be ok. Just disable for now, as it's a test issue
93
// not an issue with the code being tests.
94
test.setEditReloadSource(false);
95
96         test.basicTest();
97     }
98
99     /*
100      * Test 5: Windows Thai MS874
101      */

102     public void test5() {
103         // (FIXME: Don't have a HTML file for this)
104
}
105
106     /*
107      * Test 6: Chinese big-5 with -ssi
108      */

109     public void test6() {
110         HtmlBasicTest test = createTest("BIG5",
111                                         "encodings/newscontent_ssi_big5.html");
112         test.addFirst(ExecXmlc.OPT_SSI);
113         test.basicTest();
114     }
115
116     /*
117      * Test 7: Emoji characters
118      */

119     public void test7() {
120         HtmlBasicTest test = createTest("Shift_JIS",
121                                         "encodings/emoji.chtml");
122         test.basicTest();
123     }
124 }
125
Popular Tags