KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > dom4j > datatype > DataTypesTest


1 /*
2  * Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
3  *
4  * This software is open source.
5  * See the bottom of this file for the licence.
6  */

7
8 package org.dom4j.datatype;
9
10 import junit.textui.TestRunner;
11
12 import java.math.BigDecimal JavaDoc;
13 import java.math.BigInteger JavaDoc;
14 import java.util.Calendar JavaDoc;
15
16 import org.dom4j.DocumentFactory;
17 import org.dom4j.io.SAXReader;
18
19 /**
20  * Test harness to test the various data types supported in the XML Schema Data
21  * Type integration.
22  *
23  * @author <a HREF="mailto:jstrachan@apache.org">James Strachan </a>
24  * @version $Revision: 1.4 $
25  */

26 public class DataTypesTest extends AbstractDataTypeTestCase {
27     public static void main(String JavaDoc[] args) {
28         TestRunner.run(DataTypesTest.class);
29     }
30
31     // Test case(s)
32
// -------------------------------------------------------------------------
33
public void testgMonthDay() throws Exception JavaDoc {
34         testNodes("//gMonthDayTag", Calendar JavaDoc.class);
35     }
36
37     public void testgDay() throws Exception JavaDoc {
38         testNodes("//gDayTag", Calendar JavaDoc.class);
39     }
40
41     public void testgMonth() throws Exception JavaDoc {
42         testNodes("//gMonthTag", Calendar JavaDoc.class);
43     }
44
45     public void testDate() throws Exception JavaDoc {
46         testNodes("//dateTag", Calendar JavaDoc.class);
47     }
48
49     public void testTime() throws Exception JavaDoc {
50         testNodes("//timeTag", Calendar JavaDoc.class);
51     }
52
53     public void testDateTime() throws Exception JavaDoc {
54         testNodes("//dateTimeTag", Calendar JavaDoc.class);
55     }
56
57     public void testgYearMonth() throws Exception JavaDoc {
58         testNodes("//gYearMonthTag", Calendar JavaDoc.class);
59     }
60
61     public void testgYear() throws Exception JavaDoc {
62         testNodes("//gYearTag", Calendar JavaDoc.class);
63     }
64
65     public void testBoolean() throws Exception JavaDoc {
66         testNodes("//booleanTag", Boolean JavaDoc.class);
67     }
68
69     public void testBase64Binary() throws Exception JavaDoc {
70         testNodes("//base64BinaryTag", byte[].class);
71     }
72
73     public void testHexBinary() throws Exception JavaDoc {
74         testNodes("//hexBinaryTag", byte[].class);
75     }
76
77     // Number types
78
public void testFloat() throws Exception JavaDoc {
79         testNodes("//floatTag", Float JavaDoc.class);
80     }
81
82     public void testDouble() throws Exception JavaDoc {
83         testNodes("//doubleTag", Double JavaDoc.class);
84     }
85
86     public void testDecimal() throws Exception JavaDoc {
87         testNodes("//decimalTag", BigDecimal JavaDoc.class);
88     }
89
90     public void testInteger() throws Exception JavaDoc {
91         testNodes("//integerTag", BigInteger JavaDoc.class);
92     }
93
94     public void testNonPositiveInteger() throws Exception JavaDoc {
95         testNodes("//nonPositiveIntegerTag", BigInteger JavaDoc.class);
96     }
97
98     public void testNegativeInteger() throws Exception JavaDoc {
99         testNodes("//negativeIntegerTag", BigInteger JavaDoc.class);
100     }
101
102     public void testLong() throws Exception JavaDoc {
103         testNodes("//longTag", Long JavaDoc.class);
104     }
105
106     public void testInt() throws Exception JavaDoc {
107         testNodes("//intTag", Integer JavaDoc.class);
108     }
109
110     public void testShort() throws Exception JavaDoc {
111         testNodes("//shortTag", Short JavaDoc.class);
112     }
113
114     public void testByte() throws Exception JavaDoc {
115         testNodes("//byteTag", Byte JavaDoc.class);
116     }
117
118     public void testNonNegativeInteger() throws Exception JavaDoc {
119         testNodes("//nonNegativeIntegerTag", BigInteger JavaDoc.class);
120     }
121
122     public void testUnsignedLong() throws Exception JavaDoc {
123         testNodes("//unsignedLongTag", BigInteger JavaDoc.class);
124     }
125
126     public void testUnsignedInt() throws Exception JavaDoc {
127         testNodes("//unsignedIntTag", Long JavaDoc.class);
128     }
129
130     public void testUnsignedShort() throws Exception JavaDoc {
131         testNodes("//unsignedShortTag", Integer JavaDoc.class);
132     }
133
134     public void testUnsignedByte() throws Exception JavaDoc {
135         testNodes("//unsignedByteTag", Short JavaDoc.class);
136     }
137
138     public void testPositiveInteger() throws Exception JavaDoc {
139         testNodes("//positiveIntegerTag", BigInteger JavaDoc.class);
140     }
141
142     // Implementation methods
143
// -------------------------------------------------------------------------
144
protected void setUp() throws Exception JavaDoc {
145         super.setUp();
146
147         DocumentFactory factory = DatatypeDocumentFactory.getInstance();
148         SAXReader reader = new SAXReader(factory);
149         document = getDocument("/xml/test/schema/test.xml", reader);
150     }
151 }
152
153 /*
154  * Redistribution and use of this software and associated documentation
155  * ("Software"), with or without modification, are permitted provided that the
156  * following conditions are met:
157  *
158  * 1. Redistributions of source code must retain copyright statements and
159  * notices. Redistributions must also contain a copy of this document.
160  *
161  * 2. Redistributions in binary form must reproduce the above copyright notice,
162  * this list of conditions and the following disclaimer in the documentation
163  * and/or other materials provided with the distribution.
164  *
165  * 3. The name "DOM4J" must not be used to endorse or promote products derived
166  * from this Software without prior written permission of MetaStuff, Ltd. For
167  * written permission, please contact dom4j-info@metastuff.com.
168  *
169  * 4. Products derived from this Software may not be called "DOM4J" nor may
170  * "DOM4J" appear in their names without prior written permission of MetaStuff,
171  * Ltd. DOM4J is a registered trademark of MetaStuff, Ltd.
172  *
173  * 5. Due credit should be given to the DOM4J Project - http://www.dom4j.org
174  *
175  * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS ``AS IS'' AND
176  * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
177  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
178  * ARE DISCLAIMED. IN NO EVENT SHALL METASTUFF, LTD. OR ITS CONTRIBUTORS BE
179  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
180  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
181  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
182  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
183  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
184  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
185  * POSSIBILITY OF SUCH DAMAGE.
186  *
187  * Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
188  */

189
Popular Tags