Line 0
Link Here
|
|
|
1 |
/******************************************************************************* |
2 |
* Copyright (c) 1998, 2008 Oracle. All rights reserved. |
3 |
* This program and the accompanying materials are made available under the |
4 |
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 |
5 |
* which accompanies this distribution. |
6 |
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html |
7 |
* and the Eclipse Distribution License is available at |
8 |
* http://www.eclipse.org/org/documents/edl-v10.php. |
9 |
* |
10 |
* Contributors: |
11 |
* bdoughan - Mar 17/2009 - 2.0 - Initial implementation |
12 |
******************************************************************************/ |
13 |
package org.eclipse.persistence.testing.sdo.helper.classgen.dynamicimpl; |
14 |
|
15 |
import java.io.InputStream; |
16 |
import java.math.BigDecimal; |
17 |
import java.math.BigInteger; |
18 |
import java.util.ArrayList; |
19 |
import java.util.List; |
20 |
|
21 |
import org.eclipse.persistence.testing.sdo.SDOTestCase; |
22 |
|
23 |
import commonj.sdo.DataObject; |
24 |
import commonj.sdo.Type; |
25 |
|
26 |
public class DataTypesTestCases extends SDOTestCase { |
27 |
|
28 |
private static String XSD = "org/eclipse/persistence/testing/sdo/helper/classgen/dynamicimpl/DataTypes.xsd"; |
29 |
|
30 |
private static Object CONTROL_OBJECT = "control"; |
31 |
private static String CONTROL_STRING = "control"; |
32 |
private static List CONTROL_STRINGS = new ArrayList(); |
33 |
private static boolean CONTROL_BOOLEAN = true; |
34 |
private static byte CONTROL_BYTE = 1; |
35 |
private static byte[] CONTROL_BYTES = new byte[0]; |
36 |
private static BigDecimal CONTROL_BIG_DECIMAL = BigDecimal.ONE; |
37 |
private static double CONTROL_DOUBLE = 1; |
38 |
private static float CONTROL_FLOAT = 1; |
39 |
private static int CONTROL_INT = 1; |
40 |
private static BigInteger CONTROL_BIG_INTEGER = BigInteger.ONE; |
41 |
private static long CONTROL_LONG = 1; |
42 |
private static short CONTROL_SHORT = 1; |
43 |
|
44 |
public DataTypesTestCases(String name) { |
45 |
super(name); |
46 |
} |
47 |
|
48 |
public void setUp() { |
49 |
super.setUp(); |
50 |
InputStream xsdInputStream = Thread.currentThread().getContextClassLoader().getSystemResourceAsStream(XSD); |
51 |
this.aHelperContext.getXSDHelper().define(xsdInputStream, null); |
52 |
} |
53 |
|
54 |
public void testCreateObject() { |
55 |
DataObject dataTypesDO = aHelperContext.getDataFactory().create("http://www.example.com", "DataTypes"); |
56 |
DataTypes dataTypes = (DataTypes) dataTypesDO; |
57 |
|
58 |
dataTypes.setAnySimpleTypeProperty(CONTROL_OBJECT); |
59 |
assertEquals(CONTROL_OBJECT, dataTypes.getAnySimpleTypeProperty()); |
60 |
|
61 |
dataTypes.setAnyTypeProperty(dataTypesDO); |
62 |
assertEquals(dataTypesDO, dataTypes.getAnyTypeProperty()); |
63 |
|
64 |
dataTypes.setAnyURIProperty(CONTROL_STRING); |
65 |
assertEquals(CONTROL_STRING, dataTypes.getAnyURIProperty()); |
66 |
/* |
67 |
dataTypes.setBase64BinaryProperty(CONTROL_BYTES); |
68 |
assertEquals(CONTROL_BYTES, dataTypes.getBase64BinaryProperty()); |
69 |
*/ |
70 |
dataTypes.setBooleanProperty(CONTROL_BOOLEAN); |
71 |
assertEquals(CONTROL_BOOLEAN, dataTypes.isBooleanProperty()); |
72 |
|
73 |
dataTypes.setByteProperty(CONTROL_BYTE); |
74 |
assertEquals(CONTROL_BYTE, dataTypes.getByteProperty()); |
75 |
|
76 |
dataTypes.setDateProperty(CONTROL_STRING); |
77 |
assertEquals(CONTROL_STRING, dataTypes.getDateProperty()); |
78 |
|
79 |
dataTypes.setDateTimeProperty(CONTROL_STRING); |
80 |
assertEquals(CONTROL_STRING, dataTypes.getDateTimeProperty()); |
81 |
|
82 |
dataTypes.setDecimalProperty(CONTROL_BIG_DECIMAL); |
83 |
assertEquals(CONTROL_BIG_DECIMAL, dataTypes.getDecimalProperty()); |
84 |
|
85 |
dataTypes.setDoubleProperty(CONTROL_DOUBLE); |
86 |
assertEquals(CONTROL_DOUBLE, dataTypes.getDoubleProperty()); |
87 |
|
88 |
dataTypes.setDurationProperty(CONTROL_STRING); |
89 |
assertEquals(CONTROL_STRING, dataTypes.getDurationProperty()); |
90 |
|
91 |
dataTypes.setENTITIESProperty(CONTROL_STRINGS); |
92 |
assertEquals(CONTROL_STRINGS, dataTypes.getENTITIESProperty()); |
93 |
|
94 |
dataTypes.setENTITYProperty(CONTROL_STRING); |
95 |
assertEquals(CONTROL_STRING, dataTypes.getENTITYProperty()); |
96 |
|
97 |
dataTypes.setFloatProperty(CONTROL_FLOAT); |
98 |
assertEquals(CONTROL_FLOAT, dataTypes.getFloatProperty()); |
99 |
|
100 |
dataTypes.setGDayProperty(CONTROL_STRING); |
101 |
assertEquals(CONTROL_STRING, dataTypes.getGDayProperty()); |
102 |
|
103 |
dataTypes.setGMonthProperty(CONTROL_STRING); |
104 |
assertEquals(CONTROL_STRING, dataTypes.getGMonthProperty()); |
105 |
|
106 |
dataTypes.setGMonthDayProperty(CONTROL_STRING); |
107 |
assertEquals(CONTROL_STRING, dataTypes.getGMonthDayProperty()); |
108 |
|
109 |
dataTypes.setGYearProperty(CONTROL_STRING); |
110 |
assertEquals(CONTROL_STRING, dataTypes.getGYearProperty()); |
111 |
|
112 |
dataTypes.setGYearMonthProperty(CONTROL_STRING); |
113 |
assertEquals(CONTROL_STRING, dataTypes.getGYearMonthProperty()); |
114 |
|
115 |
dataTypes.setHexBinaryProperty(CONTROL_BYTES); |
116 |
assertEquals(CONTROL_BYTES, dataTypes.getHexBinaryProperty()); |
117 |
|
118 |
dataTypes.setIDProperty(CONTROL_STRING); |
119 |
assertEquals(CONTROL_STRING, dataTypes.getIDProperty()); |
120 |
|
121 |
dataTypes.setIDREFProperty(CONTROL_STRING); |
122 |
assertEquals(CONTROL_STRING, dataTypes.getIDREFProperty()); |
123 |
|
124 |
dataTypes.setIntProperty(CONTROL_INT); |
125 |
assertEquals(CONTROL_INT, dataTypes.getIntProperty()); |
126 |
|
127 |
dataTypes.setIntegerProperty(CONTROL_BIG_INTEGER); |
128 |
assertEquals(CONTROL_BIG_INTEGER, dataTypes.getIntegerProperty()); |
129 |
|
130 |
dataTypes.setLanguageProperty(CONTROL_STRING); |
131 |
assertEquals(CONTROL_STRING, dataTypes.getLanguageProperty()); |
132 |
|
133 |
dataTypes.setLongProperty(CONTROL_LONG); |
134 |
assertEquals(CONTROL_LONG, dataTypes.getLongProperty()); |
135 |
|
136 |
dataTypes.setNameProperty(CONTROL_STRING); |
137 |
assertEquals(CONTROL_STRING, dataTypes.getNameProperty()); |
138 |
|
139 |
dataTypes.setNCNameProperty(CONTROL_STRING); |
140 |
assertEquals(CONTROL_STRING, dataTypes.getNCNameProperty()); |
141 |
|
142 |
dataTypes.setNegativeIntegerProperty(CONTROL_BIG_INTEGER); |
143 |
assertEquals(CONTROL_BIG_INTEGER, dataTypes.getNegativeIntegerProperty()); |
144 |
|
145 |
dataTypes.setNMTOKENProperty(CONTROL_STRING); |
146 |
assertEquals(CONTROL_STRING, dataTypes.getNMTOKENProperty()); |
147 |
|
148 |
dataTypes.setNMTOKENSProperty(CONTROL_STRINGS); |
149 |
assertEquals(CONTROL_STRINGS, dataTypes.getNMTOKENSProperty()); |
150 |
|
151 |
dataTypes.setNonNegativeIntegerProperty(CONTROL_BIG_INTEGER); |
152 |
assertEquals(CONTROL_BIG_INTEGER, dataTypes.getNonNegativeIntegerProperty()); |
153 |
|
154 |
dataTypes.setNonPositiveIntegerProperty(CONTROL_BIG_INTEGER); |
155 |
assertEquals(CONTROL_BIG_INTEGER, dataTypes.getNonPositiveIntegerProperty()); |
156 |
|
157 |
dataTypes.setNormalizedStringProperty(CONTROL_STRING); |
158 |
assertEquals(CONTROL_STRING, dataTypes.getNormalizedStringProperty()); |
159 |
|
160 |
dataTypes.setNOTATION(CONTROL_STRING); |
161 |
assertEquals(CONTROL_STRING, dataTypes.getNOTATION()); |
162 |
|
163 |
dataTypes.setPositiveIntegerProperty(CONTROL_BIG_INTEGER); |
164 |
assertEquals(CONTROL_BIG_INTEGER, dataTypes.getPositiveIntegerProperty()); |
165 |
|
166 |
dataTypes.setQName(CONTROL_STRING); |
167 |
assertEquals(CONTROL_STRING, dataTypes.getQName()); |
168 |
|
169 |
dataTypes.setShort(CONTROL_SHORT); |
170 |
assertEquals(CONTROL_SHORT, dataTypes.getShort()); |
171 |
|
172 |
dataTypes.setString(CONTROL_STRING); |
173 |
assertEquals(CONTROL_STRING, dataTypes.getString()); |
174 |
|
175 |
dataTypes.setTime(CONTROL_STRING); |
176 |
assertEquals(CONTROL_STRING, dataTypes.getTime()); |
177 |
|
178 |
dataTypes.setToken(CONTROL_STRING); |
179 |
assertEquals(CONTROL_STRING, dataTypes.getToken()); |
180 |
|
181 |
dataTypes.setUnsignedByte(CONTROL_SHORT); |
182 |
assertEquals(CONTROL_SHORT, dataTypes.getUnsignedByte()); |
183 |
|
184 |
dataTypes.setUnsignedInt(CONTROL_LONG); |
185 |
assertEquals(CONTROL_LONG, dataTypes.getUnsignedInt()); |
186 |
|
187 |
dataTypes.setUnsignedLong(CONTROL_BIG_INTEGER); |
188 |
assertEquals(CONTROL_BIG_INTEGER, dataTypes.getUnsignedLong()); |
189 |
|
190 |
dataTypes.setUnsignedShort(CONTROL_INT); |
191 |
assertEquals(CONTROL_INT, dataTypes.getUnsignedInt()); |
192 |
} |
193 |
|
194 |
} |