KickJava   Java API By Example, From Geeks To Geeks.

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


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: BasicTests.java,v 1.2 2005/01/26 08:29:25 jkjome Exp $
22  */

23
24 package org.enhydra.xml.xmlc.html;
25 import java.io.File JavaDoc;
26 import java.lang.reflect.Method JavaDoc;
27
28 import junit.framework.Test;
29
30 import org.enhydra.xml.driver.TestDiff;
31 import org.enhydra.xml.xmlc.driver.ExecXmlc;
32
33 /**
34  * Tests of basic HTML functionality.
35  */

36 public class BasicTests extends HtmlTestCaseBase {
37
38     /** Factory method to create suite of these tests */
39     public static Test suite() {
40         return createSuite(BasicTests.class, null);
41     }
42     
43     /** Constructor */
44     public BasicTests(Method JavaDoc method) {
45         super(method);
46     }
47
48     /**
49      * Test 1: compile of HTML with non-standard tags and using
50      * an options file.
51      */

52     public void test1() {
53         HtmlBasicTest test = createLutrisIndexTest();
54         test.addOptionFile(getInputFile("lutris-index1.xmlc"));
55         test.basicTest();
56     }
57
58     /*
59      * Test 2: -urlmapping and -g option
60      */

61     public void test2() {
62         HtmlBasicTest test = createLutrisIndexTest();
63         test.addBoth(ExecXmlc.OPT_JAVAC_G);
64         test.addFirst(ExecXmlc.OPT_URL_MAPPING);
65         test.addFirst("TheCompany1.html", "TheCompany1.po");
66         test.addFirst(ExecXmlc.OPT_URL_MAPPING);
67         test.addFirst("ProfSrvcs1.html", "ProfSrvcs1.po");
68         test.setUseToDocument();
69         test.basicTest();
70     }
71
72     /*
73      * Test 3: -urlsetting and -g option
74      */

75     public void test3() {
76         HtmlBasicTest test = createTest("simple-href.html");
77         test.addFirst(ExecXmlc.OPT_URL_SETTING);
78         test.addFirst("testNode", "http://www.foo.com/");
79         test.basicTest();
80     }
81
82     /*
83      * Test 5: -urlregexpmapping in an option file
84      */

85     public void test5() {
86         HtmlBasicTest test = createLutrisIndexTest();
87         test.addOptionFile(getInputFile("LutrisIndex4.xmlc"));
88         test.setUseToDocument();
89         test.basicTest();
90     }
91
92     /*
93      * Test 6: File containing java script and a noscript tag.
94      */

95     public void test6() {
96         HtmlBasicTest test = createTest("CheckVersion.html");
97         test.basicTest();
98     }
99
100     /*
101      * Test 7: Two -urlregexpmapping
102      */

103     public void test7() {
104         HtmlBasicTest test = createLutrisIndexTest();
105         test.addBoth(ExecXmlc.OPT_JAVAC_G);
106         test.addFirst(ExecXmlc.OPT_URL_REGEXP_MAPPING);
107         test.addFirst("^(Th.+)\\.html$$", "$$1.po");
108         test.addFirst(ExecXmlc.OPT_URL_REGEXP_MAPPING);
109         test.addFirst("^(Pr.+)\\.html$$", "$$1.po");
110         test.basicTest();
111     }
112
113     /*
114      * Test 8: handling of special characters. This contains HTML 4.0
115      * additions, so the result will not be the same in every browser.
116      */

117     public void test8() {
118         HtmlBasicTest test = createTest("special-char.html");
119         test.basicTest();
120     }
121
122     /*
123      * Test 9: Test handling of special characters in attribute values,
124      * without using attribute entity references.
125      */

126     public void test9() {
127         HtmlBasicTest test = createTest("attributeValues.html");
128         test.getOutputOptions().setOmitAttributeCharEntityRefs(true);
129         test.basicTest();
130         File JavaDoc htmlFile = test.getGenerateFile();
131
132         TestDiff differ = getDiffer();
133         differ.fgrepMustFind("http://www.foo.bar/cgi-bin/pig3?a=b&c=d",
134                              htmlFile);
135         differ.fgrepMustFind("http://www.foo.bar/cgi-bin/pig4?a="&c=d",
136                              htmlFile);
137         differ.fgrepMustFind("http://www.foo.bar/cgi-bin/pig5?a="&c=d",
138                              htmlFile);
139     }
140
141     /*
142      * Test 10: Test handling of special characters in attribute values,
143      * using attribute entity references.
144      */

145     public void test10() {
146         HtmlBasicTest test = createTest("attributeValues.html");
147         test.getOutputOptions().setOmitAttributeCharEntityRefs(false);
148         test.basicTest();
149
150         File JavaDoc htmlFile = test.getGenerateFile();
151         TestDiff differ = getDiffer();
152         differ.fgrepMustFind("http://www.foo.bar/cgi-bin/pig3?a=b&c=d",
153                              htmlFile);
154         differ.fgrepMustFind("http://www.foo.bar/cgi-bin/pig4?a="&c=d",
155                              htmlFile);
156         differ.fgrepMustFind("http://www.foo.bar/cgi-bin/pig5?a="&c=d",
157                              htmlFile);
158     }
159
160     /*
161      * Test 11: Handling framesets
162      */

163     public void test11() {
164         HtmlBasicTest test = createTest("FrameSet.html");
165         test.basicTest();
166     }
167 }
168
Popular Tags