You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ke...@apache.org on 2007/01/08 14:34:59 UTC
svn commit: r494066 [5/6] - in /incubator/tuscany/java/cts: ./ sdo2.1/
sdo2.1/src/ sdo2.1/src/main/ sdo2.1/src/main/java/
sdo2.1/src/main/java/test/ sdo2.1/src/main/java/test/sdo21/
sdo2.1/src/main/java/test/sdo21/framework/ sdo2.1/src/main/java/test/s...
Added: incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/typeconv/TypeConversionTest.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/typeconv/TypeConversionTest.java?view=auto&rev=494066
==============================================================================
--- incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/typeconv/TypeConversionTest.java (added)
+++ incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/typeconv/TypeConversionTest.java Mon Jan 8 05:34:57 2007
@@ -0,0 +1,4816 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package test.sdo21.tests.typeconv;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.TypeHelper;
+import junit.framework.TestCase;
+import test.sdo21.CTSSuite;
+import test.sdo21.framework.TestHelper;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+
+/**
+ * This test case primarily tests the type conversion matrix in section 16 of the
+ * specification. There are tests for valid and invalid type conversions. Invalid
+ * type conversions are expected to throw a ClassCastException as per section 3.1.13
+ * of the specification.
+ *
+ * Some of the tests perform conversions that result in loss of information e.g. getting
+ * a double property by calling getShort(). Type conversions should follow the rules of
+ * the Java language and are allowed to lose information (section 3.1.3)
+ *
+ */
+public class TypeConversionTest extends TestCase {
+
+ /**
+ * This variable is used to create unique type names to avoid name clashes in TypeHelper
+ */
+ static int unique = 0;
+
+ /**
+ * DateFormat is set up in the constructor as per the format in the specification.
+ */
+ private DateFormat f;
+
+ /**
+ * The TestHelper interface provides access to SDO helper classes.
+ */
+ private TestHelper testHelper;
+
+ /**
+ * Message to use when an invalid type conversion does not throw a ClassCastException
+ */
+ private static final String EXPECTED_CLASS_CAST_EXCEPTION = "ClassCastException should have been thrown (invalid conversion)";
+
+ public TypeConversionTest(String string) {
+ super(string);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // set up time format as per page 71 of SDO for Java 2.1.0 FINAL
+ f = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'.'SSS'Z'");
+ f.setTimeZone(TimeZone.getTimeZone("GMT"));
+
+ // obtain TestHelper implementation
+ testHelper = CTSSuite.getTestHelper();
+ }
+
+ /**
+ * Helper function for converions tests.
+ * Creates a DataObject with name 'product' and data hold property
+ *
+ * @param strName the name of the data hold property in the created object.
+ * @param strType the type of the data hold property in the created object.
+ * @return the created DataObject.
+ */
+ private DataObject createTypeConversionObject(String strName, String strType) {
+
+ // obtain a TypeHelper
+ TypeHelper typeHelper = testHelper.getTypeHelper();
+
+ // create new DataType
+ String uri = "http://example.com/TypeConversionTest/" + unique;
+ String name = "TypeConversionTest" + unique;
+ unique++;
+ DataObject productType = testHelper.getDataFactory().create("commonj.sdo", "Type");
+ productType.set("uri", uri);
+ productType.set("name", name);
+
+ // define property
+ DataObject dateValProperty = productType.createDataObject("property");
+ dateValProperty.set("name", strName);
+ dateValProperty.set("type", typeHelper.getType("commonj.sdo", strType));
+ dateValProperty.setBoolean("containment", false);
+
+ // define the type
+ typeHelper.define(productType);
+
+ // create DataObject using the new Type
+ return testHelper.getDataFactory().create(uri, name);
+ }
+
+ /**
+ * Helper function for boolean converions tests.
+ * Created a DataObject with 'boolVal' boolean property
+ *
+ * @param initialVal the initial value of the data hold property.
+ * @return the initialized DataObject.
+ */
+ private DataObject createBooleanObject(boolean initialVal) {
+ DataObject productType = createTypeConversionObject("boolVal", "Boolean");
+ productType.setBoolean("boolVal", initialVal);
+ return productType;
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting byte from DataObject with type boolean
+ */
+ public void testBooleanGetTypeConversionByte() {
+ DataObject product = createBooleanObject(true);
+ try {//to byte
+ product.getByte("boolVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting char from DataObject with type boolean
+ */
+ public void testBooleanGetTypeConversionChar() {
+ DataObject product = createBooleanObject(true);
+ try {//to char
+ product.getChar("boolVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting double from DataObject with type boolean
+ */
+ public void testBooleanGetTypeConversionDouble() {
+ DataObject product = createBooleanObject(true);
+ try {//to double
+ product.getDouble("boolVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting float from DataObject with type boolean
+ */
+ public void testBooleanGetTypeConversionFloat() {
+ DataObject product = createBooleanObject(true);
+ try {//to float
+ product.getFloat("boolVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting int from DataObject with type boolean
+ */
+ public void testBooleanGetTypeConversionInt() {
+ DataObject product = createBooleanObject(true);
+ try {
+ product.getInt("boolVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting long from DataObject with type boolean
+ */
+ public void testBooleanGetTypeConversionLong() {
+ DataObject product = createBooleanObject(true);
+ try {//to long
+ product.getLong("boolVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting short from DataObject with type boolean
+ */
+ public void testBooleanGetTypeConversionShort() {
+ DataObject product = createBooleanObject(true);
+ try {//to short
+ product.getShort("boolVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting string from DataObject with type boolean
+ */
+ public void testBooleanGetTypeConversionString() {
+ DataObject product = createBooleanObject(true);
+ String strVal = product.getString("boolVal");
+ assertEquals("true", strVal);
+ product.setBoolean("boolVal", false);
+ strVal = product.getString("boolVal");
+ assertEquals("false", strVal);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting bytes[] from DataObject with type boolean
+ */
+ public void testBooleanGetTypeConversionBytes() {
+ DataObject product = createBooleanObject(true);
+ try {//to bytes[]
+ product.getBytes("boolVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting BigDecimal from DataObject with type boolean
+ */
+ public void testBooleanGetTypeConversionBigDecimal() {
+ DataObject product = createBooleanObject(true);
+ try {//to BigDecimal
+ product.getBigDecimal("boolVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting BigInteger from DataObject with type boolean
+ */
+ public void testBooleanGetTypeConversionBigInteger() {
+ DataObject product = createBooleanObject(true);
+ try {//to BigInteger
+ product.getBigInteger("boolVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting Date from DataObject with type boolean
+ */
+ public void testBooleanGetTypeConversionDate() {
+ DataObject product = createBooleanObject(true);
+ try {//to Date
+ product.getDate("boolVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * Helper function for byte converions tests.
+ * Creates a DataObject with 'byteVal' byte property
+ *
+ * @param initialVal the initial value of the data hold property.
+ * @return the initialized DataObject.
+ */
+ private DataObject createByteObject(byte initialVal) {
+ DataObject productType = createTypeConversionObject("byteVal", "Byte");
+ productType.setByte("byteVal", initialVal);
+ return productType;
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting boolean from DataObject with type byte
+ */
+ public void testByteGetTypeConversionBoolean() {
+ DataObject product = createByteObject((byte) 5);
+ try {
+ product.getBoolean("byteVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting char from DataObject with type byte
+ */
+ public void testByteGetTypeConversionChar() {
+ DataObject product = createByteObject((byte) 5);
+ try {
+ product.getChar("byteVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting double from DataObject with type byte
+ */
+ public void testByteGetTypeConversionDouble() {
+ DataObject product = createByteObject((byte) 5);
+
+ double doubleVal = product.getDouble("byteVal");
+ assertTrue(doubleVal == 5);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting float from DataObject with type byte
+ */
+ public void testByteGetTypeConversionFloat() {
+ DataObject product = createByteObject((byte) 5);
+
+ float floatVal = product.getFloat("byteVal");
+ assertTrue(floatVal == 5);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting int from DataObject with type byte
+ */
+ public void testByteGetTypeConversionInt() {
+ DataObject product = createByteObject((byte) 5);
+
+ int intVal = product.getInt("byteVal");
+ assertTrue(intVal == 5);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting long from DataObject with type byte
+ */
+ public void testByteGetTypeConversionLong() {
+ DataObject product = createByteObject((byte) 5);
+
+ long longVal = product.getLong("byteVal");
+ assertTrue(longVal == 5);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting short from DataObject with type byte
+ */
+ public void testByteGetTypeConversionShort() {
+ DataObject product = createByteObject((byte) 5);
+
+ short shortVal = product.getShort("byteVal");
+ assertTrue(shortVal == 5);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting String from DataObject with type byte
+ */
+ public void testByteGetTypeConversionString() {
+ DataObject product = createByteObject((byte) 5);
+
+ String stringVal = product.getString("byteVal");
+ assertNotNull(stringVal);
+ assertEquals(0, stringVal.compareToIgnoreCase("5"));
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting bytes[] from DataObject with type byte
+ */
+ public void testByteGetTypeConversionBytes() {
+ DataObject product = createByteObject((byte) 5);
+ try {
+ product.getBytes("byteVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting BigDecimal from DataObject with type byte
+ */
+ public void testByteGetTypeConversionBigDecimal() {
+ DataObject product = createByteObject((byte) 5);
+ try {
+ product.getBigDecimal("byteVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting BigInteger from DataObject with type byte
+ */
+ public void testByteGetTypeConversionBigInteger() {
+ DataObject product = createByteObject((byte) 5);
+ try {
+ product.getBigInteger("byteVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting Date from DataObject with type byte
+ */
+ public void testByteGetTypeConversionDate() {
+ DataObject product = createByteObject((byte) 5);
+ try {
+ product.getDate("byteVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * Helper function for char converions tests.
+ * Creates a DataObject with 'charVal' char property
+ *
+ * @param initialVal the initial value of the data hold property.
+ * @return the initialized DataObject.
+ */
+ private DataObject createCharObject(char initialVal) {
+ DataObject productType = createTypeConversionObject("charVal", "Character");
+ productType.setChar("charVal", initialVal);
+ return productType;
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting boolean from DataObject with type char
+ */
+ public void testCharGetTypeConversionBoolean() {
+ DataObject product = createCharObject('s');
+ try {
+ product.getBoolean("charVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting byte from DataObject with type char
+ */
+ public void testCharGetTypeConversionByte() {
+ DataObject product = createCharObject('s');
+ try {
+ product.getByte("charVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting double from DataObject with type char
+ */
+ public void testCharGetTypeConversionDouble() {
+ DataObject product = createCharObject('s');
+ try {
+ product.getDouble("charVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting float from DataObject with type char
+ */
+ public void testCharGetTypeConversionFloat() {
+ DataObject product = createCharObject('s');
+ try {
+ product.getFloat("charVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting int from DataObject with type char
+ */
+ public void testCharGetTypeConversionInt() {
+ DataObject product = createCharObject('s');
+ try {
+ product.getInt("charVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting long from DataObject with type char
+ */
+ public void testCharGetTypeConversionLong() {
+ DataObject product = createCharObject('s');
+ try {
+ product.getLong("charVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting short from DataObject with type char
+ */
+ public void testCharGetTypeConversionShort() {
+ DataObject product = createCharObject('s');
+ try {
+ product.getShort("charVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting string from DataObject with type char
+ */
+ public void testCharGetTypeConversionString() {
+ DataObject product = createCharObject('s');
+
+ String strRes = product.getString("charVal");
+ assertNotNull(strRes);
+ assertEquals("s", strRes);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting bytes[] from DataObject with type char
+ */
+ public void testCharGetTypeConversionBytes() {
+ DataObject product = createCharObject('s');
+ try {
+ product.getBytes("charVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting BigDecimal from DataObject with type char
+ */
+ public void testCharGetTypeConversionBigDecimal() {
+ DataObject product = createCharObject('s');
+ try {
+ product.getBigDecimal("charVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting BigInteger from DataObject with type char
+ */
+ public void testCharGetTypeConversionBigInteger() {
+ DataObject product = createCharObject('s');
+ try {
+ product.getBigInteger("charVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting Date from DataObject with type char
+ */
+ public void testCharGetTypeConversionDate() {
+ DataObject product = createCharObject('s');
+ try {
+ product.getDate("charVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * Helper function for Double converions tests.
+ * Creates a DataObject with 'doubleVal' double property.
+ *
+ * @param initialVal the initial value of the data hold property.
+ * @return the initialized DataObject.
+ */
+ private DataObject createDoubleObject(double initialVal) {
+ DataObject productType = createTypeConversionObject("doubleVal", "Double");
+ productType.setDouble("doubleVal", initialVal);
+ return productType;
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting boolean from DataObject with type double
+ */
+ public void testDoubleGetTypeConversionBoolean() {
+ DataObject product = createDoubleObject(5);
+ try {
+ product.getBoolean("doubleVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting byte from DataObject with type double
+ */
+ public void testDoubleGetTypeConversionByte() {
+ DataObject product1 = createDoubleObject(5);
+ byte byteVal = product1.getByte("doubleVal");
+ assertEquals(5, byteVal);
+
+ int largeValue = Byte.MAX_VALUE + 1;
+ DataObject product = createDoubleObject(largeValue);
+ byte b = product.getByte("doubleVal");
+ assertEquals( (byte)largeValue, b );
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting char from DataObject with type double
+ */
+ public void testDoubleGetTypeConversionChar() {
+ DataObject product = createDoubleObject(5);
+ try {
+ product.getChar("doubleVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting float from DataObject with type double
+ */
+ public void testDoubleGetTypeConversionFloat() {
+ DataObject product1 = createDoubleObject(5);
+ float floatVal = product1.getFloat("doubleVal");
+ assertTrue(floatVal == 5.0F);
+
+ double largeValue = ((double) Float.MAX_VALUE) + 1.0;
+ DataObject product = createDoubleObject(largeValue);
+ float f = product.getFloat("doubleVal");
+ assertEquals( (float)largeValue, f);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting int from DataObject with type double
+ */
+ public void testDoubleGetTypeConversionInt() {
+ DataObject product1 = createDoubleObject(5);
+ int intVal = product1.getInt("doubleVal");
+ assertEquals(5, intVal);
+
+ double largeValue = ((double) Integer.MAX_VALUE) + 1.0;
+ DataObject product = createDoubleObject(largeValue);
+ int value = product.getInt("doubleVal");
+ assertEquals( (int)largeValue, value );
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting long from DataObject with type double
+ */
+ public void testDoubleGetTypeConversionLong() {
+ DataObject product1 = createDoubleObject(5);
+ long longVal = product1.getLong("doubleVal");
+ assertEquals(5, longVal);
+
+ double largeValue = ((double) Long.MAX_VALUE) + 1.0;
+ DataObject product = createDoubleObject(largeValue);
+ long l = product.getLong("doubleVal");
+ assertEquals( (long)largeValue, l );
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting short from DataObject with type double
+ */
+ public void testDoubleGetTypeConversionShort() {
+ DataObject product1 = createDoubleObject(5);
+ short shortVal = product1.getShort("doubleVal");
+ assertEquals(5, shortVal);
+
+ int largeValue = Short.MAX_VALUE + 1;
+ DataObject product = createDoubleObject(largeValue);
+ short s = product.getShort("doubleVal");
+ assertEquals( (short)largeValue, s );
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting string from DataObject with type double
+ */
+ public void testDoubleGetTypeConversionString() {
+ DataObject product = createDoubleObject(5);
+ String strVal = product.getString("doubleVal");
+ assertEquals("5.0", strVal);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting bytes[] from DataObject with type double
+ */
+ public void testDoubleGetTypeConversionBytes() {
+ DataObject product = createDoubleObject(5);
+ try {
+ product.getBytes("doubleVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting Bigdecimal from DataObject with type double
+ */
+ public void testDoubleGetTypeConversionBigDecimal() {
+ DataObject product = createDoubleObject(5);
+
+ BigDecimal bdVal = product.getBigDecimal("doubleVal");
+ assertEquals(5, bdVal.intValue());
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting BigInteger from DataObject with type double
+ */
+ public void testDoubleGetTypeConversionBigInteger() {
+ DataObject product = createDoubleObject(5);
+
+ BigInteger biVal = product.getBigInteger("doubleVal");
+ assertEquals(5, biVal.intValue());
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting date from DataObject with type double
+ */
+ public void testDoubleGetTypeConversionDate() {
+ DataObject product = createDoubleObject(5);
+ try {
+ product.getDate("doubleVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * Helper function for Float converions tests.
+ * Creates a DataObject with 'floatVal' float property
+ *
+ * @param initialVal the initial value of the data hold property.
+ * @return the initialized DataObject.
+ */
+ private DataObject createFloatObject(float initialVal) {
+ DataObject productType = createTypeConversionObject("floatVal", "Float");
+ productType.setFloat("floatVal", initialVal);
+ return productType;
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting boolean from DataObject with type float
+ */
+ public void testFloatGetTypeConversionBoolean() {
+ DataObject product = createFloatObject(5);
+ try {
+ product.getBoolean("floatVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting byte from DataObject with type float
+ */
+ public void testFloatGetTypeConversionByte() {
+ DataObject product1 = createFloatObject(5);
+ byte byteVal = product1.getByte("floatVal");
+ assertEquals(5, byteVal);
+
+ float value = 5.5F;
+ DataObject product = createFloatObject(value);
+ byte b = product.getByte("floatVal");
+ assertEquals( (byte)value, b );
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting char from DataObject with type float
+ */
+ public void testFloatGetTypeConversionChar() {
+ DataObject product = createFloatObject(5);
+ try {
+ product.getChar("floatVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting double from DataObject with type float
+ */
+ public void testFloatGetTypeConversionDouble() {
+ DataObject product1 = createFloatObject(5);
+ double doubleVal = product1.getDouble("floatVal");
+ assertTrue(doubleVal == 5);
+
+ float value = 5.5F;
+ DataObject product = createFloatObject(value);
+ double d = product.getDouble("floatVal");
+ assertEquals( (double)value, d );
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting int from DataObject with type float
+ */
+ public void testFloatGetTypeConversionInt() {
+ DataObject product1 = createFloatObject(5);
+ int intVal = product1.getInt("floatVal");
+ assertEquals(5, intVal);
+
+ float value = 5.5F;
+ DataObject product = createFloatObject(value);
+ int i = product.getInt("floatVal");
+ assertEquals( (int)value, i );
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting long from DataObject with type float
+ */
+ public void testFloatGetTypeConversionLong() {
+ DataObject product1 = createFloatObject(5);
+ long longVal = product1.getLong("floatVal");
+ assertTrue(longVal == 5);
+
+ float f = 5.5F;
+ DataObject product = createFloatObject(f);
+ long l = product.getLong("floatVal");
+ assertEquals( (long)f, l );
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting short from DataObject with type float
+ */
+ public void testFloatGetTypeConversionShort() {
+
+ DataObject product1 = createFloatObject(5);
+ short shortVal = product1.getShort("floatVal");
+ assertTrue(shortVal == 5);
+
+ float value = 5.5F;
+ DataObject product = createFloatObject(value);
+ short s = product.getShort("floatVal");
+ assertEquals( (short)value, s );
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting string from DataObject with type float
+ */
+ public void testFloatGetTypeConversionString() {
+ DataObject product = createFloatObject(5.5F);
+ String strval = product.getString("floatVal");
+ assertEquals("5.5", strval);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting bytes[] from DataObject with type float
+ */
+ public void testFloatGetTypeConversionBytes() {
+ DataObject product = createFloatObject(5);
+ try {
+ product.getBytes("floatVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting BigDecimal from DataObject with type float
+ */
+ public void testFloatGetTypeConversionBigDecimal() {
+ DataObject product = createFloatObject(5.5F);
+ BigDecimal bdval = product.getBigDecimal("floatVal");
+ assertTrue(bdval.floatValue() == 5.5F);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting BigInteger from DataObject with type float
+ */
+ public void testFloatGetTypeConversionBigInteger() {
+ DataObject product1 = createFloatObject(5);
+ BigInteger bdval = product1.getBigInteger("floatVal");
+ assertTrue(bdval.intValue() == 5);
+
+ float value = 5.5F;
+ DataObject product = createFloatObject(value);
+ BigInteger big = product.getBigInteger("floatVal");
+ assertEquals( new BigInteger(""+(int)value), big );
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting date from DataObject with type float
+ */
+ public void testFloatGetTypeConversionDate() {
+ DataObject product = createFloatObject(5);
+ try {
+ product.getDate("floatVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * Helper function for int converions tests.
+ * Creates a DataObject with 'intVal' int property
+ *
+ * @param initialVal the initial value of the data hold property.
+ * @return the initialized DataObject.
+ */
+ private DataObject createIntObject(int initialVal) {
+ DataObject productType = createTypeConversionObject("intVal", "Int");
+ productType.setInt("intVal", initialVal);
+ return productType;
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting boolean from DataObject with type int
+ */
+ public void testIntGetTypeConversionBoolean() {
+ DataObject product = createIntObject(5);
+ try {
+ product.getBoolean("intVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting byte from DataObject with type int
+ */
+ public void testIntGetTypeConversionByte() {
+ DataObject product1 = createIntObject(5);
+ byte byteVal = product1.getByte("intVal");
+ assertTrue(byteVal == 5);
+
+ int value = Byte.MAX_VALUE + 1;
+ DataObject product = createIntObject(value);
+ byte b = product.getByte("intVal");
+ assertEquals( (byte)value, b );
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting char from DataObject with type int
+ */
+ public void testIntGetTypeConversionChar() {
+ DataObject product = createIntObject(5);
+ try {
+ product.getChar("intVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting double from DataObject with type int
+ */
+ public void testIntGetTypeConversionDouble() {
+ DataObject product = createIntObject(5);
+ double doubleVal = product.getDouble("intVal");
+ assertTrue(doubleVal == 5);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting float from DataObject with type int
+ */
+ public void testIntGetTypeConversionFloat() {
+ DataObject product1 = createIntObject(5);
+ float floatVal = product1.getFloat("intVal");
+ assertTrue(floatVal == 5);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting long from DataObject with type int
+ */
+ public void testIntGetTypeConversionLong() {
+ DataObject product = createIntObject(5);
+ long longVal = product.getLong("intVal");
+ assertTrue(longVal == 5);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting short from DataObject with type int
+ */
+ public void testIntGetTypeConversionShort() {
+ DataObject product1 = createIntObject(5);
+ short shortVal = product1.getShort("intVal");
+ assertTrue(shortVal == 5);
+
+ int value = Short.MAX_VALUE + 1;
+ DataObject product = createIntObject(value);
+ short s = product.getShort("intVal");
+ assertEquals( (short)value, s );
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting string from DataObject with type int
+ */
+ public void testIntGetTypeConversionString() {
+ DataObject product = createIntObject(5);
+ String strVal = product.getString("intVal");
+ assertEquals("5", strVal);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting bytes[] from DataObject with type int
+ */
+ public void testIntGetTypeConversionBytes() {
+ DataObject product = createIntObject(5);
+ try {
+ product.getBytes("intVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting BigDecimal from DataObject with type int
+ */
+ public void testIntGetTypeConversionBigDecimal() {
+ DataObject product1 = createIntObject(5);
+ BigDecimal bdVal = product1.getBigDecimal("intVal");
+ assertTrue(bdVal.intValue() == 5);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting BigInteger from DataObject with type int
+ */
+ public void testIntGetTypeConversionBigInteger() {
+ DataObject product = createIntObject(5);
+ BigInteger biVal = product.getBigInteger("intVal");
+ assertTrue(biVal.intValue() == 5);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting date from DataObject with type int
+ */
+ public void testIntGetTypeConversionDate() {
+ DataObject product = createIntObject(5);
+ try {
+ product.getDate("intVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * Helper function for Long converions tests.
+ * Creates a DataObject with 'longVal' long property.
+ *
+ * @param initialVal the initial value of the data hold property.
+ * @return the initialized DataObject.
+ */
+ private DataObject createLongObject(long initialVal) {
+ DataObject productType = createTypeConversionObject("longVal", "Long");
+ productType.setLong("longVal", initialVal);
+ return productType;
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting boolean from DataObject with type long
+ */
+ public void testLongGetTypeConversionBoolean() {
+ DataObject product = createLongObject(5);
+ try {
+ product.getBoolean("longVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting byte from DataObject with type long
+ */
+ public void testLongGetTypeConversionByte() {
+ DataObject product1 = createLongObject(5);
+ byte byteVal = product1.getByte("longVal");
+ assertTrue(byteVal == 5);
+
+ int value = Byte.MAX_VALUE + 1;
+ DataObject product = createLongObject(value);
+ byte b = product.getByte("longVal");
+ assertEquals( (byte)value, b );
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting char from DataObject with type long
+ */
+ public void testLongGetTypeConversionChar() {
+ DataObject product = createLongObject(5);
+ try {
+ product.getChar("longVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting double from DataObject with type long
+ */
+ public void testLongGetTypeConversionDouble() {
+ DataObject product = createLongObject(5);
+ double doubleVal = product.getDouble("longVal");
+ assertTrue(doubleVal == 5);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting float from DataObject with type long
+ */
+ public void testLongGetTypeConversionFloat() {
+ DataObject product1 = createLongObject(5);
+ float floatVal = product1.getFloat("longVal");
+ assertTrue(floatVal == 5);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting int from DataObject with type long
+ */
+ public void testLongGetTypeConversionInt() {
+ DataObject product1 = createLongObject(5);
+ int intVal = product1.getInt("longVal");
+ assertTrue(intVal == 5);
+
+ long value = Long.MAX_VALUE;
+ DataObject product = createLongObject(value);
+ int i = product.getInt("longVal");
+ assertEquals( (int)value, i );
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting short from DataObject with type long
+ */
+ public void testLongGetTypeConversionShort() {
+ DataObject product1 = createLongObject(5);
+ short shortVal = product1.getByte("longVal");
+ assertTrue(shortVal == 5);
+
+ int value = Short.MAX_VALUE + 1;
+ DataObject product = createLongObject(value);
+ short s = product.getShort("longVal");
+ assertEquals( (short) value, s );
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting string from DataObject with type long
+ */
+ public void testLongGetTypeConversionString() {
+ DataObject product = createLongObject(5);
+ String strVal = product.getString("longVal");
+ assertEquals("5", strVal);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting bytes[] from DataObject with type long
+ */
+ public void testLongGetTypeConversionBytes() {
+ DataObject product = createLongObject(5);
+ try {
+ product.getBytes("longVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting BigDecimal from DataObject with type long
+ */
+ public void testLongGetTypeConversionBigDecimal() {
+ DataObject product = createLongObject(5);
+ BigDecimal bdVal = product.getBigDecimal("longVal");
+ assertTrue(bdVal.intValue() == 5);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting BigInteger from DataObject with type long
+ */
+ public void testLongGetTypeConversionBigInteger() {
+ DataObject product1 = createLongObject(5);
+ BigInteger biVal = product1.getBigInteger("longVal");
+ assertTrue(biVal.intValue() == 5);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting date from DataObject with type long
+ */
+ public void testLongGetTypeConversionDate() {
+ Date dateNow = new Date();
+ DataObject product1 = createLongObject(dateNow.getTime());
+ Date dateRes = product1.getDate("longVal");
+ assertTrue(dateRes.getTime() == dateNow.getTime());
+ }
+
+ /**
+ * Helper function for short converions tests.
+ * Creates a DataObject with 'shortVal' short property
+ *
+ * @param initialVal the initial value of the data hold property.
+ * @return the initialized DataObject.
+ */
+ private DataObject createShortObject(short initialVal) {
+ DataObject productType = createTypeConversionObject("shortVal", "Short");
+ productType.setShort("shortVal", initialVal);
+ return productType;
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting boolean from DataObject with type short
+ */
+ public void testShortGetTypeConversionBoolean() {
+ DataObject product = createShortObject((short) 5);
+ try {
+ product.getBoolean("shortVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting byte from DataObject with type short
+ */
+ public void testShortGetTypeConversionByte() {
+ DataObject product1 = createShortObject((short) 5);
+ byte byteVal = product1.getByte("shortVal");
+ assertTrue(byteVal == 5);
+
+ short value = (Byte.MAX_VALUE + 1);
+ DataObject product = createShortObject(value);
+ byte b = product.getByte("shortVal");
+ assertEquals( (byte)value, b );
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting char from DataObject with type short
+ */
+ public void testShortGetTypeConversionChar() {
+ DataObject product = createShortObject((short) 5);
+ try {
+ product.getChar("shortVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting double from DataObject with type short
+ */
+ public void testShortGetTypeConversionDouble() {
+ DataObject product = createShortObject((short) 5);
+ double doubleVal = product.getDouble("shortVal");
+ assertTrue(doubleVal == 5);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting float from DataObject with type short
+ */
+ public void testShortGetTypeConversionFloat() {
+ DataObject product = createShortObject((short) 5);
+ float floatVal = product.getFloat("shortVal");
+ assertTrue(floatVal == 5);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting int from DataObject with type short
+ */
+ public void testShortGetTypeConversionInt() {
+ DataObject product = createShortObject((short) 5);
+ int intVal = product.getInt("shortVal");
+ assertTrue(intVal == 5);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting long from DataObject with type short
+ */
+ public void testShortGetTypeConversionLong() {
+ DataObject product = createShortObject((short) 5);
+ long longVal = product.getLong("shortVal");
+ assertTrue(longVal == 5);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting string from DataObject with type short
+ */
+ public void testShortGetTypeConversionString() {
+ DataObject product = createShortObject((short) 5);
+ String strVal = product.getString("shortVal");
+ assertEquals("5", strVal);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting bytes[] from DataObject with type short
+ */
+ public void testShortGetTypeConversionBytes() {
+ DataObject product = createShortObject((short) 5);
+ try {
+ product.getBytes("shortVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting BigDecimal from DataObject with type short
+ */
+ public void testShortGetTypeConversionBigDecimal() {
+ DataObject product = createShortObject((short) 5);
+ try {
+ product.getBigDecimal("shortVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting BigInteger from DataObject with type short
+ */
+ public void testShortGetTypeConversionBigInteger() {
+ DataObject product = createShortObject((short) 5);
+ try {
+ product.getBigInteger("shortVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting date from DataObject with type short
+ */
+ public void testShortGetTypeConversionDate() {
+ DataObject product = createShortObject((short) 5);
+ try {
+ product.getDate("shortVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * Helper function for short converions tests.
+ * Creates a DataObject with 'stringVal' string property
+ *
+ * @param initialVal the initial value of the data hold property.
+ * @return the initialized DataObject.
+ */
+ private DataObject createStringObject(String initialVal) {
+ DataObject productType = createTypeConversionObject("stringVal", "String");
+ productType.setString("stringVal", initialVal);
+ return productType;
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting boolean from DataObject with type string
+ */
+ public void testStringGetTypeConversionBoolean() {
+ DataObject product = createStringObject("true");
+ boolean boolVal = product.getBoolean("stringVal");
+ assertEquals(true, boolVal);
+
+ DataObject product1 = createStringObject("false");
+ boolVal = product1.getBoolean("stringVal");
+ assertEquals(false, boolVal);
+
+ DataObject product2 = createStringObject("string");
+ try {
+ product2.getBoolean("stringVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting byte from DataObject with type string
+ */
+ public void testStringGetTypeConversionByte() {
+ DataObject product = createStringObject("5");
+ byte byteVal = product.getByte("stringVal");
+ assertEquals(5, byteVal);
+
+ DataObject product2 = createStringObject("string");
+ try {
+ product2.getByte("stringVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting char from DataObject with type string
+ */
+ public void testStringGetTypeConversionChar() {
+ DataObject product = createStringObject("string");
+ char charVal = product.getChar("stringVal");
+ assertEquals('s', charVal);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting double from DataObject with type string
+ */
+ public void testStringGetTypeConversionDouble() {
+ DataObject product = createStringObject("5");
+ double doubleVal = product.getDouble("stringVal");
+ assertTrue(5 == doubleVal);
+
+ DataObject product2 = createStringObject("string");
+ try {
+ product2.getDouble("stringVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting float from DataObject with type string
+ */
+ public void testStringGetTypeConversionFloat() {
+ DataObject product = createStringObject("5.5");
+ float floatVal = product.getFloat("stringVal");
+ assertTrue(5.5F == floatVal);
+
+ DataObject product2 = createStringObject("string");
+ try {
+ product2.getFloat("stringVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting int from DataObject with type string
+ */
+ public void testStringGetTypeConversionInt() {
+ DataObject product = createStringObject("5");
+ int intVal = product.getInt("stringVal");
+ assertEquals(5, intVal);
+
+ DataObject product2 = createStringObject("string");
+ try {
+ product2.getInt("stringVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting boolean from DataObject with type string
+ */
+ public void testStringGetTypeConversionLong() {
+ DataObject product = createStringObject("5");
+ long longVal = product.getLong("stringVal");
+ assertEquals(5, longVal);
+
+ DataObject product2 = createStringObject("string");
+ try {
+ product2.getLong("stringVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting short from DataObject with type string
+ */
+ public void testStringGetTypeConversionShort() {
+ DataObject product = createStringObject("5");
+ short shortVal = product.getShort("stringVal");
+ assertEquals(5, shortVal);
+
+ DataObject product2 = createStringObject("string");
+ try {
+ product2.getShort("stringVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting bytes from DataObject with type string
+ */
+ public void testStringGetTypeConversionBytes() {
+ DataObject product = createStringObject("0A64");
+
+ byte[] bytesRes = product.getBytes("stringVal");
+ assertNotNull(bytesRes);
+
+ assertEquals(2, bytesRes.length);
+ assertEquals(10, bytesRes[0]);
+ assertEquals(100, bytesRes[1]);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting decimal from DataObject with type string
+ */
+ public void testStringGetTypeConversionBigDecimal() {
+ DataObject product = createStringObject("5");
+ BigDecimal bdVal = product.getBigDecimal("stringVal");
+ assertTrue(5 == bdVal.intValue());
+
+ DataObject product2 = createStringObject("string");
+ try {
+ product2.getBigDecimal("stringVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting BigInteger from DataObject with type string
+ */
+ public void testStringGetTypeConversionBigInteger() {
+ DataObject product = createStringObject("5");
+ BigInteger biVal = product.getBigInteger("stringVal");
+ assertTrue(5 == biVal.intValue());
+
+ DataObject product2 = createStringObject("string");
+ try {
+ product2.getBigInteger("stringVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting date from DataObject with type string
+ */
+ public void testStringGetTypeConversionDate() {
+ Date bdTemp = new Date();
+ String dateString = f.format(bdTemp);
+
+ DataObject product = createStringObject(dateString);
+ Date dateVal = product.getDate("stringVal");
+ assertEquals(bdTemp, dateVal);
+
+ DataObject product2 = createStringObject("string");
+ try {
+ product2.getDate("stringVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * Helper function for byte[] converions tests.
+ * Created a DataObject with 'bytesVal' byte[] property
+ *
+ * @param initialVal the initial value of the data hold property.
+ * @return the initialized DataObject.
+ */
+ private DataObject createBytesObject(byte[] initialVal) {
+ DataObject productType = createTypeConversionObject("bytesVal", "Bytes");
+ productType.setBytes("bytesVal", initialVal);
+ return productType;
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting boolean from DataObject with type byte[]
+ */
+ public void testBytesGetTypeConversionBoolean() {
+ byte[] byteVal = {10, 100};
+ DataObject product = createBytesObject(byteVal);
+ try {
+ product.getBoolean("bytesVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting byte from DataObject with type byte[]
+ */
+ public void testBytesGetTypeConversionByte() {
+ byte[] byteVal = {10, 100};
+ DataObject product = createBytesObject(byteVal);
+ try {
+ product.getByte("bytesVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting char from DataObject with type byte[]
+ */
+ public void testBytesGetTypeConversionChar() {
+ byte[] byteVal = {10, 100};
+ DataObject product = createBytesObject(byteVal);
+ try {
+ product.getChar("bytesVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting double from DataObject with type byte[]
+ */
+ public void testBytesGetTypeConversionDouble() {
+ byte[] byteVal = {10, 100};
+ DataObject product = createBytesObject(byteVal);
+ try {
+ product.getDouble("bytesVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting float from DataObject with type byte[]
+ */
+ public void testBytesGetTypeConversionFloat() {
+ byte[] byteVal = {10, 100};
+ DataObject product = createBytesObject(byteVal);
+ try {
+ product.getFloat("bytesVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting int from DataObject with type byte[]
+ */
+ public void testBytesGetTypeConversionInt() {
+ byte[] byteVal = {10, 100};
+ DataObject product = createBytesObject(byteVal);
+ try {
+ product.getInt("bytesVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting long from DataObject with type byte[]
+ */
+ public void testBytesGetTypeConversionLong() {
+ byte[] byteVal = {10, 100};
+ DataObject product = createBytesObject(byteVal);
+ try {
+ product.getLong("bytesVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting short from DataObject with type byte[]
+ */
+ public void testBytesGetTypeConversionShort() {
+ byte[] byteVal = {10, 100};
+ DataObject product = createBytesObject(byteVal);
+ try {
+ product.getShort("bytesVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting string from DataObject with type byte[]
+ */
+ public void testBytesGetTypeConversionString() {
+ byte[] byteVal = {10, 100};
+ DataObject product = createBytesObject(byteVal);
+ String strRes = product.getString("bytesVal");
+ assertEquals(0, strRes.compareToIgnoreCase("0a64"));
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting BigDecimal from DataObject with type byte[]
+ */
+ public void testBytesGetTypeConversionBigDecimal() {
+ byte[] byteVal = {10, 100};
+ DataObject product = createBytesObject(byteVal);
+ try {
+ product.getBigDecimal("bytesVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting BigInteger from DataObject with type byte[]
+ */
+ public void testBytesGetTypeConversionBigInteger() {
+ byte[] byteVal = {10, 100};
+ DataObject product = createBytesObject(byteVal);
+ BigInteger biVal = product.getBigInteger("bytesVal");
+ byte[] bytesRes = biVal.toByteArray();
+
+ assertEquals(2, bytesRes.length);
+ assertEquals(10, bytesRes[0]);
+ assertEquals(100, bytesRes[1]);
+ //System.out.println("testBytesGetTypeConversionBigInteger="+);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting date from DataObject with type byte[]
+ */
+ public void testBytesGetTypeConversionDate() {
+ byte[] byteVal = {10, 100};
+ DataObject product = createBytesObject(byteVal);
+ try {
+ product.getDate("bytesVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * Helper function for Decimal converions tests.
+ * creates a DataObject with 'bigDecimalVal' BigDecimal property
+ *
+ * @param initialVal the initial value of the data hold property.
+ * @return the initialized DataObject.
+ */
+ private DataObject createBigDecimalObject(BigDecimal initialVal) {
+ DataObject productType = createTypeConversionObject("bigDecimalVal", "Decimal");
+ productType.setBigDecimal("bigDecimalVal", initialVal);
+ return productType;
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting boolean from DataObject with type BigDecimal
+ */
+ public void testBigDecimalGetTypeConversionBoolean() {
+ DataObject product = createBigDecimalObject(new BigDecimal(4));
+ try {
+ product.getBoolean("bigDecimalVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting byte from DataObject with type BigDecimal
+ */
+ public void testBigDecimalGetTypeConversionByte() {
+ DataObject product = createBigDecimalObject(new BigDecimal(4));
+ try {
+ product.getByte("bigDecimalVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting char from DataObject with type BigDecimal
+ */
+ public void testBigDecimalGetTypeConversionChar() {
+ DataObject product = createBigDecimalObject(new BigDecimal(4));
+ try {
+ product.getChar("bigDecimalVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting double from DataObject with type BigDecimal
+ */
+ public void testBigDecimalGetTypeConversionDouble() {
+ DataObject product = createBigDecimalObject(new BigDecimal(4));
+ double doubleVal = product.getDouble("bigDecimalVal");
+ assertTrue(doubleVal == 4);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting float from DataObject with type BigDecimal
+ */
+ public void testBigDecimalGetTypeConversionFloat() {
+ DataObject product = createBigDecimalObject(new BigDecimal(4));
+ float floatVal = product.getFloat("bigDecimalVal");
+ assertTrue(floatVal == 4);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting int from DataObject with type BigDecimal
+ */
+ public void testBigDecimalGetTypeConversionInt() {
+ DataObject product1 = createBigDecimalObject(new BigDecimal(4));
+ int intVal = product1.getInt("bigDecimalVal");
+ assertTrue(intVal == 4);
+
+ BigDecimal value = new BigDecimal(4.4);
+ DataObject product = createBigDecimalObject(value);
+ int i = product.getInt("bigDecimalVal");
+ assertEquals( value.intValue(), i );
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting long from DataObject with type BigDecimal
+ */
+ public void testBigDecimalGetTypeConversionLong() {
+ DataObject product1 = createBigDecimalObject(new BigDecimal(4));
+ long intVal = product1.getLong("bigDecimalVal");
+ assertTrue(intVal == 4);
+
+ BigDecimal value = new BigDecimal(4.4);
+ DataObject product = createBigDecimalObject(value);
+ long l = product.getLong("bigDecimalVal");
+ assertEquals( value.longValue(), l );
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting short from DataObject with type BigDecimal
+ */
+ public void testBigDecimalGetTypeConversionShort() {
+ DataObject product = createBigDecimalObject(new BigDecimal(4));
+ try {
+ product.getShort("bigDecimalVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting string from DataObject with type BigDecimal
+ */
+ public void testBigDecimalGetTypeConversionString() {
+ BigDecimal initialVal = new BigDecimal(4);
+ DataObject product = createBigDecimalObject(initialVal);
+
+ String strVal = product.getString("bigDecimalVal");
+ assertEquals(strVal, initialVal.toString());
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting byte[] from DataObject with type BigDecimal
+ */
+ public void testBigDecimalGetTypeConversionBytes() {
+ DataObject product = createBigDecimalObject(new BigDecimal(4));
+ try {
+ product.getBytes("bigDecimalVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting BigInteger from DataObject with type BigDecimal
+ */
+ public void testBigDecimalGetTypeConversionBigInteger() {
+ DataObject product1 = createBigDecimalObject(new BigDecimal(4));
+ BigInteger biVal = product1.getBigInteger("bigDecimalVal");
+ assertTrue(biVal.intValue() == 4);
+
+ BigDecimal value = new BigDecimal(4.4);
+ DataObject product = createBigDecimalObject(value);
+ BigInteger big = product.getBigInteger("bigDecimalVal");
+ assertEquals( value.toBigInteger(), big );
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting date from DataObject with type BigDecimal
+ */
+ public void testBigDecimalGetTypeConversionDate() {
+ DataObject product = createBigDecimalObject(new BigDecimal(4));
+ try {
+ product.getDate("bigDecimalVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * Helper function for BigInteger converions tests.
+ * Creates a DataObject with 'bigIntegerVal' BigInteger property.
+ *
+ * @param initialVal the initial value of the data hold property.
+ * @return the initialized DataObject.
+ */
+ private DataObject createBigIntegerObject(BigInteger initialVal) {
+ DataObject productType = createTypeConversionObject("bigIntegerVal", "Integer");
+ productType.setBigInteger("bigIntegerVal", initialVal);
+ return productType;
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting boolean from DataObject with type BigInteger
+ */
+ public void testBigIntegerGetTypeConversionBoolean() {
+ DataObject product = createBigIntegerObject(BigInteger.valueOf(4));
+ try {
+ product.getBoolean("bigIntegerVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting byte from DataObject with type BigInteger
+ */
+ public void testBigIntegerGetTypeConversionByte() {
+ DataObject product = createBigIntegerObject(BigInteger.valueOf(4));
+ try {
+ product.getByte("bigIntegerVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting char from DataObject with type BigInteger
+ */
+ public void testBigIntegerGetTypeConversionChar() {
+ DataObject product = createBigIntegerObject(BigInteger.valueOf(4));
+ try {
+ product.getChar("bigIntegerVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting double from DataObject with type BigInteger
+ */
+ public void testBigIntegerGetTypeConversionDouble() {
+ DataObject product = createBigIntegerObject(BigInteger.valueOf(4));
+ double doubleVal = product.getDouble("bigIntegerVal");
+ assertTrue(doubleVal == 4);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting float from DataObject with type BigInteger
+ */
+ public void testBigIntegerGetTypeConversionFloat() {
+ DataObject product = createBigIntegerObject(BigInteger.valueOf(4));
+
+ float floatVal = product.getFloat("bigIntegerVal");
+ assertTrue(floatVal == 4);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting int from DataObject with type BigInteger
+ */
+ public void testBigIntegerGetTypeConversionInt() {
+ DataObject product = createBigIntegerObject(BigInteger.valueOf(4));
+
+ int intVal = product.getInt("bigIntegerVal");
+ assertTrue(intVal == 4);
+
+ BigInteger value = BigInteger.valueOf(Long.MAX_VALUE);
+ DataObject product1 = createBigIntegerObject(value);
+ int i = product1.getInt("bigIntegerVal");
+ assertEquals( value.intValue(), i );
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting long from DataObject with type BigInteger
+ */
+ public void testBigIntegerGetTypeConversionLong() {
+ DataObject product = createBigIntegerObject(BigInteger.valueOf(4));
+
+ long longVal = product.getLong("bigIntegerVal");
+ assertTrue(longVal == 4);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting short from DataObject with type BigInteger
+ */
+ public void testBigIntegerGetTypeConversionShort() {
+ DataObject product = createBigIntegerObject(BigInteger.valueOf(4));
+ try {
+ product.getShort("bigIntegerVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting string from DataObject with type BigInteger
+ */
+ public void testBigIntegerGetTypeConversionString() {
+ DataObject product = createBigIntegerObject(BigInteger.valueOf(4));
+
+ String strVal = product.getString("bigIntegerVal");
+ assertTrue(strVal.compareTo("4") == 0);
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting byte[] from DataObject with type BigInteger
+ */
+ public void testBigIntegerGetTypeConversionBytes() {
+ byte[] byteVal = {10, 100};
+ DataObject product = createBigIntegerObject(new BigInteger(byteVal));
+
+ byte[] bytesRes = product.getBytes("bigIntegerVal");
+ assertNotNull(bytesRes);
+
+ assertEquals(2, bytesRes.length);
+ assertEquals(10, bytesRes[0]);
+ assertEquals(100, bytesRes[1]);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting BigDecimal from DataObject with type BigInteger
+ */
+ public void testBigIntegerGetTypeConversionBigDecimal() {
+ DataObject product = createBigIntegerObject(BigInteger.valueOf(4));
+
+ BigDecimal bdVal = product.getBigDecimal("bigIntegerVal");
+ assertTrue(bdVal.intValue() == 4);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting date from DataObject with type BigInteger
+ */
+ public void testBigIntegerGetTypeConversionDate() {
+ DataObject product = createBigIntegerObject(BigInteger.valueOf(4));
+ try {
+ product.getDate("bigIntegerVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * Helper function for Date converions tests.
+ * Creates a DataObject with 'dateVal' date property.
+ *
+ * @param initialVal the initial value of the data hold property.
+ * @return the initialized DataObject.
+ */
+ private DataObject createDateObject(Date initialVal) {
+ DataObject productType = createTypeConversionObject("dateVal", "Date");
+ productType.setDate("dateVal", initialVal);
+ return productType;
+ }
+
+
+ /**
+ * DataObject class test.
+ * Testing getting boolean from DataObject with type date
+ */
+ public void testDateGetTypeConversionBoolean() {
+ DataObject product = createDateObject(new Date());
+ try {
+ product.getBoolean("dateVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting byte from DataObject with type date
+ */
+ public void testDateGetTypeConversionByte() {
+ DataObject product = createDateObject(new Date());
+ try {
+ product.getByte("dateVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting char from DataObject with type date
+ */
+ public void testDateGetTypeConversionChar() {
+ DataObject product = createDateObject(new Date());
+ try {
+ product.getChar("dateVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting double from DataObject with type date
+ */
+ public void testDateGetTypeConversionDouble() {
+ DataObject product = createDateObject(new Date());
+ try {
+ product.getDouble("dateVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting float from DataObject with type date
+ */
+ public void testDateGetTypeConversionFloat() {
+ DataObject product = createDateObject(new Date());
+ try {
+ product.getFloat("dateVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting int from DataObject with type date
+ */
+ public void testDateGetTypeConversionInt() {
+ DataObject product = createDateObject(new Date());
+ try {
+ product.getInt("dateVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting long from DataObject with type date
+ */
+ public void testDateGetTypeConversionLong() {
+ Date dateNow = new Date();
+ DataObject product = createDateObject(dateNow);
+
+ long longVal = product.getLong("dateVal");
+ assertEquals(dateNow.getTime(), longVal);
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting short from DataObject with type date
+ */
+ public void testDateGetTypeConversionShort() {
+ DataObject product = createDateObject(new Date());
+ try {
+ product.getShort("dateVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting string from DataObject with type date
+ */
+ public void testDateGetTypeConversionString() {
+ Date dateNow = new Date();
+ DataObject product = createDateObject(dateNow);
+ String strVal = product.getString("dateVal");
+
+
+ String dateString = f.format(dateNow);
+
+ assertTrue(strVal.compareTo(dateString) == 0);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting byte[] from DataObject with type date
+ */
+ public void testDateGetTypeConversionBytes() {
+ DataObject product = createDateObject(new Date());
+ try {
+ product.getBytes("dateVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting BigDecimal from DataObject with type date
+ */
+ public void testDateGetTypeConversionBigDecimal() {
+ DataObject product = createDateObject(new Date());
+ try {
+ product.getBigDecimal("dateVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing getting BigInteger from DataObject with type date
+ */
+ public void testDateGetTypeConversionBigInteger() {
+ DataObject product = createDateObject(new Date());
+ try {
+ product.getBigInteger("dateVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing setting byte to DataObject with type boolean
+ */
+ public void testBooleanSetTypeConversionByte() {
+ DataObject product = createBooleanObject(true);
+ try {//to byte
+ product.setByte("boolVal", (byte) 5);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing setting char to DataObject with type boolean
+ */
+ public void testBooleanSetTypeConversionChar() {
+ DataObject product = createBooleanObject(true);
+ try {
+ product.setChar("boolVal", 's');
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing setting double to DataObject with type boolean
+ */
+ public void testBooleanSetTypeConversionDouble() {
+ DataObject product = createBooleanObject(true);
+ try {
+ product.setDouble("boolVal", 5);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing setting float to DataObject with type boolean
+ */
+ public void testBooleanSetTypeConversionFloat() {
+ DataObject product = createBooleanObject(true);
+ try {
+ product.setFloat("boolVal", 5.5F);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing setting int to DataObject with type boolean
+ */
+ public void testBooleanSetTypeConversionInt() {
+ DataObject product = createBooleanObject(true);
+ try {
+ product.setInt("boolVal", 5);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing setting long to DataObject with type boolean
+ */
+ public void testBooleanSetTypeConversionLong() {
+ DataObject product = createBooleanObject(true);
+ try {
+ product.setLong("boolVal", 5);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing setting short to DataObject with type boolean
+ */
+ public void testBooleanSetTypeConversionShort() {
+ DataObject product = createBooleanObject(true);
+ try {
+ product.setShort("boolVal", (short) 5);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing setting string to DataObject with type boolean
+ */
+ public void testBooleanSetTypeConversionString() {
+ DataObject product = createBooleanObject(true);
+ product.setString("boolVal", "false");
+ boolean boolVal = product.getBoolean("boolVal");
+ assertFalse(boolVal);
+ product.setString("boolVal", "true");
+ boolVal = product.getBoolean("boolVal");
+ assertTrue(boolVal);
+ }
+
+ /**
+ * DataObject class test.
+ * Testing setting bytes[] to DataObject with type boolean
+ */
+ public void testBooleanSetTypeConversionBytes() {
+ DataObject product = createBooleanObject(true);
+ byte[] byteVal = {10, 100};
+ try {
+ product.setBytes("boolVal", byteVal);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing setting BigDecimal to DataObject with type boolean
+ */
+ public void testBooleanSetTypeConversionBigDecimal() {
+ DataObject product = createBooleanObject(true);
+ BigDecimal bdVal = new BigDecimal(4);
+ try {
+ product.setBigDecimal("boolVal", bdVal);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing setting BigInteger to DataObject with type boolean
+ */
+ public void testBooleanSetTypeConversionBigInteger() {
+ DataObject product = createBooleanObject(true);
+ try {
+ product.setBigInteger("boolVal", BigInteger.valueOf(4));
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing setting Date to DataObject with type boolean
+ */
+ public void testBooleanSetTypeConversionDate() {
+ DataObject product = createBooleanObject(true);
+ try {//to Date
+ product.setDate("boolVal", new Date());
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing setting boolean to DataObject with type byte
+ */
+ public void testByteSetTypeConversionBoolean() {
+ DataObject product = createByteObject((byte) 5);
+ try {
+ product.setBoolean("byteVal", true);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing setting char to DataObject with type byte
+ */
+ public void testByteSetTypeConversionChar() {
+ DataObject product = createByteObject((byte) 5);
+ try {
+ product.setChar("byteVal", 's');
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing setting double to DataObject with type byte
+ */
+ public void testByteSetTypeConversionDouble() {
+ DataObject product = createByteObject((byte) 5);
+
+ double value = 20;
+ product.setDouble("byteVal", value);
+ byte byteVal = product.getByte("byteVal");
+ assertEquals( (byte)value, byteVal );
+ }
+
+ /**
+ * DataObject class test.
+ * Testing setting float to DataObject with type byte
+ */
+ public void testByteSetTypeConversionFloat() {
+ DataObject product = createByteObject((byte) 5);
+
+ float value = 6;
+ product.setFloat("byteVal", value);
+ byte byteVal = product.getByte("byteVal");
+ assertEquals( (byte)value, byteVal );
+ }
+
+ /**
+ * DataObject class test.
+ * Testing setting int to DataObject with type byte
+ */
+ public void testByteSetTypeConversionInt() {
+ DataObject product = createByteObject((byte) 5);
+
+ int value = Byte.MAX_VALUE + 1;
+ product.setInt("byteVal", value);
+ byte byteVal = product.getByte("byteVal");
+ assertEquals( (byte)value, byteVal );
+ }
+
+ /**
+ * DataObject class test.
+ * Testing setting long to DataObject with type byte
+ */
+ public void testByteSetTypeConversionLong() {
+ DataObject product = createByteObject((byte) 5);
+
+ long value = 123456789;
+ product.setLong("byteVal", value);
+ byte byteVal = product.getByte("byteVal");
+ assertEquals( (byte)value, byteVal );
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing setting short to DataObject with type byte
+ */
+ public void testByteSetTypeConversionShort() {
+ DataObject product = createByteObject((byte) 5);
+
+ short s = (short) 6;
+ product.setShort("byteVal", s);
+ byte byteVal = product.getByte("byteVal");
+ assertEquals( (byte) s, byteVal );
+ }
+
+ /**
+ * DataObject class test.
+ * Testing setting String to DataObject with type byte
+ */
+ public void testByteSetTypeConversionString() {
+ DataObject product = createByteObject((byte) 5);
+
+ product.setString("byteVal", "6");
+ byte byteVal = product.getByte("byteVal");
+ assertTrue(byteVal == 6);
+
+ try {
+ product.setString("byteVal", "string");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing setting bytes[] to DataObject with type byte
+ */
+ public void testByteSetTypeConversionBytes() {
+ DataObject product = createByteObject((byte) 5);
+ byte[] byteVal = {10, 100};
+ try {
+ product.setBytes("byteVal", byteVal);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing setting BigDecimal to DataObject with type byte
+ */
+ public void testByteSetTypeConversionBigDecimal() {
+ DataObject product = createByteObject((byte) 5);
+ try {
+ product.setBigDecimal("byteVal", new BigDecimal(4));
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing setting BigInteger to DataObject with type byte
+ */
+ public void testByteSetTypeConversionBigInteger() {
+ DataObject product = createByteObject((byte) 5);
+ try {
+ product.setBigInteger("byteVal", BigInteger.valueOf(4));
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
+ //expected
+ }
+
+ }
+
+ /**
+ * DataObject class test.
+ * Testing setting Date to DataObject with type byte
+ */
+ public void testByteSetTypeConversionDate() {
+ DataObject product = createByteObject((byte) 5);
+ try {
+ product.setDate("byteVal", new Date());
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ }
+ catch (ClassCastException e) {
[... 1894 lines stripped ...]
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org