1
2
3
4
5
6
7
8
9
10 package org.dom4j.datatype;
11
12 import java.math.BigDecimal;
13 import java.math.BigInteger;
14 import java.net.URL;
15 import java.util.Calendar;
16
17 import junit.framework.Test;
18 import junit.framework.TestSuite;
19 import junit.textui.TestRunner;
20
21 import org.dom4j.DocumentFactory;
22 import org.dom4j.io.SAXReader;
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.6 $
30 */
31 public class TestDataTypes extends AbstractDataTypeTest {
32
33 public static void main( String[] args ) {
34 TestRunner.run( suite() );
35 }
36
37 public static Test suite() {
38 return new TestSuite( TestDataTypes.class );
39 }
40
41 public TestDataTypes(String name) {
42 super(name);
43 }
44
45
46
47
48 public void testgMonthDay() throws Exception {
49 testNodes( "//gMonthDayTag", Calendar.class );
50 }
51 public void testgDay() throws Exception {
52 testNodes( "//gDayTag", Calendar.class );
53 }
54 public void testgMonth() throws Exception {
55 testNodes( "//gMonthTag", Calendar.class );
56 }
57
58
59 public void testDate() throws Exception {
60 testNodes( "//dateTag", Calendar.class );
61 }
62
63 public void testTime() throws Exception {
64 testNodes( "//timeTag", Calendar.class );
65 }
66 public void testDateTime() throws Exception {
67 testNodes( "//dateTimeTag", Calendar.class );
68 }
69
70 public void testgYearMonth() throws Exception {
71 testNodes( "//gYearMonthTag", Calendar.class );
72 }
73 public void testgYear() throws Exception {
74 testNodes( "//gYearTag", Calendar.class );
75 }
76
77
78 public void testBoolean() throws Exception {
79 testNodes( "//booleanTag", Boolean.class );
80 }
81
82 public void testBase64Binary() throws Exception {
83 testNodes( "//base64BinaryTag", byte[].class );
84 }
85 public void testHexBinary() throws Exception {
86 testNodes( "//hexBinaryTag", byte[].class );
87 }
88
89
90
91
92
93
94 public void testFloat() throws Exception {
95 testNodes( "//floatTag", Float.class );
96 }
97 public void testDouble() throws Exception {
98 testNodes( "//doubleTag", Double.class );
99 }
100
101
102 public void testDecimal() throws Exception {
103 testNodes( "//decimalTag", BigDecimal.class );
104 }
105
106 public void testInteger() throws Exception {
107 testNodes( "//integerTag", BigInteger.class );
108 }
109
110
111 public void testNonPositiveInteger() throws Exception {
112 testNodes( "//nonPositiveIntegerTag", BigInteger.class );
113 }
114
115 public void testNegativeInteger() throws Exception {
116 testNodes( "//negativeIntegerTag", BigInteger.class );
117 }
118
119 public void testLong() throws Exception {
120 testNodes( "//longTag", Long.class );
121 }
122 public void testInt() throws Exception {
123 testNodes( "//intTag", Integer.class );
124 }
125 public void testShort() throws Exception {
126 testNodes( "//shortTag", Short.class );
127 }
128 public void testByte() throws Exception {
129 testNodes( "//byteTag", Byte.class );
130 }
131
132 public void testNonNegativeInteger() throws Exception {
133 testNodes( "//nonNegativeIntegerTag", BigInteger.class );
134 }
135
136 public void testUnsignedLong() throws Exception {
137 testNodes( "//unsignedLongTag", BigInteger.class );
138 }
139
140 public void testUnsignedInt() throws Exception {
141 testNodes( "//unsignedIntTag", Long.class );
142 }
143 public void testUnsignedShort() throws Exception {
144 testNodes( "//unsignedShortTag", Integer.class );
145 }
146 public void testUnsignedByte() throws Exception {
147 testNodes( "//unsignedByteTag", Short.class );
148 }
149
150 public void testPositiveInteger() throws Exception {
151 testNodes( "//positiveIntegerTag", BigInteger.class );
152 }
153
154
155
156 protected void setUp() throws Exception {
157 DocumentFactory factory = DatatypeDocumentFactory.getInstance();
158 SAXReader reader = new SAXReader( factory );
159 URL url = getClass().getResource("/xml/test/schema/test.xml");
160 document = reader.read(url);
161 }
162 }
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210