KickJava   Java API By Example, From Geeks To Geeks.

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


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: CornerCasesTests.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.driver.TestDiff;
30 import org.enhydra.xml.xmlc.driver.ExecXmlc;
31
32 /**
33  * Tests of of various special cases, many that caused bugs. Not all work with
34  * the swing parser.
35  */

36 public class CornerCasesTests extends HtmlTestCaseBase {
37     /** Factory method to create suite of these tests */
38     public static Test suite() {
39         return createSuite(CornerCasesTests.class, null);
40     }
41     
42     /** Constructor */
43     public CornerCasesTests(Method JavaDoc method) {
44         super(method);
45     }
46
47     /*
48      * Test 1: special characters in attributes, urlmappings, and
49      * invalid names in form input.
50      */

51     public void test1() {
52         HtmlBasicTest test = createTest("testPage1.html");
53         test.addOptionFile(getInputFile("testPage1.xmlc"));
54         test.basicTest();
55     }
56
57     /*
58      * Test 2: head tag parsing
59      */

60     public void test2() {
61         HtmlBasicTest test = createTest("testPage2.html");
62         test.basicTest();
63     }
64
65     /*
66      * Test 3: two forms
67      */

68     public void test3() {
69         HtmlBasicTest test = createTest("Form2.html");
70         test.basicTest();
71     }
72
73     /*
74      * Test 4: weird name attributes
75      */

76     public void test4() {
77         HtmlBasicTest test = createTest("testPage3.html");
78         test.basicTest();
79     }
80
81     /*
82      * Test 5: form contain P tags
83      */

84     public void test5() {
85         // Swing parse can't handle this
86
if (!fParams.getParser().equals(ExecXmlc.SWING_PARSER)) {
87             HtmlBasicTest test = createTest("formWithPs.html");
88             test.basicTest();
89         }
90     }
91
92
93     /*
94      * Test 6: form containing BR tags
95      */

96     public void test6() {
97         HtmlBasicTest test = createTest("formWithBRs.html");
98         test.basicTest();
99     }
100
101     /*
102      * Test 8: name and class name constant generation
103      */

104     public void test8() {
105         HtmlBasicTest test = createTest("testPage4.html");
106         test.basicTest();
107     }
108
109     /*
110      * Test 9: Swing parser mangled iframes.
111      */

112     public void test9() {
113         HtmlBasicTest test = createTest("iframe.html");
114         test.basicTest();
115     }
116
117     /*
118      * Test 10: Deleting elements by class
119      */

120     public void test10() {
121         HtmlBasicTest test = createTest("DeleteByClass.html");
122         test.addFirst(ExecXmlc.OPT_DELETE_CLASS, "deleteMe");
123         test.basicTest();
124     }
125
126     /*
127      * Test 11: Tests for various parsing related bugs
128      */

129     public void test11() {
130         HtmlBasicTest test = createTest("testPage5.html");
131         test.basicTest();
132     }
133
134     /*
135      * Test 12: Entity problems (attribute values, etc).
136      */

137     public void test12() {
138         HtmlBasicTest test = createTest("testPage6.html");
139         test.basicTest();
140
141         // Check different files in reloading tests
142
TestDiff differ = getDiffer();
143         differ.fgrepMustFind("value=\"æ, ø and å\"",
144                              test.getGenerateFile());
145         differ.fgrepMustFind("value=\"æ, ø and å\"",
146                                  test.getRegenerateFile());
147     }
148
149     /*
150      * Test 13: Lazy DOM broke when non-standard attribute names
151      * contained `:'. This will not work with the Swing parser.
152      */

153     public void test13() {
154         // Swing parse can't handle this
155
if (!fParams.getParser().equals(ExecXmlc.SWING_PARSER)) {
156             HtmlBasicTest test = createTest("namespace-like.html");
157             test.basicTest();
158         }
159     }
160
161     /*
162      * Test 14: more non-standard attribute names.
163      */

164     public void test14() {
165         HtmlBasicTest test = createTest("namespace-like2.html");
166         test.addOptionFile(getInputFile("namespace-like2.xmlc"));
167         if (fParams.getParser().equals(ExecXmlc.SWING_PARSER)) {
168             // Swing parse can't handle this document
169
test.setCompileShouldFail();
170         }
171         test.basicTest();
172     }
173
174     /*
175      * Test 15: Handling of style elements. This broke in older versions
176      * of the Swing parser, which only worked if the contents were in
177      * a comment. It appears to be working now.
178      */

179     public void test15() {
180         HtmlBasicTest test = createTest("style1.html");
181         test.basicTest();
182     }
183
184     /*
185      * Test 16: Style, contents in comment
186      */

187     public void test16() {
188         HtmlBasicTest test = createTest("style2.html");
189         test.basicTest();
190     }
191     /*
192      * Test 17: Problems with spacing being different in generated HTML.
193      */

194     public void test17() {
195         HtmlBasicTest test = createTest("space-bug1.html");
196         test.basicTest();
197     }
198
199     /*
200      * Test 18: Someone reported that newlines in <A> body didn't work.
201      */

202     public void test18() {
203         HtmlBasicTest test = createTest("href-spaces.html");
204         test.basicTest();
205     }
206
207     /*
208      * Test 19: Broken document exported from Word caused an endless
209      * loop in Tidy parser. Swing can't handle it.
210      */

211     public void test19() {
212         HtmlBasicTest test = createTest("caused-hang.html");
213         if (fParams.getParser().equals(ExecXmlc.SWING_PARSER)) {
214             test.setCompileShouldFail();
215         }
216         test.basicTest();
217     }
218
219     /*
220      * Test 20: Javascript quoting
221      */

222     public void test20() {
223         HtmlBasicTest test = createTest("javascript2.html");
224         test.addCyberStudioTags();
225         test.basicTest();
226     }
227 }
228
Popular Tags