diff options
Diffstat (limited to 'java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/SequenceAddTypedTest.java')
-rw-r--r-- | java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/SequenceAddTypedTest.java | 599 |
1 files changed, 0 insertions, 599 deletions
diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/SequenceAddTypedTest.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/SequenceAddTypedTest.java deleted file mode 100644 index 4c927b67da..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/SequenceAddTypedTest.java +++ /dev/null @@ -1,599 +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. - * - * $Rev$ $Date$ - */ -package test.sdo21.tests.api; - -import commonj.sdo.DataObject; -import commonj.sdo.Sequence; -import commonj.sdo.Property; -import commonj.sdo.Type; -import commonj.sdo.helper.DataFactory; -import commonj.sdo.helper.HelperContext; -import commonj.sdo.helper.TypeHelper; -import test.sdo21.framework.TestHelper; -import test.sdo21.framework.junit3_8.CTSTestCase; -import test.sdo21.CTSSuite; -import junit.framework.TestCase; - -public class SequenceAddTypedTest extends CTSTestCase { - - protected String URI = "http://www.example.com/cts/SequenceAddTypedTest"; - - protected TestHelper testHelper; - protected DataFactory dataFactory; - protected TypeHelper typeHelper; - protected DataObject testDataObject; - - public SequenceAddTypedTest(String string) throws Exception{ - super(string); - } - - public void setUp() throws Exception { - super.setUp(); - - HelperContext scope = getScope(); - testHelper = getTestHelper(); - dataFactory = scope.getDataFactory(); - typeHelper = scope.getTypeHelper(); - - - defineDynamicTypes(getName()); - } - - /** - * Helper function to define the types - * and also get the test name for use - * in the URI to create a seperate xmldoc - * for each test case. - * - * @param testName Name to append to URI - */ - - protected void defineDynamicTypes(String testName) throws Exception { - - //Setup Open DataObject and enable sequence - - - String testURI = URI + testName; - - if (typeHelper.getType(testURI, testName) == null) { - DataObject testRootType = dataFactory.create( "commonj.sdo", "Type" ); - testRootType.set( "uri" , testURI); - testRootType.set( "name", testName); - testRootType.set( "sequenced", true ); - - DataObject testProperty = testRootType.createDataObject( "property" ); - testProperty.set( "name", "testBoolean" ); - testProperty.set( "type", typeHelper.getType("commonj.sdo", "Boolean" )); - testProperty.set( "many", true); - - testProperty = testRootType.createDataObject( "property" ); - testProperty.set( "name", "testString" ); - testProperty.set( "type", typeHelper.getType("commonj.sdo", "String" )); - testProperty.set( "many", true); - - testProperty = testRootType.createDataObject( "property" ); - testProperty.set( "name", "testCharacter" ); - testProperty.set( "type", typeHelper.getType("commonj.sdo", "Character" )); - testProperty.set( "many", true); - - testProperty = testRootType.createDataObject( "property" ); - testProperty.set( "name", "testDate" ); - testProperty.set( "type", typeHelper.getType("commonj.sdo", "Date" )); - testProperty.set( "many", true); - - testProperty = testRootType.createDataObject( "property" ); - testProperty.set( "name", "testDateTime" ); - testProperty.set( "type", typeHelper.getType("commonj.sdo", "DateTime" )); - testProperty.set( "many", true); - - testProperty = testRootType.createDataObject( "property" ); - testProperty.set( "name", "testDay" ); - testProperty.set( "type", typeHelper.getType("commonj.sdo", "Day" )); - testProperty.set( "many", true); - - testProperty = testRootType.createDataObject( "property" ); - testProperty.set( "name", "testDecimal" ); - testProperty.set( "type", typeHelper.getType("commonj.sdo", "Decimal" )); - testProperty.set( "many", true); - - testProperty = testRootType.createDataObject( "property" ); - testProperty.set( "name", "testDouble" ); - testProperty.set( "type", typeHelper.getType("commonj.sdo", "Double" )); - testProperty.set( "many", true); - - typeHelper.define( testRootType ); - } - testDataObject = dataFactory.create( testURI, testName ); - } - - /** - * Tests the SDO 2.1 Sequence method for the - * java type of Boolean - * - * boolean add(String propertyName, Object value) - * - */ - public void testAddBooleanByName() throws Exception { - - Boolean testTrue = Boolean.TRUE; - Boolean testFalse = Boolean.FALSE; - - //DataObject testBoolean = testDataObject.getDataObject( "testBoolean" ); - - Sequence testSequence = testDataObject.getSequence(); - assertEquals( 0, testSequence.size() ); - - testSequence.add("testBoolean", Boolean.TRUE); - testSequence.add("testBoolean", Boolean.FALSE); - testSequence.add("testBoolean", Boolean.TRUE); - assertEquals( 3, testSequence.size() ); - - //Check the basic value - assertTrue(testTrue.equals(testSequence.getValue(0))); - assertTrue(testFalse.equals(testSequence.getValue(1))); - assertTrue(testTrue.equals(testSequence.getValue(2))); - - //Get the properties and check - //that they are equal to the types property - - Property prop = testSequence.getProperty(0); - assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); - prop = testSequence.getProperty(1); - assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); - prop = testSequence.getProperty(2); - assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); - - - } - - /** - * Tests the SDO 2.1 Sequence method for the - * java type of Boolean - * - * boolean add(Property property, Object value) - * - */ - public void testAddBooleanByProperty() throws Exception { - - Boolean testTrue = new Boolean(true); - Boolean testFalse = new Boolean(false); - - //DataObject testBoolean = testDataObject.getDataObject( "testBoolean" ); - - Sequence testSequence = testDataObject.getSequence(); - assertEquals( testSequence.size(), 0 ); - - Property prop = testDataObject.getInstanceProperty("testBoolean"); - testSequence.add(prop, new Boolean(true)); - testSequence.add(prop, new Boolean(false)); - testSequence.add(prop, new Boolean(true)); - - //Check the basic value - assertEquals( 3, testSequence.size() ); - - assertTrue(testTrue.equals(testSequence.getValue(0))); - assertTrue(testFalse.equals(testSequence.getValue(1))); - assertTrue(testTrue.equals(testSequence.getValue(2))); - - //Get the properties and check - //that they are equal to the types property - - prop = testSequence.getProperty(0); - assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); - prop = testSequence.getProperty(1); - assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); - prop = testSequence.getProperty(2); - assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); - } - - /** - * Tests the SDO 2.1 Sequence method for the - * java type of Boolean - * - * boolean add(int propertyIndex, Object value) - * - */ - public void testAddBooleanByPropertyIndex() throws Exception { - - Boolean testTrue = new Boolean(true); - Boolean testFalse = new Boolean(false); - - //DataObject testBoolean = testDataObject.getDataObject( "testBoolean" ); - - Sequence testSequence = testDataObject.getSequence(); - assertEquals( 0, testSequence.size() ); - - testSequence.add(0, new Boolean(true)); - testSequence.add(0, new Boolean(false)); - testSequence.add(0, new Boolean(true)); - - //Check the basic value - assertEquals(3, testSequence.size()); - assertTrue(testTrue.equals(testSequence.getValue(0))); - assertTrue(testFalse.equals(testSequence.getValue(1))); - assertTrue(testTrue.equals(testSequence.getValue(2))); - - //Get the properties and check - //that they are equal to the types property - - Property prop = testSequence.getProperty(0); - assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); - prop = testSequence.getProperty(1); - assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); - prop = testSequence.getProperty(2); - assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); - } - - /** - * Tests the SDO 2.1 Sequence method for the - * java type of Boolean - * - * boolean add(int index, String propertyName, Object value) - * - */ - public void testAddBooleanByIndexAndPropertyName() throws Exception { - - Boolean testTrue = new Boolean(true); - Boolean testFalse = new Boolean(false); - - //DataObject testBoolean = testDataObject.getDataObject( "testBoolean" ); - - Sequence testSequence = testDataObject.getSequence(); - assertEquals( 0, testSequence.size() ); - - testSequence.add("testBoolean", new Boolean(true)); - testSequence.add("testBoolean", new Boolean(false)); - testSequence.add("testBoolean", new Boolean(true)); - - testSequence.add(1, "testBoolean", new Boolean(true)); - - //Check the basic values - assertEquals( 4, testSequence.size() ); - assertTrue(testTrue.equals(testSequence.getValue(0))); - assertTrue(testTrue.equals(testSequence.getValue(1))); - assertTrue(testFalse.equals(testSequence.getValue(2))); - assertTrue(testTrue.equals(testSequence.getValue(3))); - - //Get the properties and check - //that everything is set. - - Property prop = testSequence.getProperty(0); - assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); - prop = testSequence.getProperty(1); - assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); - prop = testSequence.getProperty(2); - assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); - - } - /** - * Tests the SDO 2.1 Sequence method for the - * java type of Boolean - * - * boolean add(int index, Property property, Object value) - * - */ - public void testAddBooleanByIndexAndProperty() throws Exception { - - Boolean testTrue = new Boolean(true); - Boolean testFalse = new Boolean(false); - - Sequence testSequence = testDataObject.getSequence(); - assertEquals( 0, testSequence.size() ); - - Property prop = testDataObject.getInstanceProperty("testBoolean"); - testSequence.add(0, prop, new Boolean(true)); - testSequence.add(1, prop, new Boolean(false)); - testSequence.add(2, prop, new Boolean(true)); - - //Check the basic value - assertEquals( 3, testSequence.size() ); - assertTrue(testTrue.equals(testSequence.getValue(0))); - assertTrue(testFalse.equals(testSequence.getValue(1))); - assertTrue(testTrue.equals(testSequence.getValue(2))); - - //Get the properties and check - //that everything is set. - - prop = testSequence.getProperty(0); - assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); - prop = testSequence.getProperty(1); - assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); - prop = testSequence.getProperty(2); - assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); - - } - - /** - * Tests the SDO 2.1 Sequence method for the - * java type of Boolean - * - * boolean add(int index, int propertyIndex, Object value) - * - */ - public void testAddBooleanByIndexAndPropertyIndex() throws Exception { - - Boolean testTrue = new Boolean(true); - Boolean testFalse = new Boolean(false); - - //DataObject testBoolean = testDataObject.getDataObject( "testBoolean" ); - - Sequence testSequence = testDataObject.getSequence(); - assertEquals( 0, testSequence.size() ); - - testSequence.add(0, 0, new Boolean(true)); - testSequence.add(1, 0, new Boolean(false)); - testSequence.add(2, 0, new Boolean(true)); - - //Check the basic value - assertEquals( 3, testSequence.size() ); - assertTrue(testTrue.equals(testSequence.getValue(0))); - assertTrue(testFalse.equals(testSequence.getValue(1))); - assertTrue(testTrue.equals(testSequence.getValue(2))); - - //Get the properties and check - //that everything is set. - - Property prop = testSequence.getProperty(0); - assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); - prop = testSequence.getProperty(1); - assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); - prop = testSequence.getProperty(2); - assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); - } - - /** - * Tests the SDO 2.1 Sequence method for the - * java type of String - * - * String add(String propertyName, Object value) - * - */ - public void testAddStringByName() throws Exception { - - String testString1 = new String("String1"); - String testString2 = new String("String2"); - - //DataObject testString = testDataObject.getDataObject( "testString" ); - - Sequence testSequence = testDataObject.getSequence(); - assertEquals( 0, testSequence.size() ); - - testSequence.add("testString", new String("String1")); - testSequence.add("testString", new String("String2")); - testSequence.add("testString", new String("String1")); - - //Check the basic value - assertTrue(testString1.equals(testSequence.getValue(0))); - assertTrue(testString2.equals(testSequence.getValue(1))); - assertTrue(testString1.equals(testSequence.getValue(2))); - - //Get the properties and check - //that they are equal to the types property - - Property prop = testSequence.getProperty(0); - assertEquals( prop , testDataObject.getInstanceProperty("testString")); - prop = testSequence.getProperty(1); - assertEquals( prop , testDataObject.getInstanceProperty("testString")); - prop = testSequence.getProperty(2); - assertEquals( prop , testDataObject.getInstanceProperty("testString")); - - - } - - /** - * Tests the SDO 2.1 Sequence method for the - * java type of String - * - * String add(Property property, Object value) - * - */ - public void testAddStringByProperty() throws Exception { - - String testString1 = new String("String1"); - String testString2 = new String("String2"); - - //DataObject testString = testDataObject.getDataObject( "testString" ); - - Sequence testSequence = testDataObject.getSequence(); - assertEquals( 0, testSequence.size() ); - - Property prop = testDataObject.getProperty("testString"); - testSequence.add(prop, new String("String1")); - testSequence.add(prop, new String("String2")); - testSequence.add(prop, new String("String1")); - - //Check the basic value - assertEquals( 3, testSequence.size() ); - - assertTrue(testString1.equals(testSequence.getValue(0))); - assertTrue(testString2.equals(testSequence.getValue(1))); - assertTrue(testString1.equals(testSequence.getValue(2))); - - //Get the properties and check - //that they are equal to the types property - - prop = testSequence.getProperty(0); - assertEquals( prop , testDataObject.getInstanceProperty("testString")); - prop = testSequence.getProperty(1); - assertEquals( prop , testDataObject.getInstanceProperty("testString")); - prop = testSequence.getProperty(2); - assertEquals( prop , testDataObject.getInstanceProperty("testString")); - } - - /** - * Tests the SDO 2.1 Sequence method for the - * java type of String - * - * String add(int propertyIndex, Object value) - * - */ - public void testAddStringByPropertyIndex() throws Exception { - - String testString1 = new String("String1"); - String testString2 = new String("String2"); - - //DataObject testString = testDataObject.getDataObject( "testString" ); - - Sequence testSequence = testDataObject.getSequence(); - assertEquals( 0, testSequence.size() ); - - - //For the property index, it should be the - //order the types were defined in - testSequence.add(1, (Object)new String("String1")); - testSequence.add(1, (Object)new String("String2")); - testSequence.add(1, (Object)new String("String1")); - - //Check the basic value - assertEquals( 3, testSequence.size() ); - assertTrue(testString1.equals(testSequence.getValue(0))); - assertTrue(testString2.equals(testSequence.getValue(1))); - assertTrue(testString1.equals(testSequence.getValue(2))); - - //Get the properties and check - //that they are equal to the types property - - Property prop = testSequence.getProperty(0); - assertEquals( prop , testDataObject.getInstanceProperty("testString")); - prop = testSequence.getProperty(1); - assertEquals( prop , testDataObject.getInstanceProperty("testString")); - prop = testSequence.getProperty(2); - assertEquals( prop , testDataObject.getInstanceProperty("testString")); - } - - /** - * Tests the SDO 2.1 Sequence method for the - * java type of String - * - * String add(int index, String propertyName, Object value) - * - */ - public void testAddStringByIndexAndPropertyName() throws Exception { - - String testString1 = new String("String1"); - String testString2 = new String("String2"); - - //DataObject testString = testDataObject.getDataObject( "testString" ); - - Sequence testSequence = testDataObject.getSequence(); - assertEquals( 0, testSequence.size() ); - - testSequence.add("testString", new String("String1")); - testSequence.add("testString", new String("String2")); - testSequence.add("testString", new String("String1")); - - testSequence.add(1, "testString", new String("String1")); - - //Check the basic values - assertEquals( 4, testSequence.size() ); - assertTrue(testString1.equals(testSequence.getValue(0))); - assertTrue(testString1.equals(testSequence.getValue(1))); - assertTrue(testString2.equals(testSequence.getValue(2))); - assertTrue(testString1.equals(testSequence.getValue(3))); - - //Get the properties and check - //that everything is set. - - Property prop = testSequence.getProperty(0); - assertEquals( prop , testDataObject.getInstanceProperty("testString")); - prop = testSequence.getProperty(1); - assertEquals( prop , testDataObject.getInstanceProperty("testString")); - prop = testSequence.getProperty(2); - assertEquals( prop , testDataObject.getInstanceProperty("testString")); - - } - /** - * Tests the SDO 2.1 Sequence method for the - * java type of String - * - * String add(int index, Property property, Object value) - * - */ - public void testAddStringByIndexAndProperty() throws Exception { - - String testString1 = new String("String1"); - String testString2 = new String("String2"); - - Sequence testSequence = testDataObject.getSequence(); - assertEquals( 0, testSequence.size() ); - - Property prop = testDataObject.getProperty("testString"); - testSequence.add(0, prop, new String("String1")); - testSequence.add(1, prop, new String("String2")); - testSequence.add(2, prop, new String("String1")); - - //Check the basic value - assertEquals( 3, testSequence.size() ); - assertTrue(testString1.equals(testSequence.getValue(0))); - assertTrue(testString2.equals(testSequence.getValue(1))); - assertTrue(testString1.equals(testSequence.getValue(2))); - - //Get the properties and check - //that everything is set. - - prop = testSequence.getProperty(0); - assertEquals( prop , testDataObject.getInstanceProperty("testString")); - prop = testSequence.getProperty(1); - assertEquals( prop , testDataObject.getInstanceProperty("testString")); - prop = testSequence.getProperty(2); - assertEquals( prop , testDataObject.getInstanceProperty("testString")); - - } - - /** - * Tests the SDO 2.1 Sequence method for the - * java type of String - * - * String add(int index, int propertyIndex, Object value) - * - */ - public void testAddStringByIndexAndPropertyIndex() throws Exception { - - String testString1 = new String("String1"); - String testString2 = new String("String2"); - - //DataObject testString = testDataObject.getDataObject( "testString" ); - - Sequence testSequence = testDataObject.getSequence(); - assertEquals( 0, testSequence.size() ); - - testSequence.add(0, 1, new String("String1")); - testSequence.add(1, 1, new String("String2")); - testSequence.add(2, 1, new String("String1")); - - //Check the basic value - assertEquals( 3, testSequence.size() ); - assertTrue(testString1.equals(testSequence.getValue(0))); - assertTrue(testString2.equals(testSequence.getValue(1))); - assertTrue(testString1.equals(testSequence.getValue(2))); - - //Get the properties and check - //that everything is set. - - Property prop = testSequence.getProperty(0); - assertEquals( prop , testDataObject.getInstanceProperty("testString")); - prop = testSequence.getProperty(1); - assertEquals( prop , testDataObject.getInstanceProperty("testString")); - prop = testSequence.getProperty(2); - assertEquals( prop , testDataObject.getInstanceProperty("testString")); - - } -} |