KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > dom4j > datatype > TestDataTypes


1 /*
2  * Copyright 2001 (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  * $Id: TestDataTypes.java,v 1.1 2003/07/07 10:30:29 per_nyfelt Exp $
8  */

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

31 public class TestDataTypes extends AbstractDataTypeTest {
32
33     public static void main( String JavaDoc[] args ) {
34         TestRunner.run( suite() );
35     }
36
37     public static Test suite() {
38         return new TestSuite( TestDataTypes.class );
39     }
40
41     public TestDataTypes(String JavaDoc name) {
42         super(name);
43     }
44
45     // Test case(s)
46
//-------------------------------------------------------------------------
47

48 /*
49     public void testDuration() throws Exception {
50         testNodes( "//durationTag", Calendar.class );
51     }
52     public void testgMonthDay() throws Exception {
53         testNodes( "//gMonthDayTag", Calendar.class );
54     }
55     public void testgDay() throws Exception {
56         testNodes( "//gDayTag", Calendar.class );
57     }
58     public void testgMonth() throws Exception {
59         testNodes( "//gMonthTag", Calendar.class );
60     }
61 */

62
63     public void testDate() throws Exception JavaDoc {
64         testNodes( "//dateTag", Calendar JavaDoc.class );
65     }
66
67     public void testTime() throws Exception JavaDoc {
68         testNodes( "//timeTag", Calendar JavaDoc.class );
69     }
70     public void testDateTime() throws Exception JavaDoc {
71         testNodes( "//dateTimeTag", Calendar JavaDoc.class );
72     }
73
74     public void testgYearMonth() throws Exception JavaDoc {
75         testNodes( "//gYearMonthTag", Calendar JavaDoc.class );
76     }
77     public void testgYear() throws Exception JavaDoc {
78         testNodes( "//gYearTag", Calendar JavaDoc.class );
79     }
80
81
82     public void testBoolean() throws Exception JavaDoc {
83         testNodes( "//booleanTag", Boolean JavaDoc.class );
84     }
85
86     public void testBase64Binary() throws Exception JavaDoc {
87         testNodes( "//base64BinaryTag", byte[].class );
88     }
89     public void testHexBinary() throws Exception JavaDoc {
90         testNodes( "//hexBinaryTag", byte[].class );
91     }
92
93
94
95
96     // Number types
97

98     public void testFloat() throws Exception JavaDoc {
99         testNodes( "//floatTag", Float JavaDoc.class );
100     }
101     public void testDouble() throws Exception JavaDoc {
102         testNodes( "//doubleTag", Double JavaDoc.class );
103     }
104
105
106     public void testDecimal() throws Exception JavaDoc {
107         testNodes( "//decimalTag", BigDecimal JavaDoc.class );
108     }
109
110     public void testInteger() throws Exception JavaDoc {
111         testNodes( "//integerTag", BigInteger JavaDoc.class );
112     }
113
114
115     public void testNonPositiveInteger() throws Exception JavaDoc {
116         testNodes( "//nonPositiveIntegerTag", BigInteger JavaDoc.class );
117     }
118
119     public void testNegativeInteger() throws Exception JavaDoc {
120         testNodes( "//negativeIntegerTag", BigInteger JavaDoc.class );
121     }
122
123     public void testLong() throws Exception JavaDoc {
124         testNodes( "//longTag", Long JavaDoc.class );
125     }
126     public void testInt() throws Exception JavaDoc {
127         testNodes( "//intTag", Integer JavaDoc.class );
128     }
129     public void testShort() throws Exception JavaDoc {
130         testNodes( "//shortTag", Short JavaDoc.class );
131     }
132     public void testByte() throws Exception JavaDoc {
133         testNodes( "//byteTag", Byte JavaDoc.class );
134     }
135
136     public void testNonNegativeInteger() throws Exception JavaDoc {
137         testNodes( "//nonNegativeIntegerTag", BigInteger JavaDoc.class );
138     }
139
140     public void testUnsignedLong() throws Exception JavaDoc {
141         testNodes( "//unsignedLongTag", BigInteger JavaDoc.class );
142     }
143
144     public void testUnsignedInt() throws Exception JavaDoc {
145         testNodes( "//unsignedIntTag", Long JavaDoc.class );
146     }
147     public void testUnsignedShort() throws Exception JavaDoc {
148         testNodes( "//unsignedShortTag", Integer JavaDoc.class );
149     }
150     public void testUnsignedByte() throws Exception JavaDoc {
151         testNodes( "//unsignedByteTag", Short JavaDoc.class );
152     }
153
154     public void testPositiveInteger() throws Exception JavaDoc {
155         testNodes( "//positiveIntegerTag", BigInteger JavaDoc.class );
156     }
157
158     // Implementation methods
159
//-------------------------------------------------------------------------
160
protected void setUp() throws Exception JavaDoc {
161         // todo create an ozone version of the factory
162
DocumentFactory factory = DatatypeDocumentFactory.getInstance();
163         SAXReader reader = new SAXReader( factory );
164         Document document = reader.read( "xml/test/schema/test.xml" );
165     }
166 }
167
168
169
170
171 /*
172  * Redistribution and use of this software and associated documentation
173  * ("Software"), with or without modification, are permitted provided
174  * that the following conditions are met:
175  *
176  * 1. Redistributions of source code must retain copyright
177  * statements and notices. Redistributions must also contain a
178  * copy of this document.
179  *
180  * 2. Redistributions in binary form must reproduce the
181  * above copyright notice, this list of conditions and the
182  * following disclaimer in the documentation and/or other
183  * materials provided with the distribution.
184  *
185  * 3. The name "DOM4J" must not be used to endorse or promote
186  * products derived from this Software without prior written
187  * permission of MetaStuff, Ltd. For written permission,
188  * please contact dom4j-info@metastuff.com.
189  *
190  * 4. Products derived from this Software may not be called "DOM4J"
191  * nor may "DOM4J" appear in their names without prior written
192  * permission of MetaStuff, Ltd. DOM4J is a registered
193  * trademark of MetaStuff, Ltd.
194  *
195  * 5. Due credit should be given to the DOM4J Project
196  * (http://dom4j.org/).
197  *
198  * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS
199  * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
200  * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
201  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
202  * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
203  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
204  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
205  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
206  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
207  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
208  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
209  * OF THE POSSIBILITY OF SUCH DAMAGE.
210  *
211  * Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved.
212  *
213  * $Id: TestDataTypes.java,v 1.1 2003/07/07 10:30:29 per_nyfelt Exp $
214  */

215
Popular Tags