KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > xml > xmlc > xml > 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.xml;
25 import java.io.File JavaDoc;
26 import java.lang.reflect.Method JavaDoc;
27
28 import junit.framework.Test;
29
30 /**
31  * Tests of basic XML functionality.
32  */

33 public class BasicTests extends XmlTestCaseBase {
34     /** Factory method to create suite of these tests */
35     public static Test suite() {
36         return createSuite(BasicTests.class, null);
37     }
38
39     /** Constructor */
40     public BasicTests(Method JavaDoc method) {
41         super(method);
42     }
43
44     /**
45      * Test 1: simple doc with no DTD.
46      */

47     public void test1() {
48         XmlBasicTest test
49             = new XmlBasicTest(this, getInputFile("simple/tiny.xml"), null);
50         test.noValidation();
51         test.setUseToDocument();
52         test.basicTest();
53     }
54
55     /**
56      * Test 2: doc with DTD
57      */

58     public void test2() {
59         XmlBasicTest test
60             = new XmlBasicTest(this, getInputFile("xml-examples/6-1.xml"), null);
61         test.basicTest();
62     }
63
64     /**
65      * Test 3: Document with lots of entities.
66      */

67     public void test3() {
68         XmlBasicTest test
69             = new XmlBasicTest(this, getInputFile("xml-examples/6-17.xml"), null);
70         // no text in main doc, so just touch
71
test.setEditReloadSource(false);
72
73         test.addXmlExampleCopyEntities();
74         test.basicTest();
75     }
76
77     /**
78      * Test 4: standalone document
79      */

80     public void test4() {
81         XmlBasicTest test
82             = new XmlBasicTest(this, getInputFile("xml-examples/7-3.xml"), null);
83         test.setUseToDocument();
84         test.basicTest();
85     }
86
87     /**
88      * Test 5: big document, the XML specification in XML
89      */

90     public void test5() {
91         XmlBasicTest test
92             = new XmlBasicTest(this, getInputFile("xml-spec/REC-xml-20001006.xml"),
93                                getInputFile("xml-spec/xmlspec-v21.dtd"));
94         test.basicTest();
95     }
96
97     /**
98      * Test 6: Comments/processing instructions before root element
99      */

100     public void test6() {
101         XmlBasicTest test
102             = new XmlBasicTest(this, getInputFile("bioml/small.bioml"),
103                                getInputFile("bioml/bioml.dtd"));
104         test.basicTest();
105     }
106
107     /**
108      * Test 7: Encoding test
109      */

110     public void test7() {
111         XmlBasicTest test
112             = new XmlBasicTest(this, getInputFile("xml-examples/6-17.ascii.xml"),
113                                null);
114         // no text in main doc, so just touch
115
test.setEditReloadSource(false);
116
117         test.addXmlExampleCopyEntities();
118         test.setExpectedEncoding("US-ASCII");
119         test.basicTest();
120     }
121
122     /**
123      * Test 8: Character entity references
124      */

125     public void test8() {
126         XmlBasicTest test
127             = new XmlBasicTest(this, getInputFile("simple/charEntities.xml"), null);
128         test.basicTest();
129     }
130
131     /**
132      * Test 9: Donated by# Chris Webb <chris.webb@voxsurf.com>, showing a
133      * large entity reference generating stack overflow in
134      * DOMBuilderGenerator.
135      */

136     public void test9() {
137         XmlBasicTest test
138             = new XmlBasicTest(this, getInputFile("bigentity/BigEntityTest.vxml"),
139                                getInputFile("bigentity/voicexml1-0.dtd"));
140         test.addExtraSrcFile(getInputFile("bigentity/BigEntity.ent"));
141         test.basicTest();
142     }
143
144     /**
145      * Test 10: Test trying to compile a HTML document with a xml parser.
146      */

147     public void test10() {
148         File JavaDoc inputFile = getOtherInputFile("../html", "testPage1.html");
149         XmlBasicTest test
150             = new XmlBasicTest(this, inputFile, null);
151         test.setCompileShouldFail();
152         test.basicTest();
153     }
154 }
155
Popular Tags