You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ke...@apache.org on 2007/04/26 16:56:52 UTC
svn commit: r532765 - in
/incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21:
UnderReviewSuite.java tests/CTSGeneralSuite.java
tests/conversion/ConversionBase.java
tests/conversion/StringConversionTest.java
tests/conversion/TypeConversionTest.java
Author: kelvingoodson
Date: Thu Apr 26 07:56:51 2007
New Revision: 532765
URL: http://svn.apache.org/viewvc?view=rev&rev=532765
Log:
TUSCANY-1230 applied Andy's patch
Added:
incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/ConversionBase.java (with props)
incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/StringConversionTest.java (with props)
Modified:
incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/UnderReviewSuite.java
incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/CTSGeneralSuite.java
incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/TypeConversionTest.java
Modified: incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/UnderReviewSuite.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/UnderReviewSuite.java?view=diff&rev=532765&r1=532764&r2=532765
==============================================================================
--- incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/UnderReviewSuite.java (original)
+++ incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/UnderReviewSuite.java Thu Apr 26 07:56:51 2007
@@ -40,6 +40,7 @@
@RunWith(Suite.class)
@Suite.SuiteClasses( {test.sdo21.paramatizedTests.CTSParamatizedSuite.class,
test.sdo21.paramatizedTests.conversion.TypeConversionTest.class,
+ test.sdo21.tests.conversion.StringConversionTest.class,
test.sdo21.tests.general.XMLHelperTest.class,
test.sdo21.tests.xsd.XSDComplexTypeTest.class})
public class UnderReviewSuite {
Modified: incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/CTSGeneralSuite.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/CTSGeneralSuite.java?view=diff&rev=532765&r1=532764&r2=532765
==============================================================================
--- incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/CTSGeneralSuite.java (original)
+++ incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/CTSGeneralSuite.java Thu Apr 26 07:56:51 2007
@@ -25,6 +25,8 @@
import test.sdo21.tests.api.DataObjectTest;
import test.sdo21.tests.conversion.DateConversionTest;
+import test.sdo21.tests.conversion.TypeConversionTest;
+import test.sdo21.tests.conversion.StringConversionTest;
import test.sdo21.tests.general.XSDHelperTest;
import test.sdo21.tests.scenarios.DataObjectListTest;
import test.sdo21.tests.xsd.XSDChoiceTest;
@@ -50,7 +52,8 @@
DynamicTypesFromSchemaTestCase.class,
XSDChoiceTest.class,
XSDComplexTypeTest.class,
- DataObjectListTest.class})
+ DataObjectListTest.class,
+ TypeConversionTest.class})
public class CTSGeneralSuite {
}
Added: incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/ConversionBase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/ConversionBase.java?view=auto&rev=532765
==============================================================================
--- incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/ConversionBase.java (added)
+++ incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/ConversionBase.java Thu Apr 26 07:56:51 2007
@@ -0,0 +1,286 @@
+/**
+ *
+ * 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.CTSSuite;
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.TypeHelper;
+
+/**
+ * Base class for conversion tests.
+ */
+public class ConversionBase extends TestCase {
+
+ /**
+ * 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.
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // set up time format as per page 71 of SDO for Java 2.1.0 FINAL
+ f = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'.'SSS'Z'");
+ f.setTimeZone(TimeZone.getTimeZone("GMT"));
+
+ // obtain TestHelper implementation
+ testHelper = CTSSuite.getTestHelper();
+ }
+
+ /**
+ * Helper function for converions tests. Creates a DataObject with name
+ * 'product' and data hold property
+ *
+ * @param strName the name of the data hold property in the created object.
+ * @param strType the type of the data hold property in the created object.
+ * @return the created DataObject.
+ */
+ private DataObject createTypeConversionObject(String strName, String strType) {
+
+ // obtain a TypeHelper
+ TypeHelper typeHelper = testHelper.getTypeHelper();
+
+ // create new DataType
+ String uri = "http://example.com/TypeConversionTest/" + unique;
+ String name = "TypeConversionTest" + unique;
+ unique++;
+ DataObject productType = testHelper.getDataFactory().create("commonj.sdo", "Type");
+ productType.set("uri", uri);
+ productType.set("name", name);
+
+ // define property
+ DataObject dateValProperty = productType.createDataObject("property");
+ dateValProperty.set("name", strName);
+ dateValProperty.set("type", typeHelper.getType("commonj.sdo", strType));
+ dateValProperty.setBoolean("containment", false);
+
+ // define the type
+ typeHelper.define(productType);
+
+ // create DataObject using the new Type
+ return testHelper.getDataFactory().create(uri, name);
+ }
+
+ /**
+ * Helper function for boolean converions tests. Created a DataObject with
+ * 'boolVal' boolean property
+ *
+ * @param initialVal the initial value of the data hold property.
+ * @return the initialized DataObject.
+ */
+ 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;
+ }
+}
Propchange: incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/ConversionBase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/ConversionBase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/StringConversionTest.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/StringConversionTest.java?view=auto&rev=532765
==============================================================================
--- incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/StringConversionTest.java (added)
+++ incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/StringConversionTest.java Thu Apr 26 07:56:51 2007
@@ -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());
+ }
+
+
+}
Propchange: incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/StringConversionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/StringConversionTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/TypeConversionTest.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/TypeConversionTest.java?view=diff&rev=532765&r1=532764&r2=532765
==============================================================================
--- incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/TypeConversionTest.java (original)
+++ incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/TypeConversionTest.java Thu Apr 26 07:56:51 2007
@@ -44,98 +44,13 @@
*/
// TODO: could use expected exception function of test annotation
-public class TypeConversionTest extends TestCase {
-
- /**
- * This variable is used to create unique type names to avoid name clashes
- * in TypeHelper
- */
- static int unique = 0;
-
- /**
- * DateFormat is set up in the constructor as per the format in the
- * specification.
- */
- private DateFormat f;
-
- /**
- * The TestHelper interface provides access to SDO helper classes.
- */
- private TestHelper testHelper;
-
- /**
- * Message to use when an invalid type conversion does not throw a
- * ClassCastException
- */
- private static final String EXPECTED_CLASS_CAST_EXCEPTION =
- "ClassCastException should have been thrown (invalid conversion)";
+public class TypeConversionTest extends ConversionBase {
public TypeConversionTest(String string) {
super(string);
}
/**
- * Sets up a time format and obtain a test helper.
- */
- protected void setUp() throws Exception {
- super.setUp();
-
- // set up time format as per page 71 of SDO for Java 2.1.0 FINAL
- f = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'.'SSS'Z'");
- f.setTimeZone(TimeZone.getTimeZone("GMT"));
-
- // obtain TestHelper implementation
- testHelper = CTSSuite.getTestHelper();
- }
-
- /**
- * Helper function for converions tests. Creates a DataObject with name
- * 'product' and data hold property
- *
- * @param strName the name of the data hold property in the created object.
- * @param strType the type of the data hold property in the created object.
- * @return the created DataObject.
- */
- private DataObject createTypeConversionObject(String strName, String strType) {
-
- // obtain a TypeHelper
- TypeHelper typeHelper = testHelper.getTypeHelper();
-
- // create new DataType
- String uri = "http://example.com/TypeConversionTest/" + unique;
- String name = "TypeConversionTest" + unique;
- unique++;
- DataObject productType = testHelper.getDataFactory().create("commonj.sdo", "Type");
- productType.set("uri", uri);
- productType.set("name", name);
-
- // define property
- DataObject dateValProperty = productType.createDataObject("property");
- dateValProperty.set("name", strName);
- dateValProperty.set("type", typeHelper.getType("commonj.sdo", strType));
- dateValProperty.setBoolean("containment", false);
-
- // define the type
- typeHelper.define(productType);
-
- // create DataObject using the new Type
- return testHelper.getDataFactory().create(uri, name);
- }
-
- /**
- * Helper function for boolean converions tests. Created a DataObject with
- * 'boolVal' boolean property
- *
- * @param initialVal the initial value of the data hold property.
- * @return the initialized DataObject.
- */
- private DataObject createBooleanObject(boolean initialVal) {
- DataObject productType = createTypeConversionObject("boolVal", "Boolean");
- productType.setBoolean("boolVal", initialVal);
- return productType;
- }
-
- /**
* DataObject class test. Testing getting byte from DataObject with type
* boolean
*/
@@ -234,19 +149,6 @@
}
/**
- * DataObject class test. Testing getting string from DataObject with type
- * boolean
- */
- public void testBooleanGetTypeConversionString() {
- DataObject product = createBooleanObject(true);
- String strVal = product.getString("boolVal");
- assertEquals("true", strVal);
- product.setBoolean("boolVal", false);
- strVal = product.getString("boolVal");
- assertEquals("false", strVal);
- }
-
- /**
* DataObject class test. Testing getting bytes[] from DataObject with type
* boolean
*/
@@ -303,19 +205,6 @@
}
/**
- * Helper function for byte converions tests. Creates a DataObject with
- * 'byteVal' byte property
- *
- * @param initialVal the initial value of the data hold property.
- * @return the initialized DataObject.
- */
- private DataObject createByteObject(byte initialVal) {
- DataObject productType = createTypeConversionObject("byteVal", "Byte");
- productType.setByte("byteVal", initialVal);
- return productType;
- }
-
- /**
* DataObject class test. Testing getting boolean from DataObject with type
* byte
*/
@@ -398,18 +287,6 @@
}
/**
- * DataObject class test. Testing getting String from DataObject with type
- * byte
- */
- public void testByteGetTypeConversionString() {
- DataObject product = createByteObject((byte)5);
-
- String stringVal = product.getString("byteVal");
- assertNotNull(stringVal);
- assertEquals(0, stringVal.compareToIgnoreCase("5"));
- }
-
- /**
* DataObject class test. Testing getting bytes[] from DataObject with type
* byte
*/
@@ -428,13 +305,9 @@
* type byte
*/
public void testByteGetTypeConversionBigDecimal() {
- DataObject product = createByteObject((byte)5);
- try {
- product.getBigDecimal("byteVal");
- fail(EXPECTED_CLASS_CAST_EXCEPTION);
- } catch (ClassCastException e) {
- // expected
- }
+ byte value = 5;
+ DataObject product = createByteObject(value);
+ assertEquals( new BigDecimal(value), product.getBigDecimal("byteVal") );
}
/**
@@ -442,13 +315,9 @@
* type byte
*/
public void testByteGetTypeConversionBigInteger() {
- DataObject product = createByteObject((byte)5);
- try {
- product.getBigInteger("byteVal");
- fail(EXPECTED_CLASS_CAST_EXCEPTION);
- } catch (ClassCastException e) {
- // expected
- }
+ byte value = 5;
+ DataObject product = createByteObject(value);
+ assertEquals( new BigInteger(String.valueOf(value)), product.getBigInteger("byteVal") );
}
/**
@@ -466,19 +335,6 @@
}
/**
- * Helper function for char converions tests. Creates a DataObject with
- * 'charVal' char property
- *
- * @param initialVal the initial value of the data hold property.
- * @return the initialized DataObject.
- */
- private DataObject createCharObject(char initialVal) {
- DataObject productType = createTypeConversionObject("charVal", "Character");
- productType.setChar("charVal", initialVal);
- return productType;
- }
-
- /**
* DataObject class test. Testing getting boolean from DataObject with type
* char
*/
@@ -576,18 +432,6 @@
}
/**
- * DataObject class test. Testing getting string from DataObject with type
- * char
- */
- public void testCharGetTypeConversionString() {
- DataObject product = createCharObject('s');
-
- String strRes = product.getString("charVal");
- assertNotNull(strRes);
- assertEquals("s", strRes);
- }
-
- /**
* DataObject class test. Testing getting bytes[] from DataObject with type
* char
*/
@@ -644,19 +488,6 @@
}
/**
- * Helper function for Double converions tests. Creates a DataObject with
- * 'doubleVal' double property.
- *
- * @param initialVal the initial value of the data hold property.
- * @return the initialized DataObject.
- */
- private DataObject createDoubleObject(double initialVal) {
- DataObject productType = createTypeConversionObject("doubleVal", "Double");
- productType.setDouble("doubleVal", initialVal);
- return productType;
- }
-
- /**
* DataObject class test. Testing getting boolean from DataObject with type
* double
*/
@@ -760,16 +591,6 @@
}
/**
- * DataObject class test. Testing getting string from DataObject with type
- * double
- */
- public void testDoubleGetTypeConversionString() {
- DataObject product = createDoubleObject(5);
- String strVal = product.getString("doubleVal");
- assertEquals("5.0", strVal);
- }
-
- /**
* DataObject class test. Testing getting bytes[] from DataObject with type
* double
*/
@@ -820,19 +641,6 @@
}
/**
- * Helper function for Float converions tests. Creates a DataObject with
- * 'floatVal' float property
- *
- * @param initialVal the initial value of the data hold property.
- * @return the initialized DataObject.
- */
- private DataObject createFloatObject(float initialVal) {
- DataObject productType = createTypeConversionObject("floatVal", "Float");
- productType.setFloat("floatVal", initialVal);
- return productType;
- }
-
- /**
* DataObject class test. Testing getting boolean from DataObject with type
* float
*/
@@ -937,16 +745,6 @@
}
/**
- * DataObject class test. Testing getting string from DataObject with type
- * float
- */
- public void testFloatGetTypeConversionString() {
- DataObject product = createFloatObject(5.5F);
- String strval = product.getString("floatVal");
- assertEquals("5.5", strval);
- }
-
- /**
* DataObject class test. Testing getting bytes[] from DataObject with type
* float
*/
@@ -1000,19 +798,6 @@
}
/**
- * Helper function for int converions tests. Creates a DataObject with
- * 'intVal' int property
- *
- * @param initialVal the initial value of the data hold property.
- * @return the initialized DataObject.
- */
- private DataObject createIntObject(int initialVal) {
- DataObject productType = createTypeConversionObject("intVal", "Int");
- productType.setInt("intVal", initialVal);
- return productType;
- }
-
- /**
* DataObject class test. Testing getting boolean from DataObject with type
* int
*/
@@ -1098,16 +883,6 @@
}
/**
- * DataObject class test. Testing getting string from DataObject with type
- * int
- */
- public void testIntGetTypeConversionString() {
- DataObject product = createIntObject(5);
- String strVal = product.getString("intVal");
- assertEquals("5", strVal);
- }
-
- /**
* DataObject class test. Testing getting bytes[] from DataObject with type
* int
*/
@@ -1155,19 +930,6 @@
}
/**
- * Helper function for Long converions tests. Creates a DataObject with
- * 'longVal' long property.
- *
- * @param initialVal the initial value of the data hold property.
- * @return the initialized DataObject.
- */
- private DataObject createLongObject(long initialVal) {
- DataObject productType = createTypeConversionObject("longVal", "Long");
- productType.setLong("longVal", initialVal);
- return productType;
- }
-
- /**
* DataObject class test. Testing getting boolean from DataObject with type
* long
*/
@@ -1260,16 +1022,6 @@
}
/**
- * DataObject class test. Testing getting string from DataObject with type
- * long
- */
- public void testLongGetTypeConversionString() {
- DataObject product = createLongObject(5);
- String strVal = product.getString("longVal");
- assertEquals("5", strVal);
- }
-
- /**
* DataObject class test. Testing getting bytes[] from DataObject with type
* long
*/
@@ -1315,19 +1067,6 @@
}
/**
- * Helper function for short converions tests. Creates a DataObject with
- * 'shortVal' short property
- *
- * @param initialVal the initial value of the data hold property.
- * @return the initialized DataObject.
- */
- private DataObject createShortObject(short initialVal) {
- DataObject productType = createTypeConversionObject("shortVal", "Short");
- productType.setShort("shortVal", initialVal);
- return productType;
- }
-
- /**
* DataObject class test. Testing getting boolean from DataObject with type
* short
*/
@@ -1411,16 +1150,6 @@
}
/**
- * DataObject class test. Testing getting string from DataObject with type
- * short
- */
- public void testShortGetTypeConversionString() {
- DataObject product = createShortObject((short)5);
- String strVal = product.getString("shortVal");
- assertEquals("5", strVal);
- }
-
- /**
* DataObject class test. Testing getting bytes[] from DataObject with type
* short
*/
@@ -1439,14 +1168,9 @@
* type short
*/
public void testShortGetTypeConversionBigDecimal() {
- DataObject product = createShortObject((short)5);
- try {
- product.getBigDecimal("shortVal");
- fail(EXPECTED_CLASS_CAST_EXCEPTION);
- } catch (ClassCastException e) {
- // expected
- }
-
+ short value = 5;
+ DataObject dobj = createShortObject(value);
+ assertEquals( new BigDecimal(value), dobj.getBigDecimal("shortVal") );
}
/**
@@ -1454,14 +1178,9 @@
* type short
*/
public void testShortGetTypeConversionBigInteger() {
- DataObject product = createShortObject((short)5);
- try {
- product.getBigInteger("shortVal");
- fail(EXPECTED_CLASS_CAST_EXCEPTION);
- } catch (ClassCastException e) {
- // expected
- }
-
+ short value = 5;
+ DataObject dobj = createShortObject(value);
+ assertEquals( new BigInteger(String.valueOf(value)), dobj.getBigInteger("shortVal") );
}
/**
@@ -1480,254 +1199,6 @@
}
/**
- * Helper function for short converions tests. Creates a DataObject with
- * 'stringVal' string property
- *
- * @param initialVal the initial value of the data hold property.
- * @return the initialized DataObject.
- */
- private DataObject createStringObject(String initialVal) {
- DataObject productType = createTypeConversionObject("stringVal", "String");
- productType.setString("stringVal", initialVal);
- return productType;
- }
-
- /**
- * DataObject class test. Testing getting boolean from DataObject with type
- * string
- */
- public void testStringGetTypeConversionBoolean() {
- DataObject product = createStringObject("true");
- boolean boolVal = product.getBoolean("stringVal");
- assertEquals(true, boolVal);
-
- DataObject product1 = createStringObject("false");
- boolVal = product1.getBoolean("stringVal");
- assertEquals(false, boolVal);
-
- DataObject product2 = createStringObject("string");
- try {
- product2.getBoolean("stringVal");
- fail(EXPECTED_CLASS_CAST_EXCEPTION);
- } catch (ClassCastException e) {
- // expected
- }
-
- }
-
- /**
- * DataObject class test. Testing getting byte from DataObject with type
- * string
- */
- public void testStringGetTypeConversionByte() {
- DataObject product = createStringObject("5");
- byte byteVal = product.getByte("stringVal");
- assertEquals(5, byteVal);
-
- DataObject product2 = createStringObject("string");
- try {
- product2.getByte("stringVal");
- fail(EXPECTED_CLASS_CAST_EXCEPTION);
- } catch (ClassCastException e) {
- // expected
- }
-
- }
-
- /**
- * DataObject class test. Testing getting char from DataObject with type
- * string
- */
- public void testStringGetTypeConversionChar() {
- DataObject product = createStringObject("string");
- char charVal = product.getChar("stringVal");
- assertEquals('s', charVal);
- }
-
- /**
- * DataObject class test. Testing getting double from DataObject with type
- * string
- */
- public void testStringGetTypeConversionDouble() {
- DataObject product = createStringObject("5");
- double doubleVal = product.getDouble("stringVal");
- assertTrue(5 == doubleVal);
-
- DataObject product2 = createStringObject("string");
- try {
- product2.getDouble("stringVal");
- fail(EXPECTED_CLASS_CAST_EXCEPTION);
- } catch (ClassCastException e) {
- // expected
- }
-
- }
-
- /**
- * DataObject class test. Testing getting float from DataObject with type
- * string
- */
- public void testStringGetTypeConversionFloat() {
- DataObject product = createStringObject("5.5");
- float floatVal = product.getFloat("stringVal");
- assertTrue(5.5F == floatVal);
-
- DataObject product2 = createStringObject("string");
- try {
- product2.getFloat("stringVal");
- fail(EXPECTED_CLASS_CAST_EXCEPTION);
- } catch (ClassCastException e) {
- // expected
- }
-
- }
-
- /**
- * DataObject class test. Testing getting int from DataObject with type
- * string
- */
- public void testStringGetTypeConversionInt() {
- DataObject product = createStringObject("5");
- int intVal = product.getInt("stringVal");
- assertEquals(5, intVal);
-
- DataObject product2 = createStringObject("string");
- try {
- product2.getInt("stringVal");
- fail(EXPECTED_CLASS_CAST_EXCEPTION);
- } catch (ClassCastException e) {
- // expected
- }
-
- }
-
- /**
- * DataObject class test. Testing getting boolean from DataObject with type
- * string
- */
- public void testStringGetTypeConversionLong() {
- DataObject product = createStringObject("5");
- long longVal = product.getLong("stringVal");
- assertEquals(5, longVal);
-
- DataObject product2 = createStringObject("string");
- try {
- product2.getLong("stringVal");
- fail(EXPECTED_CLASS_CAST_EXCEPTION);
- } catch (ClassCastException e) {
- // expected
- }
-
- }
-
- /**
- * DataObject class test. Testing getting short from DataObject with type
- * string
- */
- public void testStringGetTypeConversionShort() {
- DataObject product = createStringObject("5");
- short shortVal = product.getShort("stringVal");
- assertEquals(5, shortVal);
-
- DataObject product2 = createStringObject("string");
- try {
- product2.getShort("stringVal");
- fail(EXPECTED_CLASS_CAST_EXCEPTION);
- } catch (ClassCastException e) {
- // expected
- }
-
- }
-
- /**
- * DataObject class test. Testing getting bytes from DataObject with type
- * string
- */
- public void testStringGetTypeConversionBytes() {
- DataObject product = createStringObject("0A64");
-
- byte[] bytesRes = product.getBytes("stringVal");
- assertNotNull(bytesRes);
-
- assertEquals(2, bytesRes.length);
- assertEquals(10, bytesRes[0]);
- assertEquals(100, bytesRes[1]);
- }
-
- /**
- * DataObject class test. Testing getting decimal from DataObject with type
- * string
- */
- public void testStringGetTypeConversionBigDecimal() {
- DataObject product = createStringObject("5");
- BigDecimal bdVal = product.getBigDecimal("stringVal");
- assertTrue(5 == bdVal.intValue());
-
- DataObject product2 = createStringObject("string");
- try {
- product2.getBigDecimal("stringVal");
- fail(EXPECTED_CLASS_CAST_EXCEPTION);
- } catch (ClassCastException e) {
- // expected
- }
-
- }
-
- /**
- * DataObject class test. Testing getting BigInteger from DataObject with
- * type string
- */
- public void testStringGetTypeConversionBigInteger() {
- DataObject product = createStringObject("5");
- BigInteger biVal = product.getBigInteger("stringVal");
- assertTrue(5 == biVal.intValue());
-
- DataObject product2 = createStringObject("string");
- try {
- product2.getBigInteger("stringVal");
- fail(EXPECTED_CLASS_CAST_EXCEPTION);
- } catch (ClassCastException e) {
- // expected
- }
-
- }
-
- /**
- * DataObject class test. Testing getting date from DataObject with type
- * string
- */
- public void testStringGetTypeConversionDate() {
- Date bdTemp = new Date();
- String dateString = f.format(bdTemp);
-
- DataObject product = createStringObject(dateString);
- Date dateVal = product.getDate("stringVal");
- assertEquals(bdTemp, dateVal);
-
- DataObject product2 = createStringObject("string");
- try {
- product2.getDate("stringVal");
- fail(EXPECTED_CLASS_CAST_EXCEPTION);
- } catch (ClassCastException e) {
- // expected
- }
-
- }
-
- /**
- * Helper function for byte[] converions tests. Created a DataObject with
- * 'bytesVal' byte[] property
- *
- * @param initialVal the initial value of the data hold property.
- * @return the initialized DataObject.
- */
- private DataObject createBytesObject(byte[] initialVal) {
- DataObject productType = createTypeConversionObject("bytesVal", "Bytes");
- productType.setBytes("bytesVal", initialVal);
- return productType;
- }
-
- /**
* DataObject class test. Testing getting boolean from DataObject with type
* byte[]
*/
@@ -1856,17 +1327,6 @@
}
/**
- * DataObject class test. Testing getting string from DataObject with type
- * byte[]
- */
- public void testBytesGetTypeConversionString() {
- byte[] byteVal = {10, 100};
- DataObject product = createBytesObject(byteVal);
- String strRes = product.getString("bytesVal");
- assertEquals(0, strRes.compareToIgnoreCase("0a64"));
- }
-
- /**
* DataObject class test. Testing getting BigDecimal from DataObject with
* type byte[]
*/
@@ -1915,19 +1375,6 @@
}
/**
- * Helper function for Decimal converions tests. creates a DataObject with
- * 'bigDecimalVal' BigDecimal property
- *
- * @param initialVal the initial value of the data hold property.
- * @return the initialized DataObject.
- */
- private DataObject createBigDecimalObject(BigDecimal initialVal) {
- DataObject productType = createTypeConversionObject("bigDecimalVal", "Decimal");
- productType.setBigDecimal("bigDecimalVal", initialVal);
- return productType;
- }
-
- /**
* DataObject class test. Testing getting boolean from DataObject with type
* BigDecimal
*/
@@ -1947,14 +1394,9 @@
* BigDecimal
*/
public void testBigDecimalGetTypeConversionByte() {
- DataObject product = createBigDecimalObject(new BigDecimal(4));
- try {
- product.getByte("bigDecimalVal");
- fail(EXPECTED_CLASS_CAST_EXCEPTION);
- } catch (ClassCastException e) {
- // expected
- }
-
+ BigDecimal value = new BigDecimal(4);
+ DataObject product = createBigDecimalObject(value);
+ assertEquals( value.byteValue(), product.getByte("bigDecimalVal") );
}
/**
@@ -2027,26 +1469,9 @@
* BigDecimal
*/
public void testBigDecimalGetTypeConversionShort() {
- DataObject product = createBigDecimalObject(new BigDecimal(4));
- try {
- product.getShort("bigDecimalVal");
- fail(EXPECTED_CLASS_CAST_EXCEPTION);
- } catch (ClassCastException e) {
- // expected
- }
-
- }
-
- /**
- * DataObject class test. Testing getting string from DataObject with type
- * BigDecimal
- */
- public void testBigDecimalGetTypeConversionString() {
- BigDecimal initialVal = new BigDecimal(4);
- DataObject product = createBigDecimalObject(initialVal);
-
- String strVal = product.getString("bigDecimalVal");
- assertEquals(strVal, initialVal.toString());
+ BigDecimal value = new BigDecimal(4);
+ DataObject product = createBigDecimalObject(value);
+ assertEquals( value.shortValue(), product.getShort("bigDecimalVal") );
}
/**
@@ -2095,19 +1520,6 @@
}
/**
- * Helper function for BigInteger converions tests. Creates a DataObject
- * with 'bigIntegerVal' BigInteger property.
- *
- * @param initialVal the initial value of the data hold property.
- * @return the initialized DataObject.
- */
- private DataObject createBigIntegerObject(BigInteger initialVal) {
- DataObject productType = createTypeConversionObject("bigIntegerVal", "Integer");
- productType.setBigInteger("bigIntegerVal", initialVal);
- return productType;
- }
-
- /**
* DataObject class test. Testing getting boolean from DataObject with type
* BigInteger
*/
@@ -2127,14 +1539,9 @@
* BigInteger
*/
public void testBigIntegerGetTypeConversionByte() {
- DataObject product = createBigIntegerObject(BigInteger.valueOf(4));
- try {
- product.getByte("bigIntegerVal");
- fail(EXPECTED_CLASS_CAST_EXCEPTION);
- } catch (ClassCastException e) {
- // expected
- }
-
+ BigInteger value = new BigInteger("5");
+ DataObject product = createBigIntegerObject(value);
+ assertEquals( value.byteValue(), product.getByte("bigIntegerVal") );
}
/**
@@ -2205,26 +1612,9 @@
* BigInteger
*/
public void testBigIntegerGetTypeConversionShort() {
- DataObject product = createBigIntegerObject(BigInteger.valueOf(4));
- try {
- product.getShort("bigIntegerVal");
- fail(EXPECTED_CLASS_CAST_EXCEPTION);
- } catch (ClassCastException e) {
- // expected
- }
-
- }
-
- /**
- * DataObject class test. Testing getting string from DataObject with type
- * BigInteger
- */
- public void testBigIntegerGetTypeConversionString() {
- DataObject product = createBigIntegerObject(BigInteger.valueOf(4));
-
- String strVal = product.getString("bigIntegerVal");
- assertTrue(strVal.compareTo("4") == 0);
-
+ BigInteger value = new BigInteger("5");
+ DataObject product = createBigIntegerObject(value);
+ assertEquals( value.shortValue(), product.getShort("bigIntegerVal") );
}
/**
@@ -2270,19 +1660,6 @@
}
/**
- * Helper function for Date converions tests. Creates a DataObject with
- * 'dateVal' date property.
- *
- * @param initialVal the initial value of the data hold property.
- * @return the initialized DataObject.
- */
- private DataObject createDateObject(Date initialVal) {
- DataObject productType = createTypeConversionObject("dateVal", "Date");
- productType.setDate("dateVal", initialVal);
- return productType;
- }
-
- /**
* DataObject class test. Testing getting boolean from DataObject with type
* date
*/
@@ -2400,20 +1777,6 @@
}
/**
- * DataObject class test. Testing getting string from DataObject with type
- * date
- */
- public void testDateGetTypeConversionString() {
- Date dateNow = new Date();
- DataObject product = createDateObject(dateNow);
- String strVal = product.getString("dateVal");
-
- String dateString = f.format(dateNow);
-
- assertTrue(strVal.compareTo(dateString) == 0);
- }
-
- /**
* DataObject class test. Testing getting byte[] from DataObject with type
* date
*/
@@ -2564,20 +1927,6 @@
}
/**
- * DataObject class test. Testing setting string to DataObject with type
- * boolean
- */
- public void testBooleanSetTypeConversionString() {
- DataObject product = createBooleanObject(true);
- product.setString("boolVal", "false");
- boolean boolVal = product.getBoolean("boolVal");
- assertFalse(boolVal);
- product.setString("boolVal", "true");
- boolVal = product.getBoolean("boolVal");
- assertTrue(boolVal);
- }
-
- /**
* DataObject class test. Testing setting bytes[] to DataObject with type
* boolean
*/
@@ -2720,36 +2069,17 @@
/**
* DataObject class test. Testing setting short to DataObject with type byte
- */
- public void testByteSetTypeConversionShort() {
- DataObject product = createByteObject((byte)5);
-
- short s = (short)6;
- product.setShort("byteVal", s);
- byte byteVal = product.getByte("byteVal");
- assertEquals((byte)s, byteVal);
- }
-
- /**
- * DataObject class test. Testing setting String to DataObject with type
- * byte
- */
- public void testByteSetTypeConversionString() {
- DataObject product = createByteObject((byte)5);
-
- product.setString("byteVal", "6");
- byte byteVal = product.getByte("byteVal");
- assertTrue(byteVal == 6);
-
- try {
- product.setString("byteVal", "string");
- fail(EXPECTED_CLASS_CAST_EXCEPTION);
- } catch (ClassCastException e) {
- // expected
- }
+ */
+ 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
@@ -2771,14 +2101,11 @@
* byte
*/
public void testByteSetTypeConversionBigDecimal() {
- DataObject product = createByteObject((byte)5);
- try {
- product.setBigDecimal("byteVal", new BigDecimal(4));
- fail(EXPECTED_CLASS_CAST_EXCEPTION);
- } catch (ClassCastException e) {
- // expected
- }
-
+ byte value = 5;
+ byte newVal = 25;
+ DataObject product = createByteObject(value);
+ product.setBigDecimal("byteVal", new BigDecimal(newVal));
+ assertEquals( newVal, product.getByte("byteVal") );
}
/**
@@ -2786,14 +2113,11 @@
* byte
*/
public void testByteSetTypeConversionBigInteger() {
- DataObject product = createByteObject((byte)5);
- try {
- product.setBigInteger("byteVal", BigInteger.valueOf(4));
- fail(EXPECTED_CLASS_CAST_EXCEPTION);
- } catch (ClassCastException e) {
- // expected
- }
-
+ byte value = 5;
+ byte newVal = 25;
+ DataObject product = createByteObject(value);
+ product.setBigInteger("byteVal", BigInteger.valueOf(newVal));
+ assertEquals( newVal, product.getByte("byteVal") );
}
/**
@@ -2911,18 +2235,6 @@
}
/**
- * 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 bytes[] to DataObject with type
* char
*/
@@ -3067,26 +2379,6 @@
}
/**
- * 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 byte[] to DataObject with type
* double
*/
@@ -3226,27 +2518,6 @@
}
/**
- * 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 byte[] to DataObject with type
* float
*/
@@ -3385,26 +2656,6 @@
}
/**
- * 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 bytes[] to DataObject with type
* int
*/
@@ -3541,26 +2792,6 @@
}
/**
- * 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 byte[] to DataObject with type
* long
*/
@@ -3696,25 +2927,6 @@
assertEquals((short)value, shortVal);
}
- /**
- * 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 bytes[] to DataObject with type
@@ -3737,14 +2949,11 @@
* short
*/
public void testShortSetTypeConversionBigDecimal() {
- DataObject product = createShortObject((short)5);
- try {
- product.setBigDecimal("shortVal", new BigDecimal(6));
- fail(EXPECTED_CLASS_CAST_EXCEPTION);
- } catch (ClassCastException e) {
- // expected
- }
-
+ short value = 5;
+ BigDecimal newValue = new BigDecimal(6);
+ DataObject product = createShortObject(value);
+ product.setBigDecimal("shortVal", newValue);
+ assertEquals( newValue, product.getBigDecimal("shortVal") );
}
/**
@@ -3752,14 +2961,11 @@
* short
*/
public void testShortSetTypeConversionBigInteger() {
- DataObject product = createShortObject((short)5);
- try {
- product.setBigInteger("shortVal", BigInteger.valueOf(6));
- fail(EXPECTED_CLASS_CAST_EXCEPTION);
- } catch (ClassCastException e) {
- // expected
- }
-
+ short value = 5;
+ BigInteger newValue = BigInteger.valueOf(6);
+ DataObject product = createShortObject(value);
+ product.setBigInteger("shortVal", newValue);
+ assertEquals( newValue, product.getBigInteger("shortVal") );
}
/**
@@ -3775,154 +2981,6 @@
}
}
- /**
- * 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 setting boolean to DataObject with type
@@ -4044,22 +3102,6 @@
}
/**
- * 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 BigDecimal to DataObject with type
* byte[]
*/
@@ -4129,13 +3171,11 @@
* BigDecimal
*/
public void testBigDecimalSetTypeConversionByte() {
- DataObject product = createBigDecimalObject(new BigDecimal(4));
- try {
- product.setByte("bigDecimalVal", (byte)5);
- fail(EXPECTED_CLASS_CAST_EXCEPTION);
- } catch (ClassCastException e) {
- // expected
- }
+ byte byteValue = 12;
+ BigDecimal value = BigDecimal.valueOf(4);
+ DataObject product = createBigDecimalObject(value);
+ product.setByte("bigDecimalVal", byteValue );
+ assertEquals( byteValue, product.getByte("bigDecimalVal") );
}
/**
@@ -4202,25 +3242,11 @@
* BigDecimal
*/
public void testBigDecimalSetTypeConversionShort() {
- DataObject product = createBigDecimalObject(new BigDecimal(4));
- try {
- product.setShort("bigDecimalVal", (short)5);
- fail(EXPECTED_CLASS_CAST_EXCEPTION);
- } catch (ClassCastException e) {
- // expected
- }
- }
-
- /**
- * 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);
+ BigDecimal value = new BigDecimal(4);
+ short newValue = (short) 5;
+ DataObject product = createBigDecimalObject(value);
+ product.setShort("bigDecimalVal", newValue);
+ assertEquals( newValue, product.getShort("bigDecimalVal") );
}
/**
@@ -4284,13 +3310,11 @@
* BigInteger
*/
public void testBigIntegerSetTypeConversionByte() {
- DataObject product = createBigIntegerObject(BigInteger.valueOf(4));
- try {
- product.setByte("bigIntegerVal", (byte)5);
- fail(EXPECTED_CLASS_CAST_EXCEPTION);
- } catch (ClassCastException e) {
- // expected
- }
+ byte byteValue = 12;
+ BigInteger value = BigInteger.valueOf(4);
+ DataObject product = createBigIntegerObject(value);
+ product.setByte("bigIntegerVal", byteValue );
+ assertEquals( byteValue, product.getByte("bigIntegerVal") );
}
/**
@@ -4359,25 +3383,11 @@
* BigInteger
*/
public void testBigIntegerSetTypeConversionShort() {
- DataObject product = createBigIntegerObject(BigInteger.valueOf(4));
- try {
- product.setShort("bigIntegerVal", (short)5);
- fail(EXPECTED_CLASS_CAST_EXCEPTION);
- } catch (ClassCastException e) {
- // expected
- }
- }
-
- /**
- * 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);
+ BigInteger value = BigInteger.valueOf(4);
+ short newValue = (short) 5;
+ DataObject product = createBigIntegerObject(value);
+ product.setShort("bigIntegerVal", newValue);
+ assertEquals( newValue, product.getShort("bigIntegerVal") );
}
/**
@@ -4529,21 +3539,6 @@
} catch (ClassCastException e) {
// expected
}
- }
-
- /**
- * 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());
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org