summaryrefslogtreecommitdiffstats
path: root/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion
diff options
context:
space:
mode:
Diffstat (limited to 'sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion')
-rw-r--r--sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/ConversionBase.java287
-rw-r--r--sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/DateConversionTest.java397
-rw-r--r--sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/StringConversionTest.java746
-rw-r--r--sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/TypeConversionTest.java3583
-rw-r--r--sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/TypeConversionTest2.java1301
-rw-r--r--sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/package.html25
6 files changed, 6339 insertions, 0 deletions
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/ConversionBase.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/ConversionBase.java
new file mode 100644
index 0000000000..83713db7e5
--- /dev/null
+++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/ConversionBase.java
@@ -0,0 +1,287 @@
+/**
+ *
+ * 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.conversion;
+
+import junit.framework.TestCase;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.TimeZone;
+import java.util.Date;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+import test.sdo21.framework.TestHelper;
+import test.sdo21.framework.junit3_8.CTSTestCase;
+import test.sdo21.CTSSuite;
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.TypeHelper;
+
+/**
+ * Base class for conversion tests.
+ */
+public class ConversionBase extends CTSTestCase {
+
+ /**
+ * This variable is used to create unique type names to avoid name clashes
+ * in TypeHelper
+ */
+ protected static int unique = 0;
+
+ /**
+ * DateFormat is set up in the constructor as per the format in the
+ * specification.
+ */
+ protected DateFormat f;
+
+ /**
+ * The TestHelper interface provides access to SDO helper classes.
+ */
+ protected TestHelper testHelper;
+
+ /**
+ * Message to use when an invalid type conversion does not throw a
+ * ClassCastException
+ */
+ protected static final String EXPECTED_CLASS_CAST_EXCEPTION =
+ "ClassCastException should have been thrown (invalid conversion)";
+
+
+ public ConversionBase(String string) {
+ super(string);
+ }
+
+ /**
+ * Sets up a time format and obtain a test helper.
+ */
+ public 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 = 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 = getScope().getTypeHelper();
+
+ // create new DataType
+ String uri = "http://example.com/TypeConversionTest/" + unique;
+ String name = "TypeConversionTest" + unique;
+ unique++;
+ DataObject productType = getScope().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 getScope().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.
+ */
+ protected DataObject createBooleanObject(boolean initialVal) {
+ DataObject productType = createTypeConversionObject("boolVal", "Boolean");
+ productType.setBoolean("boolVal", initialVal);
+ return productType;
+ }
+
+ /**
+ * 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.
+ */
+ protected DataObject createByteObject(byte initialVal) {
+ DataObject productType = createTypeConversionObject("byteVal", "Byte");
+ productType.setByte("byteVal", initialVal);
+ return productType;
+ }
+
+ /**
+ * 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.
+ */
+ protected DataObject createCharObject(char initialVal) {
+ DataObject productType = createTypeConversionObject("charVal", "Character");
+ productType.setChar("charVal", initialVal);
+ return productType;
+ }
+
+ /**
+ * 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.
+ */
+ protected DataObject createDoubleObject(double initialVal) {
+ DataObject productType = createTypeConversionObject("doubleVal", "Double");
+ productType.setDouble("doubleVal", initialVal);
+ return productType;
+ }
+
+ /**
+ * 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.
+ */
+ protected DataObject createFloatObject(float initialVal) {
+ DataObject productType = createTypeConversionObject("floatVal", "Float");
+ productType.setFloat("floatVal", initialVal);
+ return productType;
+ }
+
+ /**
+ * 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.
+ */
+ protected DataObject createIntObject(int initialVal) {
+ DataObject productType = createTypeConversionObject("intVal", "Int");
+ productType.setInt("intVal", initialVal);
+ return productType;
+ }
+
+ /**
+ * 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.
+ */
+ protected DataObject createLongObject(long initialVal) {
+ DataObject productType = createTypeConversionObject("longVal", "Long");
+ productType.setLong("longVal", initialVal);
+ return productType;
+ }
+
+ /**
+ * 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.
+ */
+ protected DataObject createShortObject(short initialVal) {
+ DataObject productType = createTypeConversionObject("shortVal", "Short");
+ productType.setShort("shortVal", initialVal);
+ return productType;
+ }
+
+ /**
+ * 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.
+ */
+ protected DataObject createStringObject(String initialVal) {
+ DataObject productType = createTypeConversionObject("stringVal", "String");
+ productType.setString("stringVal", initialVal);
+ return productType;
+ }
+
+ /**
+ * 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.
+ */
+ protected DataObject createBytesObject(byte[] initialVal) {
+ DataObject productType = createTypeConversionObject("bytesVal", "Bytes");
+ productType.setBytes("bytesVal", initialVal);
+ return productType;
+ }
+
+ /**
+ * 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.
+ */
+ protected DataObject createBigDecimalObject(BigDecimal initialVal) {
+ DataObject productType = createTypeConversionObject("bigDecimalVal", "Decimal");
+ productType.setBigDecimal("bigDecimalVal", initialVal);
+ return productType;
+ }
+
+ /**
+ * 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.
+ */
+ protected DataObject createBigIntegerObject(BigInteger initialVal) {
+ DataObject productType = createTypeConversionObject("bigIntegerVal", "Integer");
+ productType.setBigInteger("bigIntegerVal", initialVal);
+ return productType;
+ }
+
+ /**
+ * 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.
+ */
+ protected DataObject createDateObject(Date initialVal) {
+ DataObject productType = createTypeConversionObject("dateVal", "Date");
+ productType.setDate("dateVal", initialVal);
+ return productType;
+ }
+}
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/DateConversionTest.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/DateConversionTest.java
new file mode 100644
index 0000000000..b9f74007ad
--- /dev/null
+++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/DateConversionTest.java
@@ -0,0 +1,397 @@
+/*
+ * 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.
+ *
+ * $Rev$ $Date$
+ */
+package test.sdo21.tests.conversion;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.lang.reflect.Method;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+
+import test.sdo21.CTSSuite;
+import test.sdo21.framework.CTSTestCase;
+
+import commonj.sdo.helper.DataHelper;
+
+// TODO: Could convert to a paramatized test case and simplify this code a lot
+
+/**
+ * Set of tests for date and time related conversions. DateConversionTest
+ * insures that the DataHelper conversions accurately retain the information in
+ * the specified fields (e.g. month, day or year). It also provides coverage for
+ * the DataHelper API.
+ */
+public class DateConversionTest extends CTSTestCase {
+ private static Calendar test_calendar;
+
+ private static Date test_date;
+
+ private static DataHelper data_helper;
+
+ private static final TestType TO_DATE_TIME =
+ new TestType("toDateTime", new int[] {Calendar.YEAR, Calendar.MONTH, Calendar.DAY_OF_MONTH,
+ Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND,
+ Calendar.MILLISECOND});
+
+ private static final TestType TO_DURATION =
+ new TestType("toDuration", new int[] {Calendar.YEAR, Calendar.MONTH, Calendar.DAY_OF_MONTH,
+ Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND,
+ Calendar.MILLISECOND});
+
+ private static final TestType TO_TIME =
+ new TestType("toTime", new int[] {Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND, Calendar.MILLISECOND});
+
+ private static final TestType TO_DAY = new TestType("toDay", new int[] {Calendar.DAY_OF_MONTH});
+
+ private static final TestType TO_MONTH = new TestType("toMonth", new int[] {Calendar.MONTH});
+
+ private static final TestType TO_MONTH_DAY =
+ new TestType("toMonthDay", new int[] {Calendar.MONTH, Calendar.DAY_OF_MONTH});
+
+ private static final TestType TO_YEAR = new TestType("toYear", new int[] {Calendar.YEAR});
+
+ private static final TestType TO_YEAR_MONTH =
+ new TestType("toYearMonth", new int[] {Calendar.YEAR, Calendar.MONTH});
+
+ private static final TestType TO_YEAR_MONTH_DAY =
+ new TestType("toYearMonthDay", new int[] {Calendar.YEAR, Calendar.MONTH, Calendar.DAY_OF_MONTH});
+
+ /**
+ * Junit 4.1 will execute this once prior to test cases being executed. This
+ * sets up the Calendar with current date.
+ */
+ @BeforeClass
+ public static void setupCalender() {
+ data_helper = getTestHelper().createHelperContext().getDataHelper();
+ test_calendar = new GregorianCalendar();
+ test_calendar.setTime(new Date(System.currentTimeMillis()));
+ test_date = test_calendar.getTime();
+ }
+
+ private static class TestType {
+ private static final Class[] DATE_CLASS_ARRAY = {Date.class};
+
+ private static final Class[] CALENDAR_CLASS_ARRAY = {Calendar.class};
+
+ Method date_method;
+
+ Method calendar_method;
+
+ int[] compare_fields;
+
+ public TestType(String method_name, int[] compare_fields) {
+ try {
+ this.date_method = DataHelper.class.getMethod(method_name, DATE_CLASS_ARRAY);
+ } catch (NoSuchMethodException e) {
+ this.date_method = null;
+ }
+
+ this.compare_fields = compare_fields;
+ try {
+ this.calendar_method = DataHelper.class.getMethod(method_name, CALENDAR_CLASS_ARRAY);
+ } catch (NoSuchMethodException e) {
+ this.calendar_method = null;
+ }
+
+ }
+
+ public Method getDateMethod() {
+ return this.date_method;
+ }
+
+ public Method getCalendarMethod() {
+ return this.calendar_method;
+ }
+ }
+
+ private static class Test {
+ String from_type;
+
+ Date from_date;
+
+ Calendar from_calendar;
+
+ Class expected_exception;
+
+ public Test() {
+ from_date = null;
+ from_calendar = null;
+ expected_exception = null;
+ }
+
+ public void initialize(TestType from_type) {
+ this.from_type = from_type.getDateMethod().getName();
+
+ try {
+ String date_string = (String)from_type.getDateMethod().invoke(data_helper, new Object[] {test_date});
+ this.from_date = data_helper.toDate(date_string);
+ date_string = (String)from_type.getCalendarMethod().invoke(data_helper, new Object[] {test_calendar});
+ this.from_calendar = data_helper.toCalendar(date_string);
+ } catch (Exception e) {
+ throw new RuntimeException( "Failed to initialize test", e );
+ }
+
+ }
+
+ // This method is needed because there is not a toDate(Date) method in
+ // DataHelper.
+
+ private void initializeToDate() {
+ this.from_calendar = test_calendar;
+ this.from_date = test_date;
+ this.from_type = "toDate";
+ }
+
+ private void attemptConversion(TestType to_type) {
+ executeConversion(to_type.getDateMethod(), new Object[] {this.from_date}, to_type.compare_fields);
+ executeConversion(to_type.getCalendarMethod(), new Object[] {this.from_calendar}, to_type.compare_fields);
+ }
+
+ private void executeConversion(Method conversion, Object[] parm, int[] compare_fields) {
+ String result;
+
+ try {
+ result = (String)conversion.invoke(data_helper, parm);
+ assertNotNull( result );
+
+ compareFields(parm[0], result, compare_fields);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("An unexpected exception was thrown while calling " + conversion.getName()
+ + " after initializing with "
+ + this.from_type
+ + ":"
+ + e.toString());
+ }
+
+ }
+
+ private void compareFields(Object compare_to, String output, int[] compare_fields) {
+ Calendar result = data_helper.toCalendar(output);
+ assertNotNull( "data_helper.toCalendar(" + output + ") should not return null", result );
+ Calendar expected;
+
+ if (compare_to instanceof Calendar)
+ expected = (GregorianCalendar)test_calendar;
+ else {
+ expected = new GregorianCalendar();
+ expected.setTime((Date)test_date);
+ }
+
+ for (int i = 0; i < compare_fields.length; i++) {
+ int expectedValue = expected.get(compare_fields[i]);
+ int actualValue = result.get(compare_fields[i]);
+ if (expectedValue != actualValue) {
+ throw new IllegalStateException( "Expected: [" + expectedValue + "] != Actual: [" + actualValue + "]" );
+ }
+ }
+ }
+
+ }
+
+ /**
+ * testConversionsFromDay verifies each of the conversions from Day using
+ * the DataHelper
+ */
+ @org.junit.Test
+ public void testConversionsFromDay() {
+ Test FromDay = new Test();
+ FromDay.initialize(TO_DAY);
+ FromDay.attemptConversion(TO_DAY);
+ }
+
+ /**
+ * testConversionsFromDate verifies each of the conversions from Date using
+ * the DataHelper
+ */
+ @org.junit.Test
+ public void testConversionsFromDate() {
+ Test FromDate = new Test();
+
+ FromDate.initializeToDate();
+
+ FromDate.attemptConversion(TO_DATE_TIME);
+ FromDate.attemptConversion(TO_DURATION);
+ FromDate.attemptConversion(TO_TIME);
+ FromDate.attemptConversion(TO_DAY);
+ FromDate.attemptConversion(TO_MONTH);
+ FromDate.attemptConversion(TO_MONTH_DAY);
+ FromDate.attemptConversion(TO_YEAR);
+ FromDate.attemptConversion(TO_YEAR_MONTH);
+ FromDate.attemptConversion(TO_YEAR_MONTH_DAY);
+ }
+
+ /**
+ * testConversionsFromDateTime verifies each of the conversions from
+ * DateTime using the DataHelper
+ */
+ @org.junit.Test
+ public void testConversionsFromDateTime() {
+ Test FromDateTime = new Test();
+
+ FromDateTime.initialize(TO_DATE_TIME);
+
+ FromDateTime.attemptConversion(TO_DATE_TIME);
+ FromDateTime.attemptConversion(TO_DURATION);
+ FromDateTime.attemptConversion(TO_TIME);
+ FromDateTime.attemptConversion(TO_DAY);
+ FromDateTime.attemptConversion(TO_MONTH);
+ FromDateTime.attemptConversion(TO_MONTH_DAY);
+ FromDateTime.attemptConversion(TO_YEAR);
+ FromDateTime.attemptConversion(TO_YEAR_MONTH);
+ FromDateTime.attemptConversion(TO_YEAR_MONTH_DAY);
+ }
+
+ /**
+ * testConversionsFromDuration verifies each of the conversions from
+ * Duration using the DataHelper
+ */
+ @org.junit.Test
+ public void testConversionsFromDuration() {
+ Test FromDuration = new Test();
+
+ FromDuration.initialize(TO_DURATION);
+
+ FromDuration.attemptConversion(TO_DURATION);
+ FromDuration.attemptConversion(TO_DATE_TIME);
+ FromDuration.attemptConversion(TO_TIME);
+ FromDuration.attemptConversion(TO_DAY);
+ FromDuration.attemptConversion(TO_MONTH);
+ FromDuration.attemptConversion(TO_MONTH_DAY);
+ FromDuration.attemptConversion(TO_YEAR);
+ FromDuration.attemptConversion(TO_YEAR_MONTH);
+ FromDuration.attemptConversion(TO_YEAR_MONTH_DAY);
+ }
+
+ /**
+ * testConversionsFromMonth verifies each of the conversions from Month
+ * using the DataHelper
+ */
+ @org.junit.Test
+ public void testConversionsFromMonth() {
+ Test FromMonth = new Test();
+
+ FromMonth.initialize(TO_MONTH);
+
+ FromMonth.attemptConversion(TO_MONTH);
+ }
+
+ /**
+ * testConversionsFromMonthDay verifies each of the conversions from
+ * MonthDay using the DataHelper
+ */
+ @org.junit.Test
+ public void testConversionsFromMonthDay() {
+ Test FromMonthDay = new Test();
+
+ FromMonthDay.initialize(TO_MONTH_DAY);
+ FromMonthDay.attemptConversion(TO_MONTH_DAY);
+ FromMonthDay.attemptConversion(TO_MONTH);
+ FromMonthDay.attemptConversion(TO_DAY);
+ }
+
+ /**
+ * testConversionsFromTime verifies each of the conversions from Time using
+ * the DataHelper
+ */
+ @org.junit.Test
+ public void testConversionsFromTime() {
+ Test FromTime = new Test();
+
+ FromTime.initialize(TO_TIME);
+
+ FromTime.attemptConversion(TO_TIME);
+ }
+
+ /**
+ * testConversionsFromYear verifies each of the conversions from Year using
+ * the DataHelper
+ */
+ @org.junit.Test
+ public void testConversionsFromYear() {
+ Test FromYear = new Test();
+
+ FromYear.initialize(TO_YEAR);
+
+ FromYear.attemptConversion(TO_YEAR);
+ }
+
+ /**
+ * testConversionsFromYearMonth verifies each of the conversions from
+ * YearMonth using the DataHelper
+ */
+ @org.junit.Test
+ public void testConversionsFromYearMonth() {
+ Test FromYearMonth = new Test();
+
+ FromYearMonth.initialize(TO_YEAR_MONTH);
+
+ FromYearMonth.attemptConversion(TO_YEAR_MONTH);
+ FromYearMonth.attemptConversion(TO_MONTH);
+ FromYearMonth.attemptConversion(TO_YEAR);
+ }
+
+ /**
+ * testConversionsFromYearMonthDay verifies each of the conversions from
+ * YearMonthDay using the DataHelper
+ */
+ @org.junit.Test
+ public void testConversionsFromYearMonthDay() {
+ Test FromYearMonthDay = new Test();
+
+ FromYearMonthDay.initialize(TO_YEAR_MONTH_DAY);
+
+ FromYearMonthDay.attemptConversion(TO_YEAR_MONTH_DAY);
+ FromYearMonthDay.attemptConversion(TO_YEAR_MONTH);
+ FromYearMonthDay.attemptConversion(TO_MONTH_DAY);
+ FromYearMonthDay.attemptConversion(TO_YEAR);
+ FromYearMonthDay.attemptConversion(TO_MONTH);
+ FromYearMonthDay.attemptConversion(TO_DAY);
+ }
+
+ /**
+ * testToDateFormats verifies that strings that should be recognized by
+ * toDate do not result in a null Date value when passed to
+ * DataHelper.toDate(String).
+ */
+ @org.junit.Test
+ @Ignore("This individual test is effectively in the UnderReview set. See TUSCANY-1175")
+ public void testToDateFormats() {
+ String[] validStrings =
+ {"2006-03-31T03:30:45.123Z", "-2006-03-31T03:30:45.1Z", "2006-03-31T03:30:45Z", "2006-03-31T03:30:45.123",
+ "2006-03-31T03:30:45.1", "-2006-03-31T03:30:45", "2006-03-31T03:30:45.123 EDT",
+ "2006-03-31T03:30:45.1 EDT", "2006-03-31T03:30:45 EDT", "---05 PST", "---04", "--12 GMT", "--12",
+ "--08-08 EST", "--08-08", "1976-08-08 PDT", "1976-08-08", "88-12 CST", "1988-12", "2005 CDT", "1999",
+ "P2006Y 08M 10D T 12H 24M 07S", "P2006Y 10D T 12H", "-P2006Y 08M 10D T 07S.2", "P08M 10D T 07H",
+ "-P 04M 10DT12H 24S.88", "PT12H"};
+
+ for (int i = 0; i < validStrings.length; i++) {
+ assertNotNull("DataHelper.toData() should not return null for '" + validStrings[i] + "'.", data_helper
+ .toDate(validStrings[i]));
+ }
+ }
+}
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/StringConversionTest.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/StringConversionTest.java
new file mode 100644
index 0000000000..61a3112cc2
--- /dev/null
+++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/StringConversionTest.java
@@ -0,0 +1,746 @@
+/**
+ *
+ * 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.conversion;
+
+import commonj.sdo.DataObject;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Date;
+
+import junit.framework.TestCase;
+
+public class StringConversionTest extends ConversionBase {
+
+ public StringConversionTest(String string) {
+ super(string);
+ }
+
+ /**
+ * 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
+ }
+
+ }
+
+ /**
+ * 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 setting boolean to DataObject with type
+ * string
+ */
+ public void testStringSetTypeConversionBoolean() {
+ DataObject product = createStringObject("string");
+ product.setBoolean("stringVal", true);
+
+ String strVal = product.getString("stringVal");
+ assertEquals("true", strVal);
+
+ DataObject product1 = createStringObject("string");
+ product1.setBoolean("stringVal", false);
+ strVal = product1.getString("stringVal");
+ assertEquals("false", strVal);
+ }
+
+ /**
+ * DataObject class test. Testing setting byte to DataObject with type
+ * string
+ */
+ public void testStringSetTypeConversionByte() {
+ DataObject product = createStringObject("string");
+ product.setByte("stringVal", (byte)5);
+
+ String strVal = product.getString("stringVal");
+ assertEquals("5", strVal);
+ }
+
+ /**
+ * DataObject class test. Testing setting char to DataObject with type
+ * string
+ */
+ public void testStringSetTypeConversionChar() {
+ DataObject product = createStringObject("string");
+ product.setChar("stringVal", 'd');
+
+ String strVal = product.getString("stringVal");
+ assertEquals("d", strVal);
+ }
+
+ /**
+ * DataObject class test. Testing setting double to DataObject with type
+ * string
+ */
+ public void testStringSetTypeConversionDouble() {
+ DataObject product = createStringObject("string");
+ product.setDouble("stringVal", 5);
+ String strVal = product.getString("stringVal");
+ assertEquals("5.0", strVal);
+ }
+
+ /**
+ * DataObject class test. Testing setting float to DataObject with type
+ * string
+ */
+ public void testStringSetTypeConversionFloat() {
+ DataObject product = createStringObject("string");
+ product.setFloat("stringVal", 5.5F);
+ String strVal = product.getString("stringVal");
+ assertEquals("5.5", strVal);
+ }
+
+ /**
+ * DataObject class test. Testing setting int to DataObject with type string
+ */
+ public void testStringSetTypeConversionInt() {
+ DataObject product = createStringObject("string");
+ product.setInt("stringVal", 5);
+ String strVal = product.getString("stringVal");
+ assertEquals("5", strVal);
+ }
+
+ /**
+ * DataObject class test. Testing setting boolean to DataObject with type
+ * string
+ */
+ public void testStringSetTypeConversionLong() {
+ DataObject product = createStringObject("string");
+ product.setLong("stringVal", 5);
+
+ String strVal = product.getString("stringVal");
+ assertEquals("5", strVal);
+ }
+
+ /**
+ * DataObject class test. Testing setting short to DataObject with type
+ * string
+ */
+ public void testStringSetTypeConversionShort() {
+ DataObject product = createStringObject("string");
+ product.setShort("stringVal", (short)5);
+ String strVal = product.getString("stringVal");
+ assertEquals("5", strVal);
+ }
+
+ /**
+ * DataObject class test. Testing setting bytes to DataObject with type
+ * string
+ */
+ public void testStringSetTypeConversionBytes() {
+ DataObject product = createStringObject("string");
+
+ byte[] byteVal = {10, 100};
+ product.setBytes("stringVal", byteVal);
+
+ String strVal = product.getString("stringVal");
+ assertEquals("0a64", strVal);
+ }
+
+ /**
+ * DataObject class test. Testing setting decimal to DataObject with type
+ * string
+ */
+ public void testStringSetTypeConversionBigDecimal() {
+ DataObject product = createStringObject("string");
+ BigDecimal initialValue = new BigDecimal(5);
+ product.setBigDecimal("stringVal", initialValue);
+
+ String strVal = product.getString("stringVal");
+ assertEquals(initialValue.toString(), strVal);
+ }
+
+ /**
+ * DataObject class test. Testing setting BigInteger to DataObject with type
+ * string
+ */
+ public void testStringSetTypeConversionBigInteger() {
+ DataObject product = createStringObject("string");
+ product.setBigInteger("stringVal", BigInteger.valueOf(5));
+
+ String strVal = product.getString("stringVal");
+ assertEquals("5", strVal);
+ }
+
+ /**
+ * DataObject class test. Testing setting date to DataObject with type
+ * string
+ */
+ public void testStringSetTypeConversionDate() {
+ Date bdTemp = new Date();
+ String dateString = f.format(bdTemp);
+
+ DataObject product = createStringObject("string");
+ product.setDate("stringVal", bdTemp);
+ String strVal = product.getString("stringVal");
+ assertEquals(dateString, strVal);
+ }
+
+ /**
+ * 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 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 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 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 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 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 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 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 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 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 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 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 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 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 string to DataObject with type
+ * char
+ */
+ public void testCharSetTypeConversionString() {
+ DataObject product = createCharObject('s');
+
+ product.setString("charVal", "string");
+ char charVal = product.getChar("charVal");
+ assertTrue(charVal == 's');
+ }
+
+ /**
+ * DataObject class test. Testing setting string to DataObject with type
+ * double
+ */
+ public void testDoubleSetTypeConversionString() {
+ DataObject product = createDoubleObject(5);
+ product.setString("doubleVal", "6");
+ double doubleVal = product.getDouble("doubleVal");
+ assertTrue(doubleVal == 6);
+
+ DataObject product1 = createDoubleObject(5);
+ try {
+ product1.setString("doubleVal", "string");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting string from DataObject with type
+ * float
+ */
+ public void testFloatSetTypeConversionString() {
+ DataObject product = createFloatObject(5.5F);
+ product.setString("floatVal", "6.0");
+
+ float floatVal = product.getFloat("floatVal");
+ assertTrue(floatVal == 6);
+
+ DataObject product1 = createFloatObject(5);
+ try {
+ product1.setString("floatVal", "string");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting string to DataObject with type int
+ */
+ public void testIntSetTypeConversionString() {
+ DataObject product = createIntObject(5);
+ product.setString("intVal", "6");
+
+ int intVal = product.getInt("intVal");
+ assertTrue(intVal == 6);
+
+ DataObject product1 = createIntObject(5);
+ try {
+ product1.setString("intVal", "string");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting string to DataObject with type
+ * long
+ */
+ public void testLongSetTypeConversionString() {
+ DataObject product = createLongObject(5);
+ product.setString("longVal", "6");
+ long longVal = product.getLong("longVal");
+ assertTrue(longVal == 6);
+
+ DataObject product1 = createLongObject(5);
+ try {
+ product1.setString("longVal", "string");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting string to DataObject with type
+ * short
+ */
+ public void testShortSetTypeConversionString() {
+ DataObject product = createShortObject((short)5);
+ product.setString("shortVal", "6");
+ short shortVal = product.getShort("shortVal");
+ assertTrue(shortVal == 6);
+
+ DataObject product1 = createShortObject((short)5);
+ try {
+ product1.setString("shortVal", "string");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting string to DataObject with type
+ * byte[]
+ */
+ public void testBytesSetTypeConversionString() {
+ byte[] byteVal = {1, 2};
+ DataObject product = createBytesObject(byteVal);
+ product.setString("bytesVal", "0a64");
+ byte[] bytesRes = product.getBytes("bytesVal");
+ assertNotNull(bytesRes);
+
+ assertEquals(2, bytesRes.length);
+ assertEquals(10, bytesRes[0]);
+ assertEquals(100, bytesRes[1]);
+ }
+
+ /**
+ * DataObject class test. Testing setting string to DataObject with type
+ * BigDecimal
+ */
+ public void testBigDecimalSetTypeConversionString() {
+ DataObject product = createBigDecimalObject(new BigDecimal(4));
+ product.setString("bigDecimalVal", "5");
+
+ BigDecimal bdVal = product.getBigDecimal("bigDecimalVal");
+ assertTrue(bdVal.intValue() == 5);
+ }
+
+ /**
+ * DataObject class test. Testing setting string to DataObject with type
+ * BigInteger
+ */
+ public void testBigIntegerSetTypeConversionString() {
+ DataObject product = createBigIntegerObject(BigInteger.valueOf(4));
+
+ product.setString("bigIntegerVal", "5");
+ BigInteger biVal = product.getBigInteger("bigIntegerVal");
+ assertTrue(biVal.intValue() == 5);
+ }
+
+ /**
+ * DataObject class test. Testing setting string to DataObject with type
+ * date
+ */
+ public void testDateSetTypeConversionString() {
+ Date dateNow = new Date();
+ DataObject product = createDateObject(dateNow);
+
+ String dateString = f.format(dateNow);
+ product.setString("dateVal", dateString);
+
+ Date dateRes = product.getDate("dateVal");
+ assertEquals(dateNow.getTime(), dateRes.getTime());
+ }
+
+
+}
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/TypeConversionTest.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/TypeConversionTest.java
new file mode 100644
index 0000000000..21abeb1aba
--- /dev/null
+++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/TypeConversionTest.java
@@ -0,0 +1,3583 @@
+/**
+ *
+ * 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.conversion;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Date;
+
+
+import commonj.sdo.DataObject;
+
+/**
+ * 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)
+ *
+ * TODO there is overlap between this test and {@link TypeConversionTest2} which
+ * needs to be resolved
+ */
+
+// TODO: could use expected exception function of test annotation
+public class TypeConversionTest extends ConversionBase {
+
+ public TypeConversionTest(String string) {
+ super(string);
+ }
+
+ /**
+ * 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 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
+ }
+ }
+
+ /**
+ * 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 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() {
+ byte value = 5;
+ DataObject product = createByteObject(value);
+ assertEquals( new BigDecimal(value), product.getBigDecimal("byteVal") );
+ }
+
+ /**
+ * DataObject class test. Testing getting BigInteger from DataObject with
+ * type byte
+ */
+ public void testByteGetTypeConversionBigInteger() {
+ byte value = 5;
+ DataObject product = createByteObject(value);
+ assertEquals( new BigInteger(String.valueOf(value)), product.getBigInteger("byteVal") );
+ }
+
+ /**
+ * 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
+ }
+ }
+
+ /**
+ * 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 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
+ }
+ }
+
+ /**
+ * 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 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
+ }
+ }
+
+ /**
+ * 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 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
+ }
+ }
+
+ /**
+ * 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 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
+ }
+ }
+
+ /**
+ * 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 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());
+ }
+
+ /**
+ * 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 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() {
+ short value = 5;
+ DataObject dobj = createShortObject(value);
+ assertEquals( new BigDecimal(value), dobj.getBigDecimal("shortVal") );
+ }
+
+ /**
+ * DataObject class test. Testing getting BigInteger from DataObject with
+ * type short
+ */
+ public void testShortGetTypeConversionBigInteger() {
+ short value = 5;
+ DataObject dobj = createShortObject(value);
+ assertEquals( new BigInteger(String.valueOf(value)), dobj.getBigInteger("shortVal") );
+ }
+
+ /**
+ * 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
+ }
+
+ }
+
+ /**
+ * 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 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
+ }
+
+ }
+
+ /**
+ * 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() {
+ BigDecimal value = new BigDecimal(4);
+ DataObject product = createBigDecimalObject(value);
+ assertEquals( value.byteValue(), product.getByte("bigDecimalVal") );
+ }
+
+ /**
+ * 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() {
+ BigDecimal value = new BigDecimal(4);
+ DataObject product = createBigDecimalObject(value);
+ assertEquals( value.shortValue(), product.getShort("bigDecimalVal") );
+ }
+
+ /**
+ * 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
+ }
+
+ }
+
+ /**
+ * 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() {
+ BigInteger value = new BigInteger("5");
+ DataObject product = createBigIntegerObject(value);
+ assertEquals( value.byteValue(), product.getByte("bigIntegerVal") );
+ }
+
+ /**
+ * 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() {
+ BigInteger value = new BigInteger("5");
+ DataObject product = createBigIntegerObject(value);
+ assertEquals( value.shortValue(), product.getShort("bigIntegerVal") );
+ }
+
+ /**
+ * 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
+ }
+
+ }
+
+ /**
+ * 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 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 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 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() {
+ byte value = 5;
+ byte newVal = 25;
+ DataObject product = createByteObject(value);
+ product.setBigDecimal("byteVal", new BigDecimal(newVal));
+ assertEquals( newVal, product.getByte("byteVal") );
+ }
+
+ /**
+ * DataObject class test. Testing setting BigInteger to DataObject with type
+ * byte
+ */
+ public void testByteSetTypeConversionBigInteger() {
+ byte value = 5;
+ byte newVal = 25;
+ DataObject product = createByteObject(value);
+ product.setBigInteger("byteVal", BigInteger.valueOf(newVal));
+ assertEquals( newVal, product.getByte("byteVal") );
+ }
+
+ /**
+ * 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) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting boolean to DataObject with type
+ * char
+ */
+ public void testCharSetTypeConversionBoolean() {
+ DataObject product = createCharObject('s');
+ try {
+ product.setBoolean("charVal", true);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting byte to DataObject with type char
+ */
+ public void testCharSetTypeConversionByte() {
+ DataObject product = createCharObject('s');
+ try {
+ product.setByte("charVal", (byte)5);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting double to DataObject with type
+ * char
+ */
+ public void testCharSetTypeConversionDouble() {
+ DataObject product = createCharObject('s');
+ try {
+ product.setDouble("charVal", (double)5);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting float to DataObject with type char
+ */
+ public void testCharSetTypeConversionFloat() {
+ DataObject product = createCharObject('s');
+ try {
+ product.setFloat("charVal", 5.5F);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting int to DataObject with type char
+ */
+ public void testCharSetTypeConversionInt() {
+ DataObject product = createCharObject('s');
+ try {
+ product.setInt("charVal", 5);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting long to DataObject with type char
+ */
+ public void testCharSetTypeConversionLong() {
+ DataObject product = createCharObject('s');
+ try {
+ product.setLong("charVal", (long)5);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting short to DataObject with type char
+ */
+ public void testCharSetTypeConversionShort() {
+ DataObject product = createCharObject('s');
+ try {
+ product.setShort("charVal", (short)5);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting bytes[] to DataObject with type
+ * char
+ */
+ public void testCharSetTypeConversionBytes() {
+ DataObject product = createCharObject('s');
+ byte[] byteVal = {10, 100};
+ try {
+ product.setBytes("charVal", byteVal);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting BigDecimal to DataObject with type
+ * char
+ */
+ public void testCharSetTypeConversionBigDecimal() {
+ DataObject product = createCharObject('s');
+ try {
+ product.setBigDecimal("charVal", new BigDecimal(4));
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting BigInteger to DataObject with type
+ * char
+ */
+ public void testCharSetTypeConversionBigInteger() {
+ DataObject product = createCharObject('s');
+ try {
+ product.setBigInteger("charVal", BigInteger.valueOf(5));
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting Date to DataObject with type char
+ */
+ public void testCharSetTypeConversionDate() {
+ DataObject product = createCharObject('s');
+ try {
+ product.setDate("charVal", new Date());
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting boolean to DataObject with type
+ * double
+ */
+ public void testDoubleSetTypeConversionBoolean() {
+ DataObject product = createDoubleObject(5);
+ try {
+ product.setBoolean("doubleVal", true);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting byte to DataObject with type
+ * double
+ */
+ public void testDoubleSetTypeConversionByte() {
+ DataObject product1 = createDoubleObject(5);
+ product1.setByte("doubleVal", (byte)6);
+ double doubleVal = product1.getDouble("doubleVal");
+ assertTrue(doubleVal == 6);
+ }
+
+ /**
+ * DataObject class test. Testing setting char to DataObject with type
+ * double
+ */
+ public void testDoubleSetTypeConversionChar() {
+ DataObject product = createDoubleObject(5);
+ try {
+ product.setChar("doubleVal", 's');
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting float to DataObject with type
+ * double
+ */
+ public void testDoubleSetTypeConversionFloat() {
+ DataObject product1 = createDoubleObject(5);
+ product1.setFloat("doubleVal", 6);
+ double doubleVal = product1.getDouble("doubleVal");
+ assertTrue(doubleVal == 6);
+ }
+
+ /**
+ * DataObject class test. Testing setting int to DataObject with type double
+ */
+ public void testDoubleSetTypeConversionInt() {
+ DataObject product1 = createDoubleObject(5);
+ product1.setInt("doubleVal", 6);
+ double doubleVal = product1.getDouble("doubleVal");
+ assertTrue(doubleVal == 6);
+ }
+
+ /**
+ * DataObject class test. Testing setting long to DataObject with type
+ * double
+ */
+ public void testDoubleSetTypeConversionLong() {
+ DataObject product1 = createDoubleObject(5);
+ product1.setLong("doubleVal", (long)6);
+ double doubleVal = product1.getDouble("doubleVal");
+ assertTrue(doubleVal == 6);
+ }
+
+ /**
+ * DataObject class test. Testing setting short to DataObject with type
+ * double
+ */
+ public void testDoubleSetTypeConversionShort() {
+ DataObject product1 = createDoubleObject(5);
+ product1.setShort("doubleVal", (short)6);
+ double doubleVal = product1.getDouble("doubleVal");
+ assertTrue(doubleVal == 6);
+ }
+
+ /**
+ * DataObject class test. Testing setting byte[] to DataObject with type
+ * double
+ */
+ public void testDoubleSetTypeConversionBytes() {
+ DataObject product = createDoubleObject(5);
+ byte[] byteVal = {10, 100};
+ try {
+ product.setBytes("doubleVal", byteVal);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting Bigdecimal to DataObject with type
+ * double
+ */
+ public void testDoubleSetTypeConversionBigDecimal() {
+ DataObject product = createDoubleObject(5);
+
+ product.setBigDecimal("doubleVal", new BigDecimal(6));
+ double doubleVal = product.getDouble("doubleVal");
+ assertTrue(doubleVal == 6);
+ }
+
+ /**
+ * DataObject class test. Testing setting BigInteger to DataObject with type
+ * double
+ */
+ public void testDoubleSetTypeConversionBigInteger() {
+ DataObject product = createDoubleObject(5);
+
+ product.setBigInteger("doubleVal", BigInteger.valueOf(6));
+ double doubleVal = product.getDouble("doubleVal");
+ assertTrue(doubleVal == 6);
+ }
+
+ /**
+ * DataObject class test. Testing setting date to DataObject with type
+ * double
+ */
+ public void testDoubleSetTypeConversionDate() {
+ DataObject product = createDoubleObject(5);
+ try {
+ product.getDate("doubleVal");
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting boolean to DataObject with type
+ * float
+ */
+ public void testFloatSetTypeConversionBoolean() {
+ DataObject product = createFloatObject(5);
+ try {
+ product.setBoolean("floatVal", true);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting byte to DataObject with type float
+ */
+ public void testFloatSetTypeConversionByte() {
+ DataObject product1 = createFloatObject(5);
+ product1.setByte("floatVal", (byte)6);
+
+ float floatVal = product1.getFloat("floatVal");
+ assertTrue(floatVal == 6);
+ }
+
+ /**
+ * DataObject class test. Testing setting char to DataObject with type float
+ */
+ public void testFloatSetTypeConversionChar() {
+ DataObject product = createFloatObject(5);
+ try {
+ product.setChar("floatVal", 's');
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting double to DataObject with type
+ * float
+ */
+ public void testFloatSetTypeConversionDouble() {
+ DataObject product1 = createFloatObject(5);
+ product1.setDouble("floatVal", (double)6);
+ float floatVal = product1.getFloat("floatVal");
+ assertTrue(floatVal == 6);
+ }
+
+ /**
+ * DataObject class test. Testing setting int to DataObject with type float
+ */
+ public void testFloatSetTypeConversionInt() {
+ DataObject product1 = createFloatObject(5);
+ int value = 6;
+ product1.setInt("floatVal", value);
+ float floatVal = product1.getFloat("floatVal");
+ assertEquals((float)value, floatVal);
+ }
+
+ /**
+ * DataObject class test. Testing setting long to DataObject with type float
+ */
+ public void testFloatSetTypeConversionLong() {
+ DataObject product1 = createFloatObject(5);
+ product1.setLong("floatVal", (long)6);
+
+ float floatVal = product1.getFloat("floatVal");
+ assertTrue(floatVal == 6);
+ }
+
+ /**
+ * DataObject class test. Testing setting short to DataObject with type
+ * float
+ */
+ public void testFloatSetTypeConversionShort() {
+ DataObject product1 = createFloatObject(5);
+ product1.setShort("floatVal", (short)6);
+ float floatVal = product1.getFloat("floatVal");
+ assertTrue(floatVal == 6);
+ }
+
+ /**
+ * DataObject class test. Testing setting byte[] to DataObject with type
+ * float
+ */
+ public void testFloatSetTypeConversionBytes() {
+ DataObject product = createFloatObject(5);
+
+ byte[] byteVal = {10, 100};
+ try {
+ product.setBytes("floatVal", byteVal);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting BigDecimal to DataObject with type
+ * float
+ */
+ public void testFloatSetTypeConversionBigDecimal() {
+ DataObject product = createFloatObject(5.5F);
+ product.setBigDecimal("floatVal", new BigDecimal(6));
+ float floatVal = product.getFloat("floatVal");
+ assertTrue(floatVal == 6);
+ }
+
+ /**
+ * DataObject class test. Testing Setting BigInteger to DataObject with type
+ * float
+ */
+ public void testFloatSetTypeConversionBigInteger() {
+ DataObject product1 = createFloatObject(5);
+ product1.setBigInteger("floatVal", BigInteger.valueOf(6));
+
+ float floatVal = product1.getFloat("floatVal");
+ assertTrue(floatVal == 6);
+ }
+
+ /**
+ * DataObject class test. Testing setting date to DataObject with type float
+ */
+ public void testFloatSetTypeConversionDate() {
+ DataObject product = createFloatObject(5);
+ try {
+ product.setDate("floatVal", new Date());
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting boolean to DataObject with type
+ * int
+ */
+ public void testIntSetTypeConversionBoolean() {
+ DataObject product = createIntObject(5);
+ try {
+ product.setBoolean("intVal", true);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting byte to DataObject with type int
+ */
+ public void testIntSetTypeConversionByte() {
+ DataObject product1 = createIntObject(5);
+ product1.setByte("intVal", (byte)6);
+
+ int intVal = product1.getInt("intVal");
+ assertTrue(intVal == 6);
+ }
+
+ /**
+ * DataObject class test. Testing setting char to DataObject with type int
+ */
+ public void testIntSetTypeConversionChar() {
+ DataObject product = createIntObject(5);
+ try {
+ product.setChar("intVal", 's');
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting double to DataObject with type int
+ */
+ public void testIntSetTypeConversionDouble() {
+ DataObject product = createIntObject(5);
+ double value = (double)6;
+ product.setDouble("intVal", value);
+ int intVal = product.getInt("intVal");
+ assertEquals((int)value, intVal);
+ }
+
+ /**
+ * DataObject class test. Testing setting float to DataObject with type int
+ */
+ public void testIntSetTypeConversionFloat() {
+ DataObject product1 = createIntObject(5);
+ float value = 6.0F;
+ product1.setFloat("intVal", value);
+ int intVal = product1.getInt("intVal");
+ assertEquals((int)value, intVal);
+ }
+
+ /**
+ * DataObject class test. Testing setting long to DataObject with type int
+ */
+ public void testIntSetTypeConversionLong() {
+ DataObject product = createIntObject(5);
+ long value = (long)6789;
+ product.setLong("intVal", value);
+ int intVal = product.getInt("intVal");
+ assertEquals((int)value, intVal);
+ }
+
+ /**
+ * DataObject class test. Testing setting short to DataObject with type int
+ */
+ public void testIntSetTypeConversionShort() {
+ DataObject product1 = createIntObject(5);
+ product1.setShort("intVal", (short)6);
+
+ int intVal = product1.getInt("intVal");
+ assertTrue(intVal == 6);
+ }
+
+ /**
+ * DataObject class test. Testing setting bytes[] to DataObject with type
+ * int
+ */
+ public void testIntSetTypeConversionBytes() {
+ DataObject product = createIntObject(5);
+ byte[] byteVal = {10, 100};
+ try {
+ product.setBytes("intVal", byteVal);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting BigDecimal to DataObject with type
+ * int
+ */
+ public void testIntSetTypeConversionBigDecimal() {
+ DataObject product1 = createIntObject(5);
+ product1.setBigDecimal("intVal", new BigDecimal(6));
+
+ int intVal = product1.getInt("intVal");
+ assertTrue(intVal == 6);
+ }
+
+ /**
+ * DataObject class test. Testing setting BigInteger to DataObject with type
+ * int
+ */
+ public void testIntSetTypeConversionBigInteger() {
+ DataObject product = createIntObject(5);
+ product.setBigInteger("intVal", BigInteger.valueOf(6));
+
+ int intVal = product.getInt("intVal");
+ assertTrue(intVal == 6);
+ }
+
+ /**
+ * DataObject class test. Testing setting date to DataObject with type int
+ */
+ public void testIntSetTypeConversionDate() {
+ DataObject product = createIntObject(5);
+ try {
+ product.setDate("intVal", new Date());
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting boolean to DataObject with type
+ * long
+ */
+ public void testLongSetTypeConversionBoolean() {
+ DataObject product = createLongObject(5);
+ try {
+ product.setBoolean("longVal", true);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting byte to DataObject with type long
+ */
+ public void testLongSetTypeConversionByte() {
+ DataObject product1 = createLongObject(5);
+ product1.setByte("longVal", (byte)6);
+ long longVal = product1.getLong("longVal");
+ assertTrue(longVal == 6);
+ }
+
+ /**
+ * DataObject class test. Testing setting char to DataObject with type long
+ */
+ public void testLongSetTypeConversionChar() {
+ DataObject product = createLongObject(5);
+ try {
+ product.setChar("longVal", 's');
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting double to DataObject with type
+ * long
+ */
+ public void testLongSetTypeConversionDouble() {
+ DataObject product = createLongObject(5);
+ product.setDouble("longVal", (double)6);
+ long longVal = product.getLong("longVal");
+ assertTrue(longVal == 6);
+ }
+
+ /**
+ * DataObject class test. Testing setting float to DataObject with type long
+ */
+ public void testLongSetTypeConversionFloat() {
+ DataObject product1 = createLongObject(5);
+ float value = 6F;
+ product1.setFloat("longVal", value);
+ long longVal = product1.getLong("longVal");
+ assertEquals((long)value, longVal);
+ }
+
+ /**
+ * DataObject class test. Testing setting int to DataObject with type long
+ */
+ public void testLongSetTypeConversionInt() {
+ DataObject product1 = createLongObject(5);
+ product1.setInt("longVal", 6);
+ long longVal = product1.getLong("longVal");
+ assertTrue(longVal == 6);
+
+ }
+
+ /**
+ * DataObject class test. Testing setting short to DataObject with type long
+ */
+ public void testLongSetTypeConversionShort() {
+ DataObject product1 = createLongObject(5);
+ product1.setShort("longVal", (short)6);
+ long longVal = product1.getLong("longVal");
+ assertTrue(longVal == 6);
+ }
+
+ /**
+ * DataObject class test. Testing setting byte[] to DataObject with type
+ * long
+ */
+ public void testLongSetTypeConversionBytes() {
+ DataObject product = createLongObject(5);
+
+ byte[] byteVal = {10, 100};
+ try {
+ product.setBytes("longVal", byteVal);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting BigDecimal to DataObject with type
+ * long
+ */
+ public void testLongSetTypeConversionBigDecimal() {
+ DataObject product = createLongObject(5);
+ product.setBigDecimal("longVal", new BigDecimal(6));
+ long longVal = product.getLong("longVal");
+ assertTrue(longVal == 6);
+ }
+
+ /**
+ * DataObject class test. Testing setting BigInteger to DataObject with type
+ * long
+ */
+ public void testLongSetTypeConversionBigInteger() {
+ DataObject product1 = createLongObject(5);
+ product1.setBigInteger("longVal", BigInteger.valueOf(6));
+ long longVal = product1.getLong("longVal");
+ assertTrue(longVal == 6);
+ }
+
+ /**
+ * DataObject class test. Testing setting date to DataObject with type long
+ */
+ public void testLongSetTypeConversionDate() {
+ Date dateNow = new Date();
+ DataObject product1 = createLongObject(5);
+ product1.setDate("longVal", dateNow);
+
+ long longVal = product1.getLong("longVal");
+ assertTrue(longVal == dateNow.getTime());
+ }
+
+ /**
+ * DataObject class test. Testing setting boolean to DataObject with type
+ * short
+ */
+ public void testShortSetTypeConversionBoolean() {
+ DataObject product = createShortObject((short)5);
+ try {
+ product.setBoolean("shortVal", true);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting byte to DataObject with type short
+ */
+ public void testShortSetTypeConversionByte() {
+ DataObject product1 = createShortObject((short)5);
+ product1.setByte("shortVal", (byte)6);
+ short shortVal = product1.getShort("shortVal");
+ assertTrue(shortVal == 6);
+ }
+
+ /**
+ * DataObject class test. Testing setting char to DataObject with type short
+ */
+ public void testShortSetTypeConversionChar() {
+ DataObject product = createShortObject((short)5);
+ try {
+ product.setChar("shortVal", 's');
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting double to DataObject with type
+ * short
+ */
+ public void testShortSetTypeConversionDouble() {
+ DataObject product = createShortObject((short)5);
+ double value = (double)6;
+ product.setDouble("shortVal", value);
+ short shortVal = product.getShort("shortVal");
+ assertEquals((short)value, shortVal);
+ }
+
+ /**
+ * DataObject class test. Testing getting float from DataObject with type
+ * short
+ */
+ public void testShortSetTypeConversionFloat() {
+ DataObject product = createShortObject((short)5);
+ float value = 6F;
+ product.setFloat("shortVal", value);
+ short shortVal = product.getShort("shortVal");
+ assertEquals((short)value, shortVal);
+ }
+
+ /**
+ * DataObject class test. Testing setting int to DataObject with type short
+ */
+ public void testShortSetTypeConversionInt() {
+ DataObject product = createShortObject((short)5);
+ int value = 123456;
+ product.setInt("shortVal", value);
+ short shortVal = product.getShort("shortVal");
+ assertEquals((short)value, shortVal);
+ }
+
+ /**
+ * DataObject class test. Testing setting long to DataObject with type short
+ */
+ public void testShortSetTypeConversionLong() {
+ DataObject product = createShortObject((short)5);
+ long value = (long)6;
+ product.setLong("shortVal", value);
+ short shortVal = product.getShort("shortVal");
+ assertEquals((short)value, shortVal);
+ }
+
+
+ /**
+ * DataObject class test. Testing setting bytes[] to DataObject with type
+ * short
+ */
+ public void testShortSetTypeConversionBytes() {
+ DataObject product = createShortObject((short)5);
+ byte[] byteVal = {10, 100};
+ try {
+ product.setBytes("shortVal", byteVal);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * DataObject class test. Testing setting BigDecimal to DataObject with type
+ * short
+ */
+ public void testShortSetTypeConversionBigDecimal() {
+ short value = 5;
+ BigDecimal newValue = new BigDecimal(6);
+ DataObject product = createShortObject(value);
+ product.setBigDecimal("shortVal", newValue);
+ assertEquals( newValue, product.getBigDecimal("shortVal") );
+ }
+
+ /**
+ * DataObject class test. Testing setting BigInteger to DataObject with type
+ * short
+ */
+ public void testShortSetTypeConversionBigInteger() {
+ short value = 5;
+ BigInteger newValue = BigInteger.valueOf(6);
+ DataObject product = createShortObject(value);
+ product.setBigInteger("shortVal", newValue);
+ assertEquals( newValue, product.getBigInteger("shortVal") );
+ }
+
+ /**
+ * DataObject class test. Testing setting date to DataObject with type short
+ */
+ public void testShortSetTypeConversionDate() {
+ DataObject product = createShortObject((short)5);
+ try {
+ product.setDate("shortVal", new Date());
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+ }
+
+
+ /**
+ * DataObject class test. Testing setting boolean to DataObject with type
+ * byte[]
+ */
+ public void testBytesSetTypeConversionBoolean() {
+ byte[] byteVal = {10, 100};
+ DataObject product = createBytesObject(byteVal);
+ try {
+ product.setBoolean("bytesVal", true);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+ }
+
+ /**
+ * DataObject class test. Testing setting byte to DataObject with type
+ * byte[]
+ */
+ public void testBytesSetTypeConversionByte() {
+ byte[] byteVal = {10, 100};
+ DataObject product = createBytesObject(byteVal);
+ try {
+ product.setByte("bytesVal", (byte)5);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+ }
+
+ /**
+ * DataObject class test. Testing setting char to DataObject with type
+ * byte[]
+ */
+ public void testBytesSetTypeConversionChar() {
+ byte[] byteVal = {10, 100};
+ DataObject product = createBytesObject(byteVal);
+ try {
+ product.setChar("bytesVal", 's');
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+ }
+
+ /**
+ * DataObject class test. Testing setting double to DataObject with type
+ * byte[]
+ */
+ public void testBytesSetTypeConversionDouble() {
+ byte[] byteVal = {10, 100};
+ DataObject product = createBytesObject(byteVal);
+ try {
+ product.setDouble("bytesVal", 5);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+ }
+
+ /**
+ * DataObject class test. Testing setting float to DataObject with type
+ * byte[]
+ */
+ public void testBytesSetTypeConversionFloat() {
+ byte[] byteVal = {10, 100};
+ DataObject product = createBytesObject(byteVal);
+ try {
+ product.setFloat("bytesVal", 5.5F);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+ }
+
+ /**
+ * DataObject class test. Testing setting int to DataObject with type byte[]
+ */
+ public void testBytesSetTypeConversionInt() {
+ byte[] byteVal = {10, 100};
+ DataObject product = createBytesObject(byteVal);
+ try {
+ product.setInt("bytesVal", 5);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+ }
+
+ /**
+ * DataObject class test. Testing setting long to DataObject with type
+ * byte[]
+ */
+ public void testBytesSetTypeConversionLong() {
+ byte[] byteVal = {10, 100};
+ DataObject product = createBytesObject(byteVal);
+ try {
+ product.setLong("bytesVal", (long)5);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+ }
+
+ /**
+ * DataObject class test. Testing setting short to DataObject with type
+ * byte[]
+ */
+ public void testBytesSetTypeConversionShort() {
+ byte[] byteVal = {10, 100};
+ DataObject product = createBytesObject(byteVal);
+ try {
+ product.setShort("bytesVal", (short)5);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+ }
+
+ /**
+ * DataObject class test. Testing setting BigDecimal to DataObject with type
+ * byte[]
+ */
+ public void testBytesSetTypeConversionBigDecimal() {
+ byte[] byteVal = {10, 100};
+ DataObject product = createBytesObject(byteVal);
+ try {
+ product.setBigDecimal("bytesVal", 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 testBytesSetTypeConversionBigInteger() {
+ byte[] byteArray1 = {1, 2};
+ byte[] byteArray2 = {10, 100};
+
+ DataObject product = createBytesObject(byteArray1);
+
+ BigInteger value = new BigInteger(byteArray2);
+ product.setBigInteger("bytesVal", value);
+
+ byte[] bytesRes = product.getBytes("bytesVal");
+ assertNotNull(bytesRes);
+
+ assertEquals(2, bytesRes.length);
+ assertEquals(10, bytesRes[0]);
+ assertEquals(100, bytesRes[1]);
+ }
+
+ /**
+ * DataObject class test. Testing setting date to DataObject with type
+ * byte[]
+ */
+ public void testBytesSetTypeConversionDate() {
+ byte[] byteVal = {10, 100};
+ DataObject product = createBytesObject(byteVal);
+ try {
+ product.setDate("bytesVal", new Date());
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+ }
+
+ /**
+ * DataObject class test. Testing setting boolean to DataObject with type
+ * BigDecimal
+ */
+ public void testBigDecimalSetTypeConversionBoolean() {
+ DataObject product = createBigDecimalObject(new BigDecimal(4));
+ try {
+ product.setBoolean("bigDecimalVal", true);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+ }
+
+ /**
+ * DataObject class test. Testing setting byte to DataObject with type
+ * BigDecimal
+ */
+ public void testBigDecimalSetTypeConversionByte() {
+ byte byteValue = 12;
+ BigDecimal value = BigDecimal.valueOf(4);
+ DataObject product = createBigDecimalObject(value);
+ product.setByte("bigDecimalVal", byteValue );
+ assertEquals( byteValue, product.getByte("bigDecimalVal") );
+ }
+
+ /**
+ * DataObject class test. Testing setting char to DataObject with type
+ * BigDecimal
+ */
+ public void testBigDecimalSetTypeConversionChar() {
+ DataObject product = createBigDecimalObject(new BigDecimal(4));
+ try {
+ product.setChar("bigDecimalVal", 's');
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+ }
+
+ /**
+ * DataObject class test. Testing setting double to DataObject with type
+ * BigDecimal
+ */
+ public void testBigDecimalSetTypeConversionDouble() {
+ DataObject product = createBigDecimalObject(new BigDecimal(4));
+ product.setDouble("bigDecimalVal", 5);
+ BigDecimal bdVal = product.getBigDecimal("bigDecimalVal");
+ assertTrue(bdVal.intValue() == 5);
+ }
+
+ /**
+ * DataObject class test. Testing setting float to DataObject with type
+ * BigDecimal
+ */
+ public void testBigDecimalSetTypeConversionFloat() {
+ DataObject product = createBigDecimalObject(new BigDecimal(4));
+ product.setFloat("bigDecimalVal", 5F);
+ BigDecimal bdVal = product.getBigDecimal("bigDecimalVal");
+ assertTrue(bdVal.intValue() == 5);
+ }
+
+ /**
+ * DataObject class test. Testing setting int to DataObject with type
+ * BigDecimal
+ */
+ public void testBigDecimalSetTypeConversionInt() {
+ DataObject product = createBigDecimalObject(new BigDecimal(4));
+ product.setInt("bigDecimalVal", 5);
+ BigDecimal bdVal = product.getBigDecimal("bigDecimalVal");
+ assertTrue(bdVal.intValue() == 5);
+ }
+
+ /**
+ * DataObject class test. Testing setting long to DataObject with type
+ * BigDecimal
+ */
+ public void testBigDecimalSetTypeConversionLong() {
+ DataObject product = createBigDecimalObject(new BigDecimal(4));
+ product.setLong("bigDecimalVal", (long)5);
+
+ BigDecimal bdVal = product.getBigDecimal("bigDecimalVal");
+ assertTrue(bdVal.intValue() == 5);
+ }
+
+ /**
+ * DataObject class test. Testing setting short to DataObject with type
+ * BigDecimal
+ */
+ public void testBigDecimalSetTypeConversionShort() {
+ BigDecimal value = new BigDecimal(4);
+ short newValue = (short) 5;
+ DataObject product = createBigDecimalObject(value);
+ product.setShort("bigDecimalVal", newValue);
+ assertEquals( newValue, product.getShort("bigDecimalVal") );
+ }
+
+ /**
+ * DataObject class test. Testing setting byte[] to DataObject with type
+ * BigDecimal
+ */
+ public void testBigDecimalSetTypeConversionBytes() {
+ DataObject product = createBigDecimalObject(new BigDecimal(4));
+
+ byte[] byteVal = {10, 100};
+ try {
+ product.setBytes("bigDecimalVal", byteVal);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+ }
+
+ /**
+ * DataObject class test. Testing setting BigInteger to DataObject with type
+ * BigDecimal
+ */
+ public void testBigDecimalSetTypeConversionBigInteger() {
+ DataObject product = createBigDecimalObject(new BigDecimal(4));
+ product.setBigInteger("bigDecimalVal", BigInteger.valueOf(5));
+
+ BigDecimal bdVal = product.getBigDecimal("bigDecimalVal");
+ assertTrue(bdVal.intValue() == 5);
+ }
+
+ /**
+ * DataObject class test. Testing setting date to DataObject with type
+ * BigDecimal
+ */
+ public void testBigDecimalSetTypeConversionDate() {
+ DataObject product = createBigDecimalObject(new BigDecimal(4));
+ try {
+ product.setDate("bigDecimalVal", new Date());
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+ }
+
+ /**
+ * DataObject class test. Testing setting boolean to DataObject with type
+ * BigInteger
+ */
+ public void testBigIntegerSetTypeConversionBoolean() {
+ DataObject product = createBigIntegerObject(BigInteger.valueOf(4));
+ try {
+ product.setBoolean("bigIntegerVal", true);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+ }
+
+ /**
+ * DataObject class test. Testing setting byte to DataObject with type
+ * BigInteger
+ */
+ public void testBigIntegerSetTypeConversionByte() {
+ byte byteValue = 12;
+ BigInteger value = BigInteger.valueOf(4);
+ DataObject product = createBigIntegerObject(value);
+ product.setByte("bigIntegerVal", byteValue );
+ assertEquals( byteValue, product.getByte("bigIntegerVal") );
+ }
+
+ /**
+ * DataObject class test. Testing setting char to DataObject with type
+ * BigInteger
+ */
+ public void testBigIntegerSetTypeConversionChar() {
+ DataObject product = createBigIntegerObject(BigInteger.valueOf(4));
+ try {
+ product.setChar("bigIntegerVal", 's');
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+ }
+
+ /**
+ * DataObject class test. Testing setting double to DataObject with type
+ * BigInteger
+ */
+ public void testBigIntegerSetTypeConversionDouble() {
+ DataObject product = createBigIntegerObject(BigInteger.valueOf(4));
+ product.setDouble("bigIntegerVal", 5);
+ BigInteger biVal = product.getBigInteger("bigIntegerVal");
+ assertTrue(biVal.intValue() == 5);
+ }
+
+ /**
+ * DataObject class test. Testing setting float to DataObject with type
+ * BigInteger
+ */
+ public void testBigIntegerSetTypeConversionFloat() {
+ DataObject product = createBigIntegerObject(BigInteger.valueOf(4));
+
+ product.setFloat("bigIntegerVal", 5F);
+ BigInteger biVal = product.getBigInteger("bigIntegerVal");
+ assertTrue(biVal.intValue() == 5);
+ }
+
+ /**
+ * DataObject class test. Testing setting int to DataObject with type
+ * BigInteger
+ */
+ public void testBigIntegerSetTypeConversionInt() {
+ DataObject product = createBigIntegerObject(BigInteger.valueOf(4));
+
+ product.setInt("bigIntegerVal", 5);
+ BigInteger biVal = product.getBigInteger("bigIntegerVal");
+ assertTrue(biVal.intValue() == 5);
+ }
+
+ /**
+ * DataObject class test. Testing setting long to DataObject with type
+ * BigInteger
+ */
+ public void testBigIntegerSetTypeConversionLong() {
+ DataObject product = createBigIntegerObject(BigInteger.valueOf(4));
+
+ product.setLong("bigIntegerVal", 5);
+ BigInteger biVal = product.getBigInteger("bigIntegerVal");
+ assertTrue(biVal.intValue() == 5);
+ }
+
+ /**
+ * DataObject class test. Testing setting short to DataObject with type
+ * BigInteger
+ */
+ public void testBigIntegerSetTypeConversionShort() {
+ BigInteger value = BigInteger.valueOf(4);
+ short newValue = (short) 5;
+ DataObject product = createBigIntegerObject(value);
+ product.setShort("bigIntegerVal", newValue);
+ assertEquals( newValue, product.getShort("bigIntegerVal") );
+ }
+
+ /**
+ * DataObject class test. Testing setting byte[] to DataObject with type
+ * BigInteger
+ */
+ public void testBigIntegerSetTypeConversionBytes() {
+ DataObject product = createBigIntegerObject(BigInteger.valueOf(4));
+
+ byte[] byteVal = {10, 100};
+ product.setBytes("bigIntegerVal", byteVal);
+
+ BigInteger biVal = product.getBigInteger("bigIntegerVal");
+
+ byte[] bytesRes = biVal.toByteArray();
+ assertNotNull(bytesRes);
+
+ assertEquals(2, bytesRes.length);
+ assertEquals(10, bytesRes[0]);
+ assertEquals(100, bytesRes[1]);
+ }
+
+ /**
+ * DataObject class test. Testing setting BigDecimal to DataObject with type
+ * BigInteger
+ */
+ public void testBigIntegerSetTypeConversionBigDecimal() {
+ DataObject product = createBigIntegerObject(BigInteger.valueOf(4));
+
+ product.setBigDecimal("bigIntegerVal", new BigDecimal(5));
+ BigInteger biVal = product.getBigInteger("bigIntegerVal");
+ assertTrue(biVal.intValue() == 5);
+ }
+
+ /**
+ * DataObject class test. Testing setting date to DataObject with type
+ * BigInteger
+ */
+ public void testBigIntegerSetTypeConversionDate() {
+ DataObject product = createBigIntegerObject(BigInteger.valueOf(4));
+ try {
+ product.setDate("bigIntegerVal", new Date());
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+ }
+
+ /**
+ * DataObject class test. Testing setting boolean to DataObject with type
+ * date
+ */
+ public void testDateSetTypeConversionBoolean() {
+ DataObject product = createDateObject(new Date());
+ try {
+ product.setBoolean("dateVal", true);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+ }
+
+ /**
+ * DataObject class test. Testing setting byte to DataObject with type date
+ */
+ public void testDateSetTypeConversionByte() {
+ DataObject product = createDateObject(new Date());
+ try {
+ product.setByte("dateVal", (byte)5);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+ }
+
+ /**
+ * DataObject class test. Testing setting char to DataObject with type date
+ */
+ public void testDateSetTypeConversionChar() {
+ DataObject product = createDateObject(new Date());
+ try {
+ product.setChar("dateVal", 's');
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+ }
+
+ /**
+ * DataObject class test. Testing setting double to DataObject with type
+ * date
+ */
+ public void testDateSetTypeConversionDouble() {
+ DataObject product = createDateObject(new Date());
+ try {
+ product.setDouble("dateVal", 5);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+ }
+
+ /**
+ * DataObject class test. Testing setting float to DataObject with type date
+ */
+ public void testDateSetTypeConversionFloat() {
+ DataObject product = createDateObject(new Date());
+ try {
+ product.setFloat("dateVal", 5F);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+ }
+
+ /**
+ * DataObject class test. Testing setting int to DataObject with type date
+ */
+ public void testDateSetTypeConversionInt() {
+ DataObject product = createDateObject(new Date());
+ try {
+ product.setInt("dateVal", 5);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+ }
+
+ /**
+ * DataObject class test. Testing setting long to DataObject with type date
+ */
+ public void testDateSetTypeConversionLong() {
+ Date dateNow = new Date();
+ DataObject product = createDateObject(dateNow);
+
+ product.setLong("dateVal", dateNow.getTime());
+ Date dateRes = product.getDate("dateVal");
+ assertEquals(dateNow.getTime(), dateRes.getTime());
+ }
+
+ /**
+ * DataObject class test. Testing setting short to DataObject with type date
+ */
+ public void testDateSetTypeConversionShort() {
+ DataObject product = createDateObject(new Date());
+ try {
+ product.setShort("dateVal", (short)5);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+ }
+
+ /**
+ * DataObject class test. Testing setting byte[] to DataObject with type
+ * date
+ */
+ public void testDateSetTypeConversionBytes() {
+ DataObject product = createDateObject(new Date());
+
+ byte[] byteVal = {10, 100};
+ try {
+ product.setBytes("dateVal", byteVal);
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+ }
+
+ /**
+ * DataObject class test. Testing setting BigDecimal to DataObject with type
+ * date
+ */
+ public void testDateSetTypeConversionBigDecimal() {
+ DataObject product = createDateObject(new Date());
+ try {
+ product.setBigDecimal("dateVal", new BigDecimal(5));
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+ }
+
+ /**
+ * DataObject class test. Testing setting BigInteger to DataObject with type
+ * date
+ */
+ public void testDateSetTypeConversionBigInteger() {
+ DataObject product = createDateObject(new Date());
+ try {
+ product.setBigInteger("dateVal", BigInteger.valueOf(5));
+ fail(EXPECTED_CLASS_CAST_EXCEPTION);
+ } catch (ClassCastException e) {
+ // expected
+ }
+ }
+}
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/TypeConversionTest2.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/TypeConversionTest2.java
new file mode 100644
index 0000000000..01479cc351
--- /dev/null
+++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/TypeConversionTest2.java
@@ -0,0 +1,1301 @@
+/*
+ * 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.
+ *
+ * $Rev$ $Date$
+ */
+package test.sdo21.tests.conversion;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.lang.reflect.Method;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.text.SimpleDateFormat;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.List;
+import java.util.TimeZone;
+
+import org.junit.After;
+import org.junit.Before;
+
+import test.sdo21.framework.CTSTestCase;
+import test.sdo21.tests.TestData.StandardDynamicFactory;
+import test.sdo21.tests.TestData.StandardFactory;
+import test.sdo21.tests.TestData.TestDataFactory;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Type;
+
+/**
+ * FIXME there appears to be overlap between this class and {@link TypeConversionTest}
+ *
+ */
+public class TypeConversionTest2 extends CTSTestCase {
+ private DataObject testDO;
+ TestDataFactory factory;
+
+ public TypeConversionTest2() {
+ factory = createFactory();
+ }
+
+ protected TestDataFactory createFactory() {
+ return new StandardDynamicFactory();
+ }
+
+ @Before
+ public void setUp () throws Exception {
+ super.setUp();
+ factory.defineMetaData(getScope());
+ testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE);
+
+ COMPARE_ANY = new GeneralComparator();
+ API_TEST_TYPE = testDO.getType();
+
+ List properties = API_TEST_TYPE.getProperties();
+ Property property;
+ String name;
+
+ for (int i = 0; i < properties.size(); i++) {
+ property = (Property)properties.get(i);
+ name = property.getName();
+
+ if (name.equals("booleanVal")) {
+ BOOLEAN_VAL_INDEX = i;
+ BOOLEAN_VAL_PROP = property;
+ } else if (name.equals("stringVal")) {
+ STRING_VAL_INDEX = i;
+ STRING_VAL_PROP = property;
+ } else if (name.equals("byteVal")) {
+ BYTE_VAL_INDEX = i;
+ BYTE_VAL_PROP = property;
+ } else if (name.equals("decimalVal")) {
+ DECIMAL_VAL_INDEX = i;
+ DECIMAL_VAL_PROP = property;
+ } else if (name.equals("intVal")) {
+ INT_VAL_INDEX = i;
+ INT_VAL_PROP = property;
+ } else if (name.equals("floatVal")) {
+ FLOAT_VAL_INDEX = i;
+ FLOAT_VAL_PROP = property;
+ } else if (name.equals("doubleVal")) {
+ DOUBLE_VAL_INDEX = i;
+ DOUBLE_VAL_PROP = property;
+ } else if (name.equals("dateVal")) {
+ DATE_VAL_INDEX = i;
+ DATE_VAL_PROP = property;
+ } else if (name.equals("shortVal")) {
+ SHORT_VAL_INDEX = i;
+ SHORT_VAL_PROP = property;
+ } else if (name.equals("longVal")) {
+ LONG_VAL_INDEX = i;
+ LONG_VAL_PROP = property;
+ } else if (name.equals("bytesVal")) {
+ BYTES_VAL_INDEX = i;
+ BYTES_VAL_PROP = property;
+ } else if (name.equals("integerVal")) {
+ INTEGER_VAL_INDEX = i;
+ INTEGER_VAL_PROP = property;
+ } else if (name.equals("charVal")) {
+ CHAR_VAL_INDEX = i;
+ CHAR_VAL_PROP = property;
+ }
+ }
+ }
+
+
+ @After
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ // The following constants describe the index for the fields in
+ // api_test.xsd.
+
+ private static int STRING_VAL_INDEX;
+
+ private static int BOOLEAN_VAL_INDEX;
+
+ private static int BYTE_VAL_INDEX;
+
+ private static int DECIMAL_VAL_INDEX;
+
+ private static int INT_VAL_INDEX;
+
+ private static int FLOAT_VAL_INDEX;
+
+ private static int DOUBLE_VAL_INDEX;
+
+ private static int DATE_VAL_INDEX;
+
+ private static int SHORT_VAL_INDEX;
+
+ private static int LONG_VAL_INDEX;
+
+ private static int BYTES_VAL_INDEX;
+
+ private static int INTEGER_VAL_INDEX;
+
+ private static int CHAR_VAL_INDEX;
+
+ // TODO: these properties are not used . . . should they be ?
+ private static Property STRING_VAL_PROP;
+
+ private static Property BOOLEAN_VAL_PROP;
+
+ private static Property BYTE_VAL_PROP;
+
+ private static Property DECIMAL_VAL_PROP;
+
+ private static Property INT_VAL_PROP;
+
+ private static Property FLOAT_VAL_PROP;
+
+ private static Property DOUBLE_VAL_PROP;
+
+ private static Property DATE_VAL_PROP;
+
+ private static Property SHORT_VAL_PROP;
+
+ private static Property LONG_VAL_PROP;
+
+ private static Property BYTES_VAL_PROP;
+
+ private static Property INTEGER_VAL_PROP;
+
+ private static Property CHAR_VAL_PROP;
+
+ // The following variables are Method arrays. Each array refers to a
+ // specific get<Type>, but within
+ // the array exist the get<Type>(index), get<Type>(property), and
+ // get<Type>(path). Rather than
+ // referring to each of the three in every circumstance, the more compact
+ // array appears.
+
+ private static ConversionType TO_BOOLEAN = new ConversionType("getBoolean");
+
+ private static ConversionType TO_BYTE = new ConversionType("getByte");
+
+ private static ConversionType TO_CHAR = new ConversionType("getChar");
+
+ private static ConversionType TO_DOUBLE = new ConversionType("getDouble");
+
+ private static ConversionType TO_FLOAT = new ConversionType("getFloat");
+
+ private static ConversionType TO_INT = new ConversionType("getInt");
+
+ private static ConversionType TO_LONG = new ConversionType("getLong");
+
+ private static ConversionType TO_SHORT = new ConversionType("getShort");
+
+ private static ConversionType TO_BYTES = new ConversionType("getBytes");
+
+ private static ConversionType TO_BIGDECIMAL = new ConversionType("getBigDecimal");
+
+ private static ConversionType TO_BIGINTEGER = new ConversionType("getBigInteger");
+
+ private static ConversionType TO_DATAOBJECT = new ConversionType("getDataObject");
+
+ private static ConversionType TO_DATE = new ConversionType("getDate");
+
+ private static ConversionType TO_STRING = new ConversionType("getString");
+
+ private static ConversionType TO_LIST = new ConversionType("getList");
+
+ private static ConversionType TO_SEQUENCE = new ConversionType("getSequence");
+
+ private static GeneralComparator COMPARE_ANY;
+
+ // There will be several instances where a Property must be passed as a
+ // parameter. Have available the Type
+ // to call getProperty() as needed.
+
+ private static Type API_TEST_TYPE;
+
+
+ private static class ConversionType {
+ // The following constants are used because the getMethod function
+ // requires an Class
+ // array describing the parameters to the functions.
+
+ private static final Class[] INT_CLASS_ARRAY = {int.class};
+
+ private static final Class[] PROPERTY_CLASS_ARRAY = {Property.class};
+
+ private static final Class[] STRING_CLASS_ARRAY = {String.class};
+
+ Method index_method;
+
+ Method property_method;
+
+ Method path_method;
+
+ public ConversionType(String method_name) {
+ try {
+ this.index_method = DataObject.class.getMethod(method_name, INT_CLASS_ARRAY);
+ this.property_method = DataObject.class.getMethod(method_name, PROPERTY_CLASS_ARRAY);
+ this.path_method = DataObject.class.getMethod(method_name, STRING_CLASS_ARRAY);
+ } catch (NoSuchMethodException e) {
+ this.index_method = null;
+ this.property_method = null;
+ this.path_method = null;
+ }
+ }
+
+ public Method getIndexMethod() {
+ return this.index_method;
+ }
+
+ public Method getPropertyMethod() {
+ return this.property_method;
+ }
+
+ public Method getPathMethod() {
+ return this.path_method;
+ }
+ }
+
+ // Each instance of Test describes a convert-from type. The index, property
+ // and path parms
+ // will refer to the same field, which is a field of the convert-from type.
+
+ private static class Test {
+ Object[] index_parm;
+
+ Object[] property_parm;
+
+ Object[] path_parm;
+
+ Object expected_value;
+
+ String from_type;
+
+ // The constructor prepares a test DataObject and determines how to
+ // access the field
+ // in three different ways - index, property, and path.
+
+ Test(String path, int index) {
+ this.index_parm = new Object[] {new Integer(index)};
+ this.property_parm = new Object[] {API_TEST_TYPE.getProperty(path)};
+ this.path_parm = new Object[] {path};
+ this.expected_value = null;
+ }
+
+ /**
+ * initialize() is a private method that establishes the initial value
+ * of the test field.
+ *
+ * @return
+ */
+
+ private void initialize(Class type, String type_name, Object initial_value, DataObject testDO) {
+ try {
+ Class[] classArray = {int.class, type};
+ Object[] initValueArray = new Object[] {this.index_parm[0], initial_value};
+
+ Method setter = DataObject.class.getMethod("set" + type_name, classArray);
+ setter.invoke(testDO, initValueArray);
+
+ this.expected_value = initial_value;
+ this.from_type = type_name;
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Exception using reflection to establish initial value for test : " + e.toString());
+ }
+ }
+
+ /**
+ * checkConversionException verifies that for a particular to and from
+ * Type pairing, the expected Exceptoin is thrown.
+ *
+ * @param to_type
+ * @param expected_exception
+ * @param testDO
+ */
+
+ private void checkConversionException(ConversionType to_type, Class expected_exception, DataObject testDO) {
+ try {
+ boolean index_err, path_err, property_err;
+
+ index_err = executeExceptionCase(to_type.getIndexMethod(), this.index_parm, expected_exception, testDO);
+ path_err = executeExceptionCase(to_type.getPathMethod(), this.path_parm, expected_exception, testDO);
+ property_err =
+ executeExceptionCase(to_type.getPropertyMethod(), this.property_parm, expected_exception, testDO);
+
+ assertEquals("Testing that expected exception for index paramater is equal to path paramater exception ",
+ index_err,
+ path_err);
+ assertEquals("Testing that expected exception for path paramater is equal to property paramater exception ",
+ property_err,
+ path_err);
+
+ // TODO: test case needs reworking
+ /*
+ * else if (index_err == false) attemptConversion(to_type,
+ * testDO);
+ */
+ if (!index_err) {
+ attemptConversion(to_type, testDO);
+ }
+
+ // TODO: test for unexpected consistency
+ /*
+ * if (consistency_err) throw new ExpectedConditionError("An
+ * exception inconsistency exists for " +
+ * to_type.getPathMethod().getName() + " when called " + "for a " +
+ * this.from_type + " property.");
+ */
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("exception caught : " + e.toString());
+ }
+ }
+
+ /**
+ * attemptConversion is a private method that attempts the conversion to
+ * the specified type, using DataObject.get____(). The get___() function
+ * can be called with an index, path, and property. attemptConversion()
+ * calls each of those three.
+ *
+ * @param to_type
+ * @param testDO
+ */
+
+ private void attemptConversion(ConversionType to_type, DataObject testDO) {
+
+ try {
+ performConversion(to_type.getIndexMethod(), this.index_parm, testDO);
+ performConversion(to_type.getPathMethod(), this.path_parm, testDO);
+ performConversion(to_type.getPropertyMethod(), this.property_parm, testDO);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Exception caught invoking attemptConversion for " + to_type + " : " + e.toString());
+ }
+ }
+
+ /**
+ * performConversion is a private method that is called by
+ * attemptConversion for each of the Property identification mechanisms.
+ * (Property, index, or name.)
+ *
+ * @param convert
+ * @param parm
+ * @param testDO
+ */
+
+ private void performConversion(Method convert, Object[] parm, DataObject testDO) throws Exception {
+
+ assertEquals("Conversion did not yield expected value for " + convert.getName()
+ + " on a "
+ + this.from_type
+ + " property.", COMPARE_ANY.compare(convert.invoke(testDO, parm), this.expected_value), 0);
+ }
+
+ /**
+ * executeExceptionCase is a private method that insures a particular to
+ * and from Type pairing will throw the expected Exception when an a
+ * conversion is attempted using get____(<x>). executeExceptionCase is
+ * called by checkConversionException for each mechanism of identifying
+ * the Property. (Property, name, or index.)
+ *
+ * @param convert
+ * @param parm
+ * @param expected_exception
+ * @param testDO
+ * @return whether or not the expected exception was thrown and caught
+ */
+ private boolean executeExceptionCase(Method convert, Object[] parm, Class expected_exception, DataObject testDO) {
+ boolean exception_thrown = false;
+ try {
+ convert.invoke(testDO, parm);
+ } catch (Exception e) {
+
+ exception_thrown = true;
+ Throwable cause = e.getCause();
+ if (cause == null) {
+ assertEquals("An unexpected exception occurred while performing " + convert.getName()
+ + " on a "
+ + this.from_type
+ + " property.", expected_exception, e.getClass());
+ } else {
+ assertEquals("An unexpected exception occurred while performing " + convert.getName()
+ + " on a "
+ + this.from_type
+ + " property.", expected_exception, cause.getClass());
+ }
+ }
+
+ return exception_thrown;
+ }
+ }
+
+ private static class GeneralComparator implements Comparator {
+ /**
+ * The compare method fo the GeneralComparator class is used to compare
+ * two of any Types between which a covnersion is permitted in SDO.
+ */
+
+ public int compare(Object obj1, Object obj2) {
+ if (obj1.getClass() == obj2.getClass()) {
+ if (obj1.equals(obj2))
+ return 0;
+ else
+ return 1;
+ }
+
+ else if (obj1.getClass() == Date.class) {
+ if (obj2.getClass() == String.class) {
+ try {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy'-'MM'-'dd'T'H':'mm':'ss.S");
+
+ sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
+ obj2 = sdf.parse((String)obj2);
+
+ if (obj1.equals(obj2))
+ return 0;
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ }
+
+ return 1;
+ }
+
+ else {
+ Date temp = (Date)obj1;
+
+ return compare(new Long(temp.getTime()), obj2);
+ }
+
+ }
+
+ else if (obj2.getClass() == Date.class) {
+ return compare(obj2, obj1);
+ }
+
+ else if (obj1.getClass() == Boolean.class) {
+ Boolean temp = (Boolean)obj1;
+
+ if (temp.booleanValue()) {
+ if (obj2.toString().equalsIgnoreCase("true"))
+ return 0;
+ else
+ return 1;
+ }
+
+ else {
+ if (obj2.toString().equalsIgnoreCase("true"))
+ return 1;
+ else
+ return 0;
+ }
+ }
+
+ else if (obj2.getClass() == Boolean.class)
+ return compare(obj2, obj1);
+
+ else if (obj1.getClass() == Byte.class || obj2.getClass() == Byte.class) {
+ byte b1 = (Double.valueOf(obj1.toString())).byteValue();
+ byte b2 = (Double.valueOf(obj2.toString())).byteValue();
+
+ if (b1 == b2)
+ return 0;
+ else if (b1 < b2)
+ return -1;
+ else
+ return 1;
+ }
+
+ else if (obj1.getClass().toString().charAt(6) == '[') {
+ long result = 0;
+ long multiplier = 1;
+
+ byte[] array = (byte[])obj1;
+ for (int i = 0; i < array.length; i++) {
+ result += array[array.length - i - 1] * multiplier;
+ multiplier *= 256;
+ }
+
+ return compare(obj2, new Long(result));
+ }
+
+ else if (obj2.getClass().toString().charAt(6) == '[') {
+ return compare(obj2, obj1);
+ }
+
+ else if (obj1.getClass() == Short.class || obj2.getClass() == Short.class) {
+ short s1 = (Double.valueOf(obj1.toString())).shortValue();
+ short s2 = (Double.valueOf(obj2.toString())).shortValue();
+
+ if (s1 == s2)
+ return 0;
+ else if (s1 < s2)
+ return -1;
+ else
+ return 1;
+ }
+
+ else if (obj1.getClass() == Integer.class || obj2.getClass() == Integer.class) {
+ int i1 = (Double.valueOf(obj1.toString())).intValue();
+ int i2 = (Double.valueOf(obj2.toString())).intValue();
+
+ if (i1 == i2)
+ return 0;
+ else if (i1 < i2)
+ return -1;
+ else
+ return 1;
+ }
+
+ else if (obj1.getClass() == Long.class || obj2.getClass() == Long.class
+ || obj1.getClass() == BigInteger.class
+ || obj2.getClass() == BigInteger.class) {
+ long l1 = (Double.valueOf(obj1.toString())).longValue();
+ long l2 = (Double.valueOf(obj2.toString())).longValue();
+
+ if (l1 == l2)
+ return 0;
+ else if (l1 < l2)
+ return -1;
+ else
+ return 1;
+ }
+
+ else if (obj1.getClass() == Float.class || obj2.getClass() == Float.class) {
+ float f1 = (Double.valueOf(obj1.toString())).floatValue();
+ float f2 = (Double.valueOf(obj2.toString())).floatValue();
+
+ if (f1 == f2)
+ return 0;
+ else if (f1 < f2)
+ return -1;
+ else
+ return 1;
+ }
+
+ else if (obj1.getClass() == Double.class || obj2.getClass() == Double.class) {
+ Double b1 = Double.valueOf(obj1.toString());
+ Double b2 = Double.valueOf(obj2.toString());
+
+ return b1.compareTo(b2);
+ }
+
+ else if (obj1.getClass() == BigDecimal.class || obj2.getClass() == BigDecimal.class) {
+ BigDecimal b1 = new BigDecimal(obj1.toString());
+ BigDecimal b2 = new BigDecimal(obj2.toString());
+
+ return b1.compareTo(b2);
+ }
+
+ else {
+ if (obj1.toString().equals(obj2.toString()))
+ return 0;
+ else
+ return 1;
+ }
+ }
+
+ }
+
+ /**
+ * TODO: Uncomment below as appropriate when TUSCANY-581 is resolved. In the
+ * following test cases, several instances are commented out. For these
+ * cases, the test case currently fails. A JIRA issue (TUSCANY-581) has been
+ * opened to either correct the behavior (then uncomment the lines) or to
+ * alter the specification against which the test cases were designed (and
+ * then remove the lines - assuming the alteration is to remove stating the
+ * nature of the exception).
+ */
+
+ /**
+ * testBooleanConversion verifies the conversion from boolean to each of the
+ * allowed types.
+ */
+ @org.junit.Test
+ public void testBooleanConversion() {
+ Test FromBoolean = new Test("booleanVal", BOOLEAN_VAL_INDEX);
+
+ FromBoolean.initialize(boolean.class, "Boolean", Boolean.valueOf(true), testDO);
+
+ try {
+ FromBoolean.attemptConversion(TO_BOOLEAN, testDO);
+ FromBoolean.attemptConversion(TO_STRING, testDO);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Unexpected exception " + e.toString());
+
+ }
+ }
+
+ /**
+ * testBooleanExceptions verifies that the appropriate Exceptions are thrown
+ * when an unpermitted conversion from boolean is attempted.
+ */
+ @org.junit.Test
+ public void testBooleanExceptions() {
+ try {
+ Test FromBoolean = new Test("booleanVal", BOOLEAN_VAL_INDEX);
+
+ FromBoolean.initialize(boolean.class, "Boolean", Boolean.valueOf(true), testDO);
+
+ // FromBoolean.checkConversionException(TO_BYTE,
+ // ClassCastException.class, testDO);
+ // FromBoolean.checkConversionException(TO_CHAR,
+ // ClassCastException.class, testDO);
+ // FromBoolean.checkConversionException(TO_DOUBLE,
+ // ClassCastException.class, testDO);
+ // FromBoolean.checkConversionException(TO_FLOAT,
+ // ClassCastException.class, testDO);
+ // FromBoolean.checkConversionException(TO_INT,
+ // ClassCastException.class, testDO);
+ // FromBoolean.checkConversionException(TO_LONG,
+ // ClassCastException.class, testDO);
+ // FromBoolean.checkConversionException(TO_SHORT,
+ // ClassCastException.class, testDO);
+ // FromBoolean.checkConversionException(TO_BYTES,
+ // ClassCastException.class, testDO);
+ // FromBoolean.checkConversionException(TO_BIGDECIMAL,
+ // ClassCastException.class, testDO);
+ // FromBoolean.checkConversionException(TO_BIGINTEGER,
+ // ClassCastException.class, testDO);
+ FromBoolean.checkConversionException(TO_DATAOBJECT, ClassCastException.class, testDO);
+ // FromBoolean.checkConversionException(TO_DATE,
+ // ClassCastException.class, testDO);
+ FromBoolean.checkConversionException(TO_LIST, ClassCastException.class, testDO);
+ FromBoolean.checkConversionException(TO_SEQUENCE, ClassCastException.class, testDO);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Unexpected exception " + e.toString());
+
+ }
+ }
+
+ /**
+ * testByteConversion verifies the conversion from byte to each of the
+ * allowed types.
+ */
+ @org.junit.Test
+ public void testByteConversion() {
+ try {
+ Test FromByte = new Test("byteVal", BYTE_VAL_INDEX);
+
+ FromByte.initialize(byte.class, "Byte", Byte.valueOf("-127"), testDO);
+
+ FromByte.attemptConversion(TO_BYTE, testDO);
+ FromByte.attemptConversion(TO_DOUBLE, testDO);
+ FromByte.attemptConversion(TO_FLOAT, testDO);
+ FromByte.attemptConversion(TO_INT, testDO);
+ FromByte.attemptConversion(TO_LONG, testDO);
+ FromByte.attemptConversion(TO_SHORT, testDO);
+ FromByte.attemptConversion(TO_STRING, testDO);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Unexpected exception " + e.toString());
+
+ }
+ }
+
+ /**
+ * testByteExceptions verifies that the appropriate Exceptions are thrown
+ * when an unpermitted conversion from byte is attempted.
+ */
+ @org.junit.Test
+ public void testByteExceptions() {
+ try {
+ Test FromByte = new Test("byteVal", BYTE_VAL_INDEX);
+
+ FromByte.initialize(byte.class, "Byte", Byte.valueOf("-127"), testDO);
+
+ // FromByte.checkConversionException(TO_BOOLEAN,
+ // ClassCastException.class, testDO);
+ // FromByte.checkConversionException(TO_CHAR,
+ // ClassCastException.class,
+ // testDO);
+ // FromByte.checkConversionException(TO_BYTES,
+ // ClassCastException.class,
+ // testDO);
+ FromByte.checkConversionException(TO_BIGDECIMAL, ClassCastException.class, testDO);
+ FromByte.checkConversionException(TO_BIGINTEGER, ClassCastException.class, testDO);
+ FromByte.checkConversionException(TO_DATAOBJECT, ClassCastException.class, testDO);
+ // FromByte.checkConversionException(TO_DATE,
+ // ClassCastException.class,
+ // testDO);
+ FromByte.checkConversionException(TO_LIST, ClassCastException.class, testDO);
+ FromByte.checkConversionException(TO_SEQUENCE, ClassCastException.class, testDO);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Unexpected exception " + e.toString());
+
+ }
+ }
+
+ /**
+ * testCharConversion verifies the conversion from char to each of the
+ * allowed types.
+ */
+ @org.junit.Test
+ public void testCharConversion() {
+ try {
+ Test FromChar = new Test("charVal", CHAR_VAL_INDEX);
+
+ FromChar.initialize(char.class, "Char", new Character('?'), testDO);
+
+ FromChar.attemptConversion(TO_CHAR, testDO);
+ FromChar.attemptConversion(TO_STRING, testDO);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Unexpected exception " + e.toString());
+
+ }
+ }
+
+ /**
+ * testCharExceptions verifies that the appropriate Exceptions are thrown
+ * when an unpermitted conversion from char is attempted.
+ */
+ @org.junit.Test
+ public void testCharExceptions() {
+ try {
+ Test FromChar = new Test("charVal", CHAR_VAL_INDEX);
+
+ FromChar.initialize(char.class, "Char", new Character('?'), testDO);
+
+ // FromChar.checkConversionException(TO_BOOLEAN,
+ // ClassCastException.class, testDO);
+ // FromChar.checkConversionException(TO_BYTE,
+ // ClassCastException.class,
+ // testDO);
+ // FromChar.checkConversionException(TO_DOUBLE,
+ // ClassCastException.class, testDO);
+ // FromChar.checkConversionException(TO_FLOAT,
+ // ClassCastException.class,
+ // testDO);
+ // FromChar.checkConversionException(TO_INT,
+ // ClassCastException.class,
+ // testDO);
+ // FromChar.checkConversionException(TO_LONG,
+ // ClassCastException.class,
+ // testDO);
+ // FromChar.checkConversionException(TO_SHORT,
+ // ClassCastException.class,
+ // testDO);
+ // FromChar.checkConversionException(TO_BYTES,
+ // ClassCastException.class,
+ // testDO);
+ // FromChar.checkConversionException(TO_BIGDECIMAL,
+ // ClassCastException.class, testDO);
+ // FromChar.checkConversionException(TO_BIGINTEGER,
+ // ClassCastException.class, testDO);
+ FromChar.checkConversionException(TO_DATAOBJECT, ClassCastException.class, testDO);
+ // FromChar.checkConversionException(TO_DATE,
+ // ClassCastException.class,
+ // testDO);
+ FromChar.checkConversionException(TO_LIST, ClassCastException.class, testDO);
+ FromChar.checkConversionException(TO_SEQUENCE, ClassCastException.class, testDO);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Unexpected exception " + e.toString());
+
+ }
+ }
+
+ /**
+ * testDoubleConversion verifies the conversion from double to each of the
+ * allowed types.
+ */
+ @org.junit.Test
+ public void testDoubleConversion() {
+ try {
+ Test FromDouble = new Test("doubleVal", DOUBLE_VAL_INDEX);
+
+ FromDouble.initialize(double.class, "Double", new Double(Double.MAX_VALUE), testDO);
+
+ FromDouble.attemptConversion(TO_BYTE, testDO);
+ FromDouble.attemptConversion(TO_DOUBLE, testDO);
+ FromDouble.attemptConversion(TO_FLOAT, testDO);
+ FromDouble.attemptConversion(TO_INT, testDO);
+ FromDouble.attemptConversion(TO_LONG, testDO);
+ FromDouble.attemptConversion(TO_SHORT, testDO);
+ FromDouble.attemptConversion(TO_BIGDECIMAL, testDO);
+ FromDouble.attemptConversion(TO_BIGINTEGER, testDO);
+ FromDouble.attemptConversion(TO_STRING, testDO);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Unexpected exception " + e.toString());
+
+ }
+ }
+
+ /**
+ * testDoubleExceptions verifies that the appropriate Exceptions are thrown
+ * when an unpermitted conversion from double is attempted.
+ */
+ @org.junit.Test
+ public void testDoubleExceptions() {
+ try {
+ Test FromDouble = new Test("doubleVal", DOUBLE_VAL_INDEX);
+
+ FromDouble.initialize(double.class, "Double", new Double(Double.MAX_VALUE), testDO);
+
+ // FromDouble.checkConversionException(TO_BOOLEAN,
+ // ClassCastException.class, testDO);
+ // FromDouble.checkConversionException(TO_CHAR,
+ // ClassCastException.class, testDO);
+ // FromDouble.checkConversionException(TO_BYTES,
+ // ClassCastException.class, testDO);
+ FromDouble.checkConversionException(TO_DATAOBJECT, ClassCastException.class, testDO);
+ // FromDouble.checkConversionException(TO_DATE,
+ // ClassCastException.class, testDO);
+ FromDouble.checkConversionException(TO_LIST, ClassCastException.class, testDO);
+ FromDouble.checkConversionException(TO_SEQUENCE, ClassCastException.class, testDO);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Unexpected exception " + e.toString());
+
+ }
+ }
+
+ /**
+ * testFloatConversion verifies the conversion from float to each of the
+ * allowed types.
+ */
+ @org.junit.Test
+ public void testFloatConversion() {
+ try {
+ Test FromFloat = new Test("floatVal", FLOAT_VAL_INDEX);
+
+ FromFloat.initialize(float.class, "Float", new Float(Float.MIN_VALUE), testDO);
+
+ FromFloat.attemptConversion(TO_BYTE, testDO);
+ FromFloat.attemptConversion(TO_DOUBLE, testDO);
+ FromFloat.attemptConversion(TO_FLOAT, testDO);
+ FromFloat.attemptConversion(TO_INT, testDO);
+ FromFloat.attemptConversion(TO_LONG, testDO);
+ FromFloat.attemptConversion(TO_SHORT, testDO);
+ FromFloat.attemptConversion(TO_BIGDECIMAL, testDO);
+ FromFloat.attemptConversion(TO_BIGINTEGER, testDO);
+ FromFloat.attemptConversion(TO_STRING, testDO);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Unexpected exception " + e.toString());
+
+ }
+ }
+
+ /**
+ * testFloatExceptions verifies that the appropriate Exceptions are thrown
+ * when an unpermitted conversion from float is attempted.
+ */
+ @org.junit.Test
+ public void testFloatExceptions() {
+ try {
+ Test FromFloat = new Test("floatVal", FLOAT_VAL_INDEX);
+
+ FromFloat.initialize(float.class, "Float", new Float(Float.MIN_VALUE), testDO);
+
+ // FromFloat.checkConversionException(TO_BOOLEAN,
+ // ClassCastException.class, testDO);
+ // FromFloat.checkConversionException(TO_CHAR,
+ // ClassCastException.class,
+ // testDO);
+ // FromFloat.checkConversionException(TO_BYTES,
+ // ClassCastException.class, testDO);
+ FromFloat.checkConversionException(TO_DATAOBJECT, ClassCastException.class, testDO);
+ // FromFloat.checkConversionException(TO_DATE,
+ // ClassCastException.class,
+ // testDO);
+ FromFloat.checkConversionException(TO_LIST, ClassCastException.class, testDO);
+ FromFloat.checkConversionException(TO_SEQUENCE, ClassCastException.class, testDO);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Unexpected exception " + e.toString());
+
+ }
+ }
+
+ /**
+ * testIntConversion verifies the conversion from int to each of the allowed
+ * types.
+ */
+ @org.junit.Test
+ public void testIntConversion() {
+ Test FromInt = new Test("intVal", INT_VAL_INDEX);
+
+ FromInt.initialize(int.class, "Int", new Integer(5), testDO);
+
+ FromInt.attemptConversion(TO_BYTE, testDO);
+ FromInt.attemptConversion(TO_DOUBLE, testDO);
+ FromInt.attemptConversion(TO_FLOAT, testDO);
+ FromInt.attemptConversion(TO_INT, testDO);
+ FromInt.attemptConversion(TO_LONG, testDO);
+ FromInt.attemptConversion(TO_SHORT, testDO);
+ FromInt.attemptConversion(TO_BIGDECIMAL, testDO);
+ FromInt.attemptConversion(TO_BIGINTEGER, testDO);
+ FromInt.attemptConversion(TO_STRING, testDO);
+ }
+
+ /**
+ * testIntExceptions verifies that the appropriate Exceptions are thrown
+ * when an unpermitted conversion from int is attempted.
+ */
+ @org.junit.Test
+ public void testIntExceptions() {
+
+ Test FromInt = new Test("intVal", INT_VAL_INDEX);
+
+ FromInt.initialize(int.class, "Int", new Integer(5), testDO);
+
+ // FromInt.checkConversionException(TO_BOOLEAN,
+ // ClassCastException.class, testDO);
+ // FromInt.checkConversionException(TO_CHAR, ClassCastException.class,
+ // testDO);
+ // FromInt.checkConversionException(TO_BYTES, ClassCastException.class,
+ // testDO);
+ FromInt.checkConversionException(TO_DATAOBJECT, ClassCastException.class, testDO);
+ // FromInt.checkConversionException(TO_DATE, ClassCastException.class,
+ // testDO);
+ FromInt.checkConversionException(TO_LIST, ClassCastException.class, testDO);
+ FromInt.checkConversionException(TO_SEQUENCE, ClassCastException.class, testDO);
+ }
+
+ /**
+ * testLongConversion verifies the conversion from long to each of the
+ * allowed types.
+ */
+ @org.junit.Test
+ public void testLongConversion() {
+ Test FromLong = new Test("longVal", LONG_VAL_INDEX);
+
+ FromLong.initialize(long.class, "Long", new Long(7000L), testDO);
+
+ FromLong.attemptConversion(TO_BYTE, testDO);
+ FromLong.attemptConversion(TO_DOUBLE, testDO);
+ FromLong.attemptConversion(TO_FLOAT, testDO);
+ FromLong.attemptConversion(TO_INT, testDO);
+ FromLong.attemptConversion(TO_LONG, testDO);
+ FromLong.attemptConversion(TO_SHORT, testDO);
+ FromLong.attemptConversion(TO_BIGDECIMAL, testDO);
+ FromLong.attemptConversion(TO_BIGINTEGER, testDO);
+ FromLong.attemptConversion(TO_DATE, testDO);
+ FromLong.attemptConversion(TO_STRING, testDO);
+ }
+
+ /**
+ * testLongExceptions verifies that the appropriate Exceptions are thrown
+ * when an unpermitted conversion from long is attempted.
+ */
+ @org.junit.Test
+ public void testLongExceptions() {
+ Test FromLong = new Test("longVal", LONG_VAL_INDEX);
+
+ FromLong.initialize(long.class, "Long", new Long(7000L), testDO);
+
+ // FromLong.checkConversionException(TO_BOOLEAN,
+ // ClassCastException.class, testDO);
+ // FromLong.checkConversionException(TO_CHAR, ClassCastException.class,
+ // testDO);
+ // FromLong.checkConversionException(TO_BYTES, ClassCastException.class,
+ // testDO);
+ FromLong.checkConversionException(TO_DATAOBJECT, ClassCastException.class, testDO);
+ FromLong.checkConversionException(TO_LIST, ClassCastException.class, testDO);
+ FromLong.checkConversionException(TO_SEQUENCE, ClassCastException.class, testDO);
+ }
+
+ /**
+ * testShortConversion verifies the conversion from short to each of the
+ * allowed types.
+ */
+ @org.junit.Test
+ public void testShortConversion() {
+ Test FromShort = new Test("shortVal", SHORT_VAL_INDEX);
+
+ FromShort.initialize(short.class, "Short", new Short("-8000"), testDO);
+
+ FromShort.attemptConversion(TO_BYTE, testDO);
+ FromShort.attemptConversion(TO_DOUBLE, testDO);
+ FromShort.attemptConversion(TO_FLOAT, testDO);
+ FromShort.attemptConversion(TO_INT, testDO);
+ FromShort.attemptConversion(TO_LONG, testDO);
+ FromShort.attemptConversion(TO_SHORT, testDO);
+ FromShort.attemptConversion(TO_STRING, testDO);
+ }
+
+ /**
+ * testShortExceptions verifies that the appropriate Exceptions are thrown
+ * when an unpermitted conversion from short is attempted.
+ */
+ @org.junit.Test
+ public void testShortExceptions() {
+ Test FromShort = new Test("shortVal", SHORT_VAL_INDEX);
+
+ FromShort.initialize(short.class, "Short", new Short("-8000"), testDO);
+
+ // FromShort.checkConversionException(TO_BOOLEAN,
+ // ClassCastException.class, testDO);
+ // FromShort.checkConversionException(TO_CHAR, ClassCastException.class,
+ // testDO);
+ // FromShort.checkConversionException(TO_BYTES,
+ // ClassCastException.class, testDO);
+ FromShort.checkConversionException(TO_BIGDECIMAL, ClassCastException.class, testDO);
+ FromShort.checkConversionException(TO_BIGINTEGER, ClassCastException.class, testDO);
+ FromShort.checkConversionException(TO_DATAOBJECT, ClassCastException.class, testDO);
+ // FromShort.checkConversionException(TO_DATE, ClassCastException.class,
+ // testDO);
+ FromShort.checkConversionException(TO_LIST, ClassCastException.class, testDO);
+ FromShort.checkConversionException(TO_SEQUENCE, ClassCastException.class, testDO);
+ }
+
+ /**
+ * testStringConversion verifies the conversion from String to each of the
+ * allowed types.
+ */
+ @org.junit.Test
+ public void testStringConversion() {
+ Test FromString = new Test("stringVal", STRING_VAL_INDEX);
+
+ FromString.initialize(String.class, "String", "5", testDO);
+
+ FromString.attemptConversion(TO_BOOLEAN, testDO);
+ FromString.attemptConversion(TO_BYTE, testDO);
+ FromString.attemptConversion(TO_CHAR, testDO);
+ FromString.attemptConversion(TO_DOUBLE, testDO);
+ FromString.attemptConversion(TO_FLOAT, testDO);
+ FromString.attemptConversion(TO_INT, testDO);
+ FromString.attemptConversion(TO_LONG, testDO);
+ FromString.attemptConversion(TO_SHORT, testDO);
+ FromString.attemptConversion(TO_BIGDECIMAL, testDO);
+ FromString.attemptConversion(TO_BIGINTEGER, testDO);
+ FromString.attemptConversion(TO_STRING, testDO);
+
+ FromString.initialize(String.class, "String", "1999-07-25T8:50:14.33Z", testDO);
+ FromString.attemptConversion(TO_DATE, testDO);
+ }
+
+ /**
+ * testStringExceptions verifies that the appropriate Exceptions are thrown
+ * when an unpermitted conversion from String is attempted.
+ */
+ @org.junit.Test
+ public void testStringExceptions() {
+ Test FromString = new Test("stringVal", STRING_VAL_INDEX);
+
+ FromString.initialize(String.class, "String", "5", testDO);
+
+ // FromString.checkConversionException(TO_BYTES,
+ // ClassCastException.class, testDO);
+ FromString.checkConversionException(TO_DATAOBJECT, ClassCastException.class, testDO);
+ FromString.checkConversionException(TO_LIST, ClassCastException.class, testDO);
+ FromString.checkConversionException(TO_SEQUENCE, ClassCastException.class, testDO);
+ }
+
+ /**
+ * testBytesConversion verifies the conversion from Bytes to each of the
+ * allowed types.
+ */
+ @org.junit.Test
+ public void testBytesConversion() {
+ Test FromBytes = new Test("bytesVal", BYTES_VAL_INDEX);
+
+ FromBytes.initialize(byte[].class, "Bytes", new byte[] {10, 100}, testDO);
+
+ FromBytes.attemptConversion(TO_BYTES, testDO);
+ FromBytes.attemptConversion(TO_BIGINTEGER, testDO);
+ }
+
+ /**
+ * testBytesExceptions verifies that the appropriate Exceptions are thrown
+ * when an unpermitted conversion from Bytes is attempted.
+ */
+ @org.junit.Test
+ public void testBytesExceptions() {
+ Test FromBytes = new Test("bytesVal", BYTES_VAL_INDEX);
+
+ FromBytes.initialize(byte[].class, "Bytes", new byte[] {10, 100}, testDO);
+
+ // FromBytes.checkConversionException(TO_BOOLEAN,
+ // ClassCastException.class, testDO);
+ // FromBytes.checkConversionException(TO_BYTE, ClassCastException.class,
+ // testDO);
+ // FromBytes.checkConversionException(TO_CHAR, ClassCastException.class,
+ // testDO);
+ // FromBytes.checkConversionException(TO_DOUBLE,
+ // ClassCastException.class, testDO);
+ // FromBytes.checkConversionException(TO_FLOAT,
+ // ClassCastException.class, testDO);
+ // FromBytes.checkConversionException(TO_INT, ClassCastException.class,
+ // testDO);
+ // FromBytes.checkConversionException(TO_LONG, ClassCastException.class,
+ // testDO);
+ // FromBytes.checkConversionException(TO_SHORT,
+ // ClassCastException.class, testDO);
+ // FromBytes.checkConversionException(TO_BIGDECIMAL,
+ // ClassCastException.class, testDO);
+ FromBytes.checkConversionException(TO_DATAOBJECT, ClassCastException.class, testDO);
+ // FromBytes.checkConversionException(TO_DATE, ClassCastException.class,
+ // testDO);
+ // FromBytes.checkConversionException(TO_STRING,
+ // ClassCastException.class, testDO);
+ FromBytes.checkConversionException(TO_LIST, ClassCastException.class, testDO);
+ FromBytes.checkConversionException(TO_SEQUENCE, ClassCastException.class, testDO);
+ }
+
+ /**
+ * testBigDecimalConversion verifies the conversion from BigDecimal to each
+ * of the allowed types.
+ */
+ @org.junit.Test
+ public void testBigDecimalConversion() {
+ Test FromBigDecimal = new Test("decimalVal", DECIMAL_VAL_INDEX);
+
+ FromBigDecimal.initialize(BigDecimal.class, "BigDecimal", new BigDecimal("-3"), testDO);
+
+ FromBigDecimal.attemptConversion(TO_DOUBLE, testDO);
+ FromBigDecimal.attemptConversion(TO_FLOAT, testDO);
+ FromBigDecimal.attemptConversion(TO_INT, testDO);
+ FromBigDecimal.attemptConversion(TO_LONG, testDO);
+ FromBigDecimal.attemptConversion(TO_BIGDECIMAL, testDO);
+ FromBigDecimal.attemptConversion(TO_BIGINTEGER, testDO);
+ FromBigDecimal.attemptConversion(TO_STRING, testDO);
+ }
+
+ /**
+ * testBigDecimalExceptions verifies that the appropriate Exceptions are
+ * thrown when an unpermitted conversion from BigDecimal is attempted.
+ */
+ @org.junit.Test
+ public void testBigDecimalExceptions() {
+ Test FromBigDecimal = new Test("decimalVal", DECIMAL_VAL_INDEX);
+
+ FromBigDecimal.initialize(BigDecimal.class, "BigDecimal", new BigDecimal("-3"), testDO);
+
+ // FromBigDecimal.checkConversionException(TO_BOOLEAN,
+ // ClassCastException.class, testDO);
+ // FromBigDecimal.checkConversionException(TO_BYTE,
+ // ClassCastException.class, testDO);
+ // FromBigDecimal.checkConversionException(TO_CHAR,
+ // ClassCastException.class, testDO);
+ // FromBigDecimal.checkConversionException(TO_SHORT,
+ // ClassCastException.class, testDO);
+ // FromBigDecimal.checkConversionException(TO_BYTES,
+ // ClassCastException.class, testDO);
+ FromBigDecimal.checkConversionException(TO_DATAOBJECT, ClassCastException.class, testDO);
+ // FromBigDecimal.checkConversionException(TO_DATE,
+ // ClassCastException.class, testDO);
+ FromBigDecimal.checkConversionException(TO_LIST, ClassCastException.class, testDO);
+ FromBigDecimal.checkConversionException(TO_SEQUENCE, ClassCastException.class, testDO);
+ }
+
+ /**
+ * testBigIntegerConversion verifies the conversion from BigInteger to each
+ * of the allowed types.
+ */
+ @org.junit.Test
+ public void testBigIntegerConversion() {
+ Test FromBigInteger = new Test("integerVal", INTEGER_VAL_INDEX);
+
+ FromBigInteger.initialize(BigInteger.class, "BigInteger", new BigInteger("31500"), testDO);
+
+ FromBigInteger.attemptConversion(TO_DOUBLE, testDO);
+ FromBigInteger.attemptConversion(TO_FLOAT, testDO);
+ FromBigInteger.attemptConversion(TO_INT, testDO);
+ FromBigInteger.attemptConversion(TO_LONG, testDO);
+ FromBigInteger.attemptConversion(TO_SHORT, testDO);
+ FromBigInteger.attemptConversion(TO_BYTES, testDO);
+ FromBigInteger.attemptConversion(TO_BIGDECIMAL, testDO);
+ FromBigInteger.attemptConversion(TO_BIGINTEGER, testDO);
+ FromBigInteger.attemptConversion(TO_STRING, testDO);
+ }
+
+ /**
+ * testBigIntegerExceptions verifies that the appropriate Exceptions are
+ * thrown when an unpermitted conversion from BigInteger is attempted.
+ *
+ * @throws Exception
+ */
+ @org.junit.Test
+ public void testBigIntegerExceptions() {
+ Test FromBigInteger = new Test("integerVal", INTEGER_VAL_INDEX);
+
+ FromBigInteger.initialize(BigInteger.class, "BigInteger", new BigInteger("31500"), testDO);
+
+ // FromBigInteger.checkConversionException(TO_BOOLEAN,
+ // ClassCastException.class, testDO);
+ // FromBigInteger.checkConversionException(TO_BYTE,
+ // ClassCastException.class, testDO);
+ // FromBigInteger.checkConversionException(TO_CHAR,
+ // ClassCastException.class, testDO);
+ FromBigInteger.checkConversionException(TO_DATAOBJECT, ClassCastException.class, testDO);
+ // FromBigInteger.checkConversionException(TO_DATE,
+ // ClassCastException.class, testDO);
+ FromBigInteger.checkConversionException(TO_LIST, ClassCastException.class, testDO);
+ FromBigInteger.checkConversionException(TO_SEQUENCE, ClassCastException.class, testDO);
+ }
+
+ /**
+ * testDateConversion verifies the conversion from Date to each of the
+ * allowed types.
+ */
+ @org.junit.Test
+ public void testDateConversion() {
+ Test FromDate = new Test("dateVal", DATE_VAL_INDEX);
+
+ FromDate.initialize(Date.class, "Date", new Date(System.currentTimeMillis()), testDO);
+
+ FromDate.attemptConversion(TO_LONG, testDO);
+ FromDate.attemptConversion(TO_DATE, testDO);
+ FromDate.attemptConversion(TO_STRING, testDO);
+ }
+
+ /**
+ * testDateExceptions verifies that the appropriate Exceptions are thrown
+ * when an unpermitted conversion from Date is attempted.
+ */
+ @org.junit.Test
+ public void testDateExceptions() {
+
+ Test FromDate = new Test("dateVal", DATE_VAL_INDEX);
+
+ FromDate.initialize(Date.class, "Date", new Date(System.currentTimeMillis()), testDO);
+
+ // FromDate.checkConversionException(TO_BOOLEAN,
+ // ClassCastException.class, testDO);
+ // FromDate.checkConversionException(TO_BYTE, ClassCastException.class,
+ // testDO);
+ // FromDate.checkConversionException(TO_CHAR, ClassCastException.class,
+ // testDO);
+ // FromDate.checkConversionException(TO_DOUBLE,
+ // ClassCastException.class, testDO);
+ // FromDate.checkConversionException(TO_FLOAT, ClassCastException.class,
+ // testDO);
+ // FromDate.checkConversionException(TO_INT, ClassCastException.class,
+ // testDO);
+ // FromDate.checkConversionException(TO_SHORT, ClassCastException.class,
+ // testDO);
+ // FromDate.checkConversionException(TO_BYTES, ClassCastException.class,
+ // testDO);
+ // FromDate.checkConversionException(TO_BIGDECIMAL,
+ // ClassCastException.class, testDO);
+ // FromDate.checkConversionException(TO_BIGINTEGER,
+ // ClassCastException.class, testDO);
+ FromDate.checkConversionException(TO_DATAOBJECT, ClassCastException.class, testDO);
+ FromDate.checkConversionException(TO_LIST, ClassCastException.class, testDO);
+ FromDate.checkConversionException(TO_SEQUENCE, ClassCastException.class, testDO);
+ }
+}
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/package.html b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/package.html
new file mode 100644
index 0000000000..2bc8f0c36f
--- /dev/null
+++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/package.html
@@ -0,0 +1,25 @@
+<html>
+<!--
+ 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.
+
+ $Rev$ $Date$
+-->
+<body>
+Contains test cases for conversion test.
+</body>
+</html>