KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > xml > xmlc > xml > WMLTests


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

23
24 package org.enhydra.xml.xmlc.xml;
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.io.OutputOptions;
31
32 /**
33  * Test related to WML. This also tests several output options.
34  */

35 public class WMLTests extends XmlTestCaseBase {
36
37     /** Factory method to create suite of these tests */
38     public static Test suite() {
39         return createSuite(WMLTests.class, null);
40     }
41     
42     /** Constructor */
43     public WMLTests(Method JavaDoc method) {
44         super(method);
45     }
46
47     /** Create an test forf a WML document. */
48     private XmlBasicTest createWMLTest(String JavaDoc relInputDoc) {
49         return new XmlBasicTest(this, getInputFile(relInputDoc),
50                                 getInputFile("wml/wml_1.1.test.xml"));
51     }
52
53     /**
54      * Test 1: Encoded as ASCII, but omitting the encoding header.
55      * Encoding as ascii encodes non-ascii characters as &#nnn;
56      */

57     public void test1() {
58         XmlBasicTest test = createWMLTest("wml/index.wml");
59         OutputOptions options = test.getOutputOptions();
60         options.setEncoding("ASCII");
61         options.setOmitEncoding(true);
62         test.basicTest();
63             
64         String JavaDoc expectEntities = "民眾";
65         TestDiff differ = getDiffer();
66     differ.fgrepMustFind(expectEntities, test.getGenerateFile());
67     differ.fgrepMustNotFind("encoding", test.getGenerateFile());
68     }
69
70     /**
71      * Test 2: Specified encoding not being lost with toDocument()
72      */

73     public void test2() {
74         // OutputDocument uses toDocument() by default if no options
75
// are specified
76
XmlBasicTest test = createWMLTest("wml/encoding.wml");
77         test.setUseToDocument();
78         test.basicTest();
79     }
80
81     /**
82      * Test 3: & in attribute values.
83      */

84     public void test3() {
85         XmlBasicTest test = createWMLTest("wml/Login.wml");
86         test.basicTest();
87     }
88
89     /**
90      * Test 4: Test of empty tag content: <br></br>, as opposed to <br/>
91      */

92     public void test4() {
93         XmlBasicTest test = createWMLTest("wml/Login2.wml");
94         test.basicTest();
95     }
96 }
97
Popular Tags