diff options
Diffstat (limited to 'java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/StringConversionTest.java')
-rw-r--r-- | java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/StringConversionTest.java | 746 |
1 files changed, 0 insertions, 746 deletions
diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/StringConversionTest.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/StringConversionTest.java deleted file mode 100644 index 61a3112cc2..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/StringConversionTest.java +++ /dev/null @@ -1,746 +0,0 @@ -/** - * - * 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()); - } - - -} |