KickJava   Java API By Example, From Geeks To Geeks.

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


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: ErrorHandlingTests.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.xmlc.driver.ExecXmlc;
31
32 /**
33  * Tests of error handling. Several problems are only generate errors with
34  * swing.
35 f */

36 public class ErrorHandlingTests extends HtmlTestCaseBase {
37
38     /** Factory method to create suite of these tests */
39     public static Test suite() {
40         return createSuite(ErrorHandlingTests.class, null);
41     }
42     
43     /** Constructor */
44     public ErrorHandlingTests(Method JavaDoc method) {
45         super(method);
46     }
47
48     /*
49      * Test 1: Java script not in comment (will not work with swing parser)
50      */

51     public void test1() {
52         HtmlBasicTest test = createTest("javascript1.html");
53         // Using swing parser should give an error.
54
if (fParams.getParser().equals(ExecXmlc.SWING_PARSER)) {
55             test.setCompileShouldFail();
56         }
57         test.basicTest();
58     }
59
60     /*
61      * Test 2:
62      */

63     public void test2() {
64         HtmlBasicTest test = createTest("bogus1.html");
65         // Using swing parser should give an error.
66
if (fParams.getParser().equals(ExecXmlc.SWING_PARSER)) {
67             test.setCompileShouldFail();
68         }
69         test.basicTest();
70     }
71
72     /*
73      * Test 3:
74      */

75     public void test3() {
76         HtmlBasicTest test = createTest("bogus2.html");
77         // Using swing parser should give an error.
78
if (fParams.getParser().equals(ExecXmlc.SWING_PARSER)) {
79             test.setCompileShouldFail();
80         }
81         test.addCyberStudioTags();
82         test.basicTest();
83     }
84
85     /*
86      * Test 4: Attempt to parse a XML file
87      */

88     public void test4() {
89         File JavaDoc insulin3 = getOtherInputFile("../xml", "bioml/insulin3.bioml");
90         HtmlBasicTest test = createTest(insulin3);
91         test.setCompileShouldFail();
92         test.basicTest();
93     }
94
95     /*
96      * Test 5: Bogus use of XML empty content tag in HTML
97      * (swing doesn't report error, Tidy was hanging).
98      */

99     public void disable_test5() {
100         // FIXME: Tidy isn't reporting an error either, just disable this
101
// test
102
HtmlBasicTest test = createTest("bogusTag.html");
103         // not detected by swing
104
if (!fParams.getParser().equals(ExecXmlc.SWING_PARSER)) {
105             test.setCompileShouldFail();
106         }
107         test.basicTest();
108     }
109 }
110
Popular Tags