KickJava   Java API By Example, From Geeks To Geeks.

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


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: IOTests.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 import java.net.MalformedURLException JavaDoc;
28 import java.net.URL JavaDoc;
29
30 import junit.framework.Test;
31
32 import org.enhydra.xml.driver.TestError;
33
34 /**
35  * Tests of input/output related functionality.
36  */

37 public class IOTests extends HtmlTestCaseBase {
38     /** file: url of testpage1 */
39     private String JavaDoc fTestPage1Url
40         = "file:" + getInputFile("testPage1.html").getPath();
41
42     /** Factory method to create suite of these tests */
43     public static Test suite() {
44         return createSuite(IOTests.class, null);
45     }
46     
47     /** Constructor */
48     public IOTests(Method JavaDoc method) {
49         super(method);
50     }
51
52     /** Create a new test object */
53     private HtmlBasicTest setupTest(File JavaDoc inputDoc) {
54         return new HtmlBasicTest(this, inputDoc);
55     }
56
57     /** Create a new test object from a URL */
58     private HtmlBasicTest setupTest(String JavaDoc inputDocURL) {
59         try {
60             URL JavaDoc url = new URL JavaDoc(inputDocURL);
61             return setupTest(new File JavaDoc(url.getFile()));
62         } catch (MalformedURLException JavaDoc except) {
63             throw new TestError(except);
64         }
65     }
66
67     /** Create a new test object for testPage1 */
68     private HtmlBasicTest setupTest() {
69         return setupTest(fTestPage1Url);
70     }
71
72     /*
73      * Test 1: explicit file URI
74      */

75     private void disabled_test1() {
76         // FIXME: Disabled, don't know how to test with input dir mapping
77
HtmlBasicTest test = setupTest();
78         test.basicTest();
79     }
80
81     /*
82      * Test 2: ../xxx relative file
83      */

84     private void disabled_test2() {
85         // FIXME: Disabled, don't know how to test with input dir mapping
86
// HtmlBasicTest test = setupTest("../html/input/testPage1.html");
87
// test.basicTest();
88
}
89
90     /*
91      * Test 3: ../../xxx relative file.
92      */

93     private void disabled_test3() {
94         // FIXME: Disabled, don't know how to test with input dir mapping
95
// HtmlBasicTest test = setupTest("../../xmlc/html/input/testPage1.html");
96
// test.basicTest();
97
}
98
99     /*
100      * Test 4: specifying public id
101      */

102     public void test4() {
103         HtmlBasicTest test = setupTest();
104         test.getOutputOptions().setPublicId("-publicid -//W3C//DTD@HTML@4.0//EN");
105         test.basicTest();
106     }
107
108     /*
109      * Test 5: specifying public and system id
110      */

111     public void test5() {
112         HtmlBasicTest test = setupTest();
113         test.getOutputOptions().setPublicId("-//W3C//DTD@HTML@4.0//EN");
114         test.getOutputOptions().setSystemId("http://www.w3.org/TR/html4/strict.dtd");
115         test.basicTest();
116     }
117
118     /*
119      * Test 6: specifying system id
120      */

121     public void test6() {
122         HtmlBasicTest test = setupTest();
123         test.getOutputOptions().setSystemId("http://www.w3.org/TR/html4/strict.dtd");
124         test.basicTest();
125     }
126 }
127
Popular Tags