diff options
Diffstat (limited to 'java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api')
36 files changed, 0 insertions, 7076 deletions
diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/CTSConsistencyBase.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/CTSConsistencyBase.java deleted file mode 100644 index 2c5a4d6754..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/CTSConsistencyBase.java +++ /dev/null @@ -1,57 +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: 537762 $ $Date: 2007-05-14 10:38:19 +0100 (Mon, 14 May 2007) $
- */
-package test.sdo21.tests.api;
-
-import org.junit.After;
-import org.junit.Before;
-
-import test.sdo21.framework.CTSTestCase;
-import test.sdo21.tests.TestData.StandardFactory;
-import test.sdo21.tests.TestData.TestDataFactory;
-
-import commonj.sdo.DataObject;
-
-/**
- * A class which supports the set of test classes which test for consistent behaviour of
- * the APIs when the metadata in use has been created by various means.
- *
- */
-public abstract class CTSConsistencyBase extends CTSTestCase {
- protected DataObject testDO;
- protected TestDataFactory factory;
- public abstract TestDataFactory createTestDataFactory();
-
- public CTSConsistencyBase() {
- factory = createTestDataFactory();
- }
-
- @Before
- public void setUp () throws Exception {
- super.setUp();
- factory.defineMetaData(getScope());
- testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE);
- }
-
- @After
- public void tearDown() throws Exception {
- super.tearDown();
- }
-}
diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/ChangeSummaryTest.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/ChangeSummaryTest.java deleted file mode 100644 index 9e31955d64..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/ChangeSummaryTest.java +++ /dev/null @@ -1,122 +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: 538928 $ $Date: 2007-05-17 15:00:54 +0100 (Thu, 17 May 2007) $
- */
-package test.sdo21.tests.api;
-
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import test.sdo21.framework.CTSTestCase;
-import test.sdo21.tests.TestData.StandardDynamicFactory;
-import test.sdo21.tests.TestData.StandardFactory;
-import test.sdo21.tests.TestData.TestDataFactory;
-
-import commonj.sdo.ChangeSummary;
-import commonj.sdo.DataGraph;
-import commonj.sdo.DataObject;
-import commonj.sdo.Type;
-import commonj.sdo.helper.HelperContext;
-import commonj.sdo.impl.HelperProvider;
-
-/**
- */
-public class ChangeSummaryTest extends CTSTestCase {
- private DataObject testDO;
- TestDataFactory factory;
-
- public ChangeSummaryTest() {
- factory = new StandardDynamicFactory();
- }
-
- @Before
- public void setUp () throws Exception {
- super.setUp();
- factory.defineMetaData(getScope());
- testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE);
- }
-
-
- @After
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
- /**
- * testGetChangeSummary performs some verification on the ChangeSummary
- * returned by DataGraph.getChangeSummary()
- */
- private void runChangeSummaryTests(DataGraph generatingDG) {
- ChangeSummary generatedCS = generatingDG.getChangeSummary();
-
- assertNotNull("DataGraph.getChangeSummary() returned a null ChangeSummary.", generatedCS);
-
- assertEquals("The ChangeSummary returned by DataGraph.getChangeSummary() did not return refer to the generating DataGraph.",
- generatedCS.getDataGraph(),
- generatingDG);
-
- assertEquals("The ChangeSummary returned by DataGraph.getChangeSummary() and the DataGraph have different root Objects. ",
- generatedCS.getRootObject(),
- generatingDG.getRootObject());
- }
-
- /**
- * Verify the proper function of DataGraph.getChangeSummary() when the
- * DataGraph RootObject was created by Type
- */
- @Test
- public void testDataGraphGetChangeSummaryType() {
- Type testType = testDO.getType();
-
- DataGraph dataGraph = getTestHelper().createDataGraph();
- dataGraph.createRootObject(testType);
-
- runChangeSummaryTests(dataGraph);
- }
-
- /**
- * Verify the proper function of DataGraph.getChangeSummary() when the
- * DataGraph RootObject was created by URI
- * @throws Exception
- */
- @Test
- public void testDataGraphGetChangeSummaryURI() throws Exception {
- // we are constrained to work with the default helper context for these APIs
- // so lets override the default behaviour of the test framework for this method
-
- HelperContext globalScope = HelperProvider.getDefaultContext();
- factory.defineMetaData(globalScope);
- testDO = factory.createTestData(globalScope, StandardFactory.API_TYPE);
-
- Type testType = testDO.getType();
-
- DataGraph dataGraph = getTestHelper().createDataGraph();
- dataGraph.createRootObject(testType.getURI(), testType.getName());
-
- runChangeSummaryTests(dataGraph);
- }
-
-
-
-}
diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/ContainmentCyclePreventionTest.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/ContainmentCyclePreventionTest.java deleted file mode 100644 index 85ad78e7ba..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/ContainmentCyclePreventionTest.java +++ /dev/null @@ -1,481 +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.api; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Enclosed; -import org.junit.runners.Suite; - -import test.sdo21.tests.TestData.StandardDynamicFactory; -import test.sdo21.tests.TestData.StandardFactory; -import test.sdo21.tests.TestData.StandardXSDFactory; -import test.sdo21.tests.TestData.TestDataFactory; - -import commonj.sdo.DataObject; -import commonj.sdo.Sequence; - -/** - * Tests prevdention of containment cycles. Each test passes if the method call that - * would result in a containment cycle throws an IllegalArgumentException and does - * not allow the formation of containment cycle. There is a test case for - * each of the various mechanisms through which a containment cycle may be created. - */ -public abstract class ContainmentCyclePreventionTest extends CTSConsistencyBase { - - public ContainmentCyclePreventionTest() { - } - - public static class DynamicMetadata extends ContainmentCyclePreventionTest { - public DynamicMetadata() { - - } - public TestDataFactory createTestDataFactory() { - - return new StandardDynamicFactory(); - } - } - - public static class XSDMetadata extends ContainmentCyclePreventionTest { - - public XSDMetadata() { - } - - public TestDataFactory createTestDataFactory() { - - return new StandardXSDFactory(); - } - } - - - @Before - public void setUp () throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - super.tearDown(); - } - - /** - * Attempt to create a 1-Member Containment Cycle using set____ on a single valued property - * and verify the behavior of the method. - * @throws Exception - */ - @Test - public void oneMemberSingleValueSetDataObject() throws Exception { - DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.API_TYPE); - - setSingleValueOneMember(dataObj1); - } - - /** - * Attempt to create an n-Member Containment Cycle using set____ on a single valued property - * and verify the behavior of the method. - * @throws Exception - */ - @Test - public void nMemberSingleValueSetDataObject() throws Exception { - DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.API_TYPE); - DataObject dataObj2 = factory.createTestData(getScope(), StandardFactory.API_TYPE); - DataObject dataObj3 = factory.createTestData(getScope(), StandardFactory.API_TYPE); - - setSingleValueNMember(dataObj1, dataObj2, dataObj3); - } - - /** - * Attempt to create a 1-Member Containment Cycle using set____ on a multi valued property - * and verify the behavior of the method. - * @throws Exception - */ - @Test - public void oneMemberMultiValueSetDataObject() throws Exception { - DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.API_TYPE); - DataObject dataObj2 = factory.createTestData(getScope(), StandardFactory.API_TYPE); - DataObject dataObj3 = factory.createTestData(getScope(), StandardFactory.API_TYPE); - - setMultiValueOneMember(dataObj1, dataObj2, dataObj3); - } - - /** - * Attempt to create an n-Member Containment Cycle using set____ on a multi valued property - * and verify the behavior of the method. - * @throws Exception - */ - @Test - public void nMemberMultiValueSetDataObject() throws Exception { - DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.API_TYPE); - DataObject dataObj2 = factory.createTestData(getScope(), StandardFactory.API_TYPE); - DataObject dataObj3 = factory.createTestData(getScope(), StandardFactory.API_TYPE); - - setManyValueNMember(dataObj1, dataObj2, dataObj3); - } - - /** - * Attempt to create a 1-Member Containment Cycle by making updates to a List returned - * from the DataObject and verify the behavior of the method. This is the static version - * of this test case. - * @throws Exception - */ - @Test - public void oneMemberReturnedList() throws Exception { - DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.API_TYPE); - - returnedListOneMember(dataObj1); - } - - /** - * Attempt to create an n-Member Containment Cycle by making updates to a List returned - * from the DataObject and verify the behavior of the method. This is the static version - * of this test case. - * @throws Exception - */ - @Test - public void nMemberReturnedList() throws Exception { - DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.API_TYPE); - DataObject dataObj2 = factory.createTestData(getScope(), StandardFactory.API_TYPE); - DataObject dataObj3 = factory.createTestData(getScope(), StandardFactory.API_TYPE); - - returnedListNMember(dataObj1, dataObj2, dataObj3); - } - - /** - * Attempt to create a 1-Member Containment Cycle using by using a Sequence to make updates - * to the DataObject, affecting a single valued property, and verify the behavior of - * the method. - * @throws Exception - */ - @Test - public void oneMemberSingleValueSequence() throws Exception { - DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE); - - sequenceSingleValueOneMember(dataObj1); - } - - /** - * Attempt to create an n-Member Containment Cycle using by using a Sequence to make updates - * to the DataObject, affecting a single valued property, and verify the behavior of - * the method. - * @throws Exception - */ - @Test - public void nMemberSingleValueSequence() throws Exception { - DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE);; - DataObject dataObj2 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE);; - DataObject dataObj3 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE);; - - sequenceSingleValueNMember(dataObj1, dataObj2, dataObj3); - } - - /** - * Attempt to create a 1-Member Containment Cycle using by using a Sequence to make updates - * to the DataObject, affecting a multi valued property, and verify the behavior of - * the method. - * @throws Exception - */ - @Test - public void oneMemberMultiValueSequence() throws Exception { - DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE);; - DataObject dataObj2 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE);; - DataObject dataObj3 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE);; - - sequenceMultiValueOneMember(dataObj1, dataObj2, dataObj3); - } - - /** - * Attempt to create an n-Member Containment Cycle using by using a Sequence to make updates - * to the DataObject, affecting a multi valued property, and verify the behavior of - * the method. - * @throws Exception - */ - @Test - public void nMemberMultiValueSequence() throws Exception { - DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE);; - DataObject dataObj2 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE);; - DataObject dataObj3 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE);; - - sequenceManyValueNMember(dataObj1, dataObj2, dataObj3); - } - - /** - * Returns true if input DataObject root is part of a containment cycle, - * false otherwise. - * @param root - * @return - */ - private static boolean containmentCycleExists (DataObject root) - { - DataObject curr = root.getContainer(); - - while (curr != null) - { - if (curr == root) - return true; - - curr = curr.getContainer(); - } - return false; - } - - /** - * Use setDataObject to create a one member containment cycle. - * @param dataObj1 - */ - private void setSingleValueOneMember(DataObject dataObj1) { - try { - dataObj1.setDataObject("contain", dataObj1); - - if (containmentCycleExists(dataObj1)) - fail("Attempting to create a containment cycle should result in an Exception."); - else - fail("Containment cycle was neither created nor prevented."); - } catch (Exception e) { - // do nothing - success - } - } - - /** - * Use setDataObject to create an N-member containment cycle. - * @param dataObj1 - * @param dataObj2 - * @param dataobj3 - */ - private void setSingleValueNMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) { - dataObj1.setDataObject("contain", dataObj2); - dataObj2.setDataObject("contain", dataObj3); - - try { - dataObj3.setDataObject("contain", dataObj1); - if (containmentCycleExists(dataObj1)) - fail("Attempting to create a containment cycle should result in an Exception."); - else - fail("Containment cycle was neither created nor prevented."); - } catch (Exception e) { - // do nothing - success - } - } - - /** - * Use setList to create a one member containment cycle. - * @param dataObj1 - * @param dataObj2 - * @param dataObj3 - */ - private void setMultiValueOneMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) { - List addList = new ArrayList(); - addList.add(dataObj2); - addList.add(dataObj1); - addList.add(dataObj3); - - try { - dataObj1.setList("containMany", addList); - if (containmentCycleExists(dataObj1)) - fail("Attempting to create a containment cycle should result in an Exception."); - else - fail("Containment cycle was neither created nor prevented."); - } catch (Exception e) { - // do nothing - success - } - } - - /** - * Use setList to create an N-member containment cycle. - * @param dataObj1 - * @param dataObj2 - * @param dataObj3 - */ - private void setManyValueNMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) { - List addList = new ArrayList(); - - dataObj1.setDataObject("contain", dataObj2); - dataObj2.setDataObject("contain", dataObj3); - addList.add(dataObj1); - - try { - dataObj3.setList("containMany", addList); - if (containmentCycleExists(dataObj1)) - fail("Attempting to create a containment cycle should result in an Exception."); - else - fail("Containment cycle was neither created nor prevented."); - } catch (Exception e) { - // do nothing - success - } - } - - /** - * Create a 1-member containment cycle by making updates to a returned List. - * @param dataObj1 - */ - private void returnedListOneMember(DataObject dataObj1) { - List returnedList = dataObj1.getList("containMany"); - - try { - returnedList.add(dataObj1); - if (containmentCycleExists(dataObj1)) - fail("Attempting to create a containment cycle should result in an Exception."); - else - fail("Containment cycle was neither created nor prevented."); - } catch (Exception e) { - // do nothing - success - } - } - - /** - * Create an n-member containment cycle by making updates to a returned List. - * @param dataObj1 - * @param dataObj2 - * @param dataobj3 - */ - private void returnedListNMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) { - dataObj1.setDataObject("contain", dataObj2); - dataObj2.setDataObject("contain", dataObj3); - - List returnedList = dataObj3.getList("containMany"); - - try { - returnedList.add(dataObj1); - if (containmentCycleExists(dataObj1)) - fail("Attempting to create a containment cycle should result in an Exception."); - else - fail("Containment cycle was neither created nor prevented."); - } catch (Exception e) { - // do nothing - success - } - } - - /** - * Create a 1-member containment cycle by making updates to a Sequence. - * The data member in this case is single valued. - * @param dataObj1 - * @param dataObj2 - * @param dataObj3 - */ - private void sequenceSingleValueOneMember(DataObject dataObj1) { - assertTrue("DataObject is not Sequenced. Test case may not proceed.", dataObj1.getType().isSequenced()); - - Sequence sequence = dataObj1.getSequence(); - - try { - sequence.add("contain", dataObj1); - if (containmentCycleExists(dataObj1)) - fail("Attempting to create a containment cycle should result in an Exception."); - else - fail("Containment cycle was neither created nor prevented."); - } catch (Exception e) { - // do nothing - success - } - - } - - /** - * Create an n-member containment cycle by making updates to a Sequence. - * The data member in this case is single valued. - * @param dataObj1 - * @param dataObj2 - * @param dataObj3 - */ - private void sequenceSingleValueNMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) { - assertTrue("DataObject is not Sequenced. Test case may not proceed.", dataObj1.getType().isSequenced()); - - Sequence sequence1 = dataObj1.getSequence(); - Sequence sequence2 = dataObj2.getSequence(); - Sequence sequence3 = dataObj3.getSequence(); - - sequence1.add("contain", (Object) dataObj2); - sequence2.add("contain", (Object) dataObj3); - - - try { - sequence3.add("contain", (Object) dataObj1); - if (containmentCycleExists(dataObj1)) - fail("Attempting to create a containment cycle should result in an Exception."); - else - fail("Containment cycle was neither created nor prevented."); - } catch (Exception e) { - // do nothing - success - } - } - - /** - * Create a 1-member containment cycle by making updates to a Sequence. - * The data member in this case is many valued. - * @param dataObj1 - * @param dataObj2 - * @param dataObj3 - */ - private void sequenceMultiValueOneMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) { - assertTrue("DataObject is not Sequenced. Test case may not proceed.", dataObj1.getType().isSequenced()); - - Sequence sequence = dataObj1.getSequence(); - - sequence.add("containMany", dataObj2); - sequence.add("containMany", dataObj3); - - try { - sequence.add("containMany", dataObj1); - if (containmentCycleExists(dataObj1)) - fail("Attempting to create a containment cycle should result in an Exception."); - else - fail("Containment cycle was neither created nor prevented."); - } catch (Exception e) { - // do nothing - success - } - } - - /** - * Create an n-member containment cycle by making updates to a Sequence. - * The data member in this case is many valued. - * @param dataObj1 - * @param dataObj2 - * @param dataObj3 - */ - private void sequenceManyValueNMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) { - assertTrue("DataObject is not Sequenced. Test case may not proceed.", dataObj1.getType().isSequenced()); - - List addList = new ArrayList(); - - addList.add(dataObj2); - dataObj1.setList("containMany", addList); - - addList.clear(); - addList.add(dataObj3); - dataObj2.setList("containMany", addList); - - Sequence sequence = dataObj3.getSequence(); - - try { - sequence.add("containMany", dataObj1); - if (containmentCycleExists(dataObj1)) - fail("Attempting to create a containment cycle should result in an Exception."); - else - fail("Containment cycle was neither created nor prevented."); - } catch (Exception e) { - // do nothing - success - } - } -} diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/ContainmentCycleSerializationTest.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/ContainmentCycleSerializationTest.java deleted file mode 100644 index 47900402bf..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/ContainmentCycleSerializationTest.java +++ /dev/null @@ -1,495 +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.api; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.ByteArrayOutputStream; -import java.util.ArrayList; -import java.util.List; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import test.sdo21.tests.TestData.StandardDynamicFactory; -import test.sdo21.tests.TestData.StandardFactory; -import test.sdo21.tests.TestData.StandardXSDFactory; -import test.sdo21.tests.TestData.TestDataFactory; -import test.sdo21.tests.util.CTSUtil; - -import commonj.sdo.DataObject; -import commonj.sdo.Sequence; -import commonj.sdo.helper.HelperContext; - -/** - * Tests serialization of containment cycles. Each test passes if the serialization does - * not generate output representing the containment cycle. There is a test case for - * each of the various mechanisms through which a containment cycle may be created and serialized. - * - * Note also that Java serialization of a containment cycle should result in an IllegalStateException, - * while XMLHelper and XMLStreamHelper serialization should successfully serialize the DataObject - * absent the containment cycle. - */ -public abstract class ContainmentCycleSerializationTest extends CTSConsistencyBase { - - - public ContainmentCycleSerializationTest() { - } - - public static class DynamicMetadata extends ContainmentCycleSerializationTest { - public DynamicMetadata() { - - } - public TestDataFactory createTestDataFactory() { - - return new StandardDynamicFactory(); - } - } - - public static class XSDMetadata extends ContainmentCycleSerializationTest { - - public XSDMetadata() { - } - - public TestDataFactory createTestDataFactory() { - - return new StandardXSDFactory(); - } - } - - - @Before - public void setUp () throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - super.tearDown(); - } - - - /** - * Attempt to create a 1-Member Containment Cycle using set____ on a single valued property - * and verify the behavior of serialization. - * @throws Exception - */ - @Test - public void oneMemberSingleValueSetDataObject() throws Exception { - DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.API_TYPE); - setSingleValueOneMember(dataObj1); - attemptSerialization(dataObj1, getScope()); - } - - /** - * Attempt to create an n-Member Containment Cycle using set____ on a single valued property - * and verify the behavior of serialization. - * @throws Exception - */ - @Test - public void nMemberSingleValueSetDataObject() throws Exception { - DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.API_TYPE); - DataObject dataObj2 = factory.createTestData(getScope(), StandardFactory.API_TYPE); - DataObject dataObj3 = factory.createTestData(getScope(), StandardFactory.API_TYPE); - - setSingleValueNMember(dataObj1, dataObj2, dataObj3); - attemptSerialization(dataObj1, getScope()); - } - - /** - * Attempt to create a 1-Member Containment Cycle using set____ on a multi valued property - * and verify the behavior of serialization. - * @throws Exception - */ - @Test - public void oneMemberMultiValueSetDataObject() throws Exception { - DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.API_TYPE); - DataObject dataObj2 = factory.createTestData(getScope(), StandardFactory.API_TYPE); - DataObject dataObj3 = factory.createTestData(getScope(), StandardFactory.API_TYPE); - - setMultiValueOneMember(dataObj1, dataObj2, dataObj3); - attemptSerialization(dataObj1, getScope()); - } - - /** - * Attempt to create an n-Member Containment Cycle using set____ on a multi valued property - * and verify the behavior of serialization. - * @throws Exception - */ - @Test - public void nMemberMultiValueSetDataObject() throws Exception { - DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.API_TYPE); - DataObject dataObj2 = factory.createTestData(getScope(), StandardFactory.API_TYPE); - DataObject dataObj3 = factory.createTestData(getScope(), StandardFactory.API_TYPE); - - setManyValueNMember(dataObj1, dataObj2, dataObj3); - attemptSerialization(dataObj1, getScope()); - } - - /** - * Attempt to create a 1-Member Containment Cycle by making updates to a List returned - * from the DataObject and verify the behavior of serialization. This is the static version - * of this test case. - * @throws Exception - */ - @Test - public void oneMemberReturnedList() throws Exception { - DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.API_TYPE); - - returnedListOneMember(dataObj1); - attemptSerialization(dataObj1, getScope()); - } - - /** - * Attempt to create an n-Member Containment Cycle by making updates to a List returned - * from the DataObject and verify the behavior of serialization. This is the static version - * of this test case. - * @throws Exception - */ - @Test - public void nMemberReturnedList() throws Exception { - DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.API_TYPE); - DataObject dataObj2 = factory.createTestData(getScope(), StandardFactory.API_TYPE); - DataObject dataObj3 = factory.createTestData(getScope(), StandardFactory.API_TYPE); - - returnedListNMember(dataObj1, dataObj2, dataObj3); - attemptSerialization(dataObj1, getScope()); - } - - /** - * Attempt to create a 1-Member Containment Cycle using by using a Sequence to make updates - * to the DataObject, affecting a single valued property, and verify the behavior of - * serialization. - * @throws Exception - */ - @Test - public void oneMemberSingleValueSequence() throws Exception { - DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE); - - sequenceSingleValueOneMember(dataObj1); - attemptSerialization(dataObj1, getScope()); - } - - /** - * Attempt to create an n-Member Containment Cycle using by using a Sequence to make updates - * to the DataObject, affecting a single valued property, and verify the behavior of - * serialization. - * @throws Exception - */ - @Test - public void nMemberSingleValueSequence() throws Exception { - DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE); - DataObject dataObj2 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE); - DataObject dataObj3 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE); - - sequenceSingleValueNMember(dataObj1, dataObj2, dataObj3); - attemptSerialization(dataObj1, getScope()); - } - - /** - * Attempt to create a 1-Member Containment Cycle using by using a Sequence to make updates - * to the DataObject, affecting a multi valued property, and verify the behavior of - * serialization. - * @throws Exception - */ - @Test - public void oneMemberMultiValueSequence() throws Exception { - DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE); - DataObject dataObj2 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE); - DataObject dataObj3 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE); - - sequenceMultiValueOneMember(dataObj1, dataObj2, dataObj3); - attemptSerialization(dataObj1, getScope()); - } - - /** - * Attempt to create an n-Member Containment Cycle using by using a Sequence to make updates - * to the DataObject, affecting a multi valued property, and verify the behavior of - * serialization. - * @throws Exception - */ - @Test - public void nMemberMultiValueSequence() throws Exception { - DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE); - DataObject dataObj2 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE); - DataObject dataObj3 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE); - - sequenceManyValueNMember(dataObj1, dataObj2, dataObj3); - attemptSerialization(dataObj1, getScope()); - } - - /** - * Attempt to serialize the DataObject in via XML, XMLStreamHelper, - * and Java serialization. - * @param dataObj - */ - private void attemptSerialization(DataObject dataObj, HelperContext scope) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - assertTrue("Containment cycle was not established.", - containmentCycleExists(dataObj)); - try { - CTSUtil.serializeDataObjectXML(dataObj, baos, scope); - } catch (Exception e) { - fail("XML serialization of a containment cycle resulted in a(n) " + e.getClass().getName() + "."); - e.printStackTrace(); - } - - assertTrue("Containment cycle was affected by XMLHelper serialization.", - containmentCycleExists(dataObj)); - - try { - CTSUtil.serializeDataObjectJava(getTestHelper(), dataObj, baos, scope); - fail("Java serialization of a containment cycle should result in an IllegalStateException."); - } catch (Exception e) { - // Do nothing. An Exception is expected in this case. - } - - assertTrue("Containment cycle was affected by Java serialization.", - containmentCycleExists(dataObj)); - - // try { - // ParamatizedTestUtil.serializeDataObjectStream(dataObj, baos, scope); - // } catch (Exception e) { - // fail("XMLStreamHelper serialization of a containment cycle resulted in a(n) " + e.getClass().getName() + "."); - // e.printStackTrace(); - // } - - // assertTrue("Containment cycle was affected by XMLStreamHelper serialization.", - // containmentCycleExists(dataObj)); - } - - /** - * Returns true if input DataObject root is part of a containment cycle, - * false otherwise. - * @param root - * @return - */ - private static boolean containmentCycleExists (DataObject root) - { - DataObject curr = root.getContainer(); - - while (curr != null) - { - if (curr == root) - return true; - - curr = curr.getContainer(); - } - return false; - } - - /** - * Use setDataObject to create a one member containment cycle. - * @param dataObj1 - */ - private void setSingleValueOneMember(DataObject dataObj1) { - try { - dataObj1.setDataObject("contain", dataObj1); - } catch (Exception e) { - // do nothing - success - } - } - - /** - * Use setDataObject to create an N-member containment cycle. - * @param dataObj1 - * @param dataObj2 - * @param dataobj3 - */ - private void setSingleValueNMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) { - dataObj1.setDataObject("contain", dataObj2); - dataObj2.setDataObject("contain", dataObj3); - - try { - dataObj3.setDataObject("contain", dataObj1); - } catch (Exception e) { - // do nothing - success - } - } - - /** - * Use setList to create a one member containment cycle. - * @param dataObj1 - * @param dataObj2 - * @param dataObj3 - */ - private void setMultiValueOneMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) { - List addList = new ArrayList(); - addList.add(dataObj2); - addList.add(dataObj1); - addList.add(dataObj3); - - try { - dataObj1.setList("containMany", addList); - } catch (Exception e) { - // do nothing - success - } - } - - /** - * Use setList to create an N-member containment cycle. - * @param dataObj1 - * @param dataObj2 - * @param dataObj3 - */ - private void setManyValueNMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) { - List addList = new ArrayList(); - - dataObj1.setDataObject("contain", dataObj2); - dataObj2.setDataObject("contain", dataObj3); - addList.add(dataObj1); - - try { - dataObj3.setList("containMany", addList); - } catch (Exception e) { - // do nothing - success - } - } - - /** - * Create a 1-member containment cycle by making updates to a returned List. - * @param dataObj1 - */ - private void returnedListOneMember(DataObject dataObj1) { - List returnedList = dataObj1.getList("containMany"); - - try { - returnedList.add(dataObj1); - } catch (Exception e) { - // do nothing - success - } - } - - /** - * Create an n-member containment cycle by making updates to a returned List. - * @param dataObj1 - * @param dataObj2 - * @param dataobj3 - */ - private void returnedListNMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) { - dataObj1.setDataObject("contain", dataObj2); - dataObj2.setDataObject("contain", dataObj3); - - List returnedList = dataObj3.getList("containMany"); - - try { - returnedList.add(dataObj1); - } catch (Exception e) { - // do nothing - success - } - } - - /** - * Create a 1-member containment cycle by making updates to a Sequence. - * The data member in this case is single valued. - * @param dataObj1 - * @param dataObj2 - * @param dataObj3 - */ - private void sequenceSingleValueOneMember(DataObject dataObj1) { - assertTrue("DataObject is not Sequenced. Test case may not proceed.", dataObj1.getType().isSequenced()); - - Sequence sequence = dataObj1.getSequence(); - - try { - sequence.add("contain", dataObj1); - } catch (Exception e) { - // do nothing - success - } - - } - - /** - * Create an n-member containment cycle by making updates to a Sequence. - * The data member in this case is single valued. - * @param dataObj1 - * @param dataObj2 - * @param dataObj3 - */ - private void sequenceSingleValueNMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) { - assertTrue("DataObject is not Sequenced. Test case may not proceed.", dataObj1.getType().isSequenced()); - - Sequence sequence1 = dataObj1.getSequence(); - Sequence sequence2 = dataObj2.getSequence(); - Sequence sequence3 = dataObj3.getSequence(); - - sequence1.add("contain", (Object) dataObj2); - sequence2.add("contain", (Object) dataObj3); - - - try { - sequence3.add("contain", (Object) dataObj1); - } catch (Exception e) { - // do nothing - success - } - } - - /** - * Create a 1-member containment cycle by making updates to a Sequence. - * The data member in this case is many valued. - * @param dataObj1 - * @param dataObj2 - * @param dataObj3 - */ - private void sequenceMultiValueOneMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) { - assertTrue("DataObject is not Sequenced. Test case may not proceed.", dataObj1.getType().isSequenced()); - - Sequence sequence = dataObj1.getSequence(); - - sequence.add("containMany", dataObj2); - sequence.add("containMany", dataObj3); - - try { - sequence.add("containMany", dataObj1); - } catch (Exception e) { - // do nothing - success - } - } - - /** - * Create an n-member containment cycle by making updates to a Sequence. - * The data member in this case is many valued. - * @param dataObj1 - * @param dataObj2 - * @param dataObj3 - */ - private void sequenceManyValueNMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) { - assertTrue("DataObject is not Sequenced. Test case may not proceed.", dataObj1.getType().isSequenced()); - - List addList = new ArrayList(); - - addList.add(dataObj2); - dataObj1.setList("containMany", addList); - - addList.clear(); - addList.add(dataObj3); - dataObj2.setList("containMany", addList); - - Sequence sequence = dataObj3.getSequence(); - - try { - sequence.add("containMany", dataObj1); - } catch (Exception e) { - // do nothing - success - } - } -} diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/CopyHelper/CopyEqualityTest.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/CopyHelper/CopyEqualityTest.java deleted file mode 100644 index 7c49576557..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/CopyHelper/CopyEqualityTest.java +++ /dev/null @@ -1,148 +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.CopyHelper; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import test.sdo21.tests.TestData.StandardDynamicFactory; -import test.sdo21.tests.TestData.StandardFactory; -import test.sdo21.tests.TestData.StandardXSDFactory; -import test.sdo21.tests.TestData.TestDataFactory; -import test.sdo21.tests.api.CTSConsistencyBase; - -import commonj.sdo.DataObject; -import commonj.sdo.helper.EqualityHelper; - -/** - * TestCase tests shallow and deep copy functions of CopyHelper utilizing the - * EqualityHelper class. Can be used to test dynamic, mixed and static - * DataObjects - * TODO this would be better as a test of CopyHelper alone, having established - * EqualityHelper as a trusted base by independent testing. As it stands it - * does not identify whether issues exist in the copy helper or the equality helper - */ -public abstract class CopyEqualityTest extends CTSConsistencyBase { - private DataObject testDO; - - public CopyEqualityTest() { - } - - public static class DynamicMetadata extends CopyEqualityTest { - public DynamicMetadata() { - - } - public TestDataFactory createTestDataFactory() { - - return new StandardDynamicFactory(); - } - } - - public static class XSDMetadata extends CopyEqualityTest { - - public XSDMetadata() { - } - - public TestDataFactory createTestDataFactory() { - - return new StandardXSDFactory(); - } - } - - - @After - public void tearDown() throws Exception { - super.tearDown(); - } - - - @Before - public void setUp () throws Exception { - super.setUp(); - testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE); - ((StandardFactory)factory).populateFields(testDO, getScope()); - } - - /** - * Performs a shallow copy and verifies that shallow equality is true - * between the source and output for the copy. - */ - @Test - public void testShallowCopyShallowEquality() { - assertNotNull("data object not created correctly", testDO); - DataObject shallowCopy = getScope().getCopyHelper().copyShallow(testDO); - - EqualityHelper equalityH = getScope().getEqualityHelper(); - - assertTrue("Shallow copy did not result in shallow equality", equalityH.equalShallow(testDO, shallowCopy)); - } - - /** - * Performs a shallow copy and verifies that deep equality is false - * (assuming passed DO includes a containment reference) between the source - * and output for the copy. - */ - @Test - public void testShallowCopyDeepEquality() { - assertNotNull("data object not created correctly", testDO); - DataObject shallowCopy = getScope().getCopyHelper().copyShallow(testDO); - - EqualityHelper equalityH = getScope().getEqualityHelper(); - - // TODO: Determine why Deep equality results when Type is sequenced. - - assertFalse("Shallow copy should not result in deep equality for this Type.", equalityH.equal(testDO, - shallowCopy)); - } - - /** - * Performs a deep copy and verifies that shallow equality exists between - * the source and output from the copy. - */ - @Test - public void testDeepCopyShallowEquality() { - assertNotNull("data object not created correctly", testDO); - DataObject deepCopy = getScope().getCopyHelper().copy(testDO); - - EqualityHelper equalityH = getScope().getEqualityHelper(); - - assertTrue("Deep copy did not result in shallow equality.", equalityH.equalShallow(testDO, deepCopy)); - } - - /** - * Performs a deep copy and verifies that deep equality exists between the - * source and output from the copy. - */ - @Test - public void testDeepCopyDeepEquality() { - assertNotNull("data object not created correctly", testDO); - DataObject deepCopy = getScope().getCopyHelper().copy(testDO); - - EqualityHelper equalityH = getScope().getEqualityHelper(); - - assertTrue("Deep copy did not result in deep equality.", equalityH.equal(testDO, deepCopy)); - } -} diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataFactory/DataFactoryConsistencyBase.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataFactory/DataFactoryConsistencyBase.java deleted file mode 100644 index cc32e6a0cb..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataFactory/DataFactoryConsistencyBase.java +++ /dev/null @@ -1,139 +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: 537762 $ $Date: 2007-05-14 10:38:19 +0100 (Mon, 14 May 2007) $
- */
-package test.sdo21.tests.api.DataFactory;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import test.sdo21.tests.TestData.StandardFactory;
-import test.sdo21.tests.api.CTSConsistencyBase;
-import test.sdo21.tests.util.CTSUtil;
-
-import commonj.sdo.DataObject;
-import commonj.sdo.Type;
-
-public abstract class DataFactoryConsistencyBase extends CTSConsistencyBase {
-
-
- @Before
- public void setUp () throws Exception {
- super.setUp();
- }
-
- @After
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
- /**
- * Verify the proper operation of DataFactory.create(Type).
- */
- @Test
- public void testDataFactoryCreateByType() {
- Type type = testDO.getType();
-
- DataObject typeDO = getScope().getDataFactory().create(type);
-
- assertNotNull("DataFactory.create(Type) did not return a DataObject as expected", typeDO);
-
- assertTrue("DataFactory.create(Type) did not return a DataObject of the expected Type.", CTSUtil.areEqualTypes(typeDO.getType(), type));
- }
-
- /**
- * Verify the proper operation of DataFactory.create(URI, Name).
- */
- @Test
- public void testDataFactoryCreateByURI() {
- Type type = testDO.getType();
-
- DataObject uriDO = getScope().getDataFactory().create(type.getURI(), type.getName());
-
- assertNotNull("DataFactory.create(URI, Name) did not return a DataObject as expected.", uriDO);
-
- assertTrue("DataFactory.create(URI, Name) did not return a DataObject of the expected Type.",
- CTSUtil.areEqualTypes(uriDO.getType(), type));
- }
-
- /**
- * Verify the proper operation of DataFactory.create(Class).
- */
- @Test
- public void testDataFactoryCreateByClass() {
- Type type = testDO.getType();
-
- if (type.getInstanceClass() != null) {
- DataObject classDO = getScope().getDataFactory().create(type.getInstanceClass());
-
- assertNotNull("DataFactory.create(Class) did not return a DataObject as expected.", classDO);
-
- assertTrue("DataFactory.create(Class) did not return a DataObject of the expected Type.",
- CTSUtil.areEqualTypes(classDO.getType(), type));
- }
- }
-
- /**
- * Verify that DataFactory.create with DataType results in
- * IllegalArgumentException
- */
- @Test
- public void testDataFactoryCreateDataTypeException() {
- try {
- Type dataType = getScope().getTypeHelper().getType("commonj.sdo", "Int");
- assertTrue("Could not test DataFactory.create(dataType) because dataType.isDataType = false", dataType
- .isDataType());
- getScope().getDataFactory().create(dataType);
- fail("DataFactory.create(dataType) did not throw an Exception.");
- } catch (IllegalArgumentException e) {
- // Do nothing
- } catch (Exception e) {
- fail("DataFactory.create(dataType) did not throw the expected IllegalArgumentException Exception.");
- }
- }
-
- /**
- * Verify that DataFactory.create with Abstract Type results in
- * IllegalArgumentException.
- */
- @Test
- public void testDataFactoryCreateAbstractException() {
- try {
- Type abstractType =
- getScope().getTypeHelper().getType(StandardFactory.TEST_NAMESPACE, "Abstract");
-
- assertTrue("Could not test DataFactory.create(abstractType) because abstractType.isAbstract = false",
- abstractType.isAbstract());
- getScope().getDataFactory().create(abstractType);
- fail("DataFactory.create(abstractType) did not throw an Exception.");
-
- } catch (IllegalArgumentException e) {
- // Do nothing
- } catch (Exception e) {
- fail("DataFactory.create(abstractType) did not throw the expected IllegalArgumentException Exception.");
- }
- }
-
-
-}
diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataFactory/DataFactoryConsistencyDynamic.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataFactory/DataFactoryConsistencyDynamic.java deleted file mode 100644 index d283d759ec..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataFactory/DataFactoryConsistencyDynamic.java +++ /dev/null @@ -1,34 +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: 537762 $ $Date: 2007-05-14 10:38:19 +0100 (Mon, 14 May 2007) $
- */
-package test.sdo21.tests.api.DataFactory;
-
-import test.sdo21.tests.TestData.StandardDynamicFactory;
-import test.sdo21.tests.TestData.TestDataFactory;
-
-public class DataFactoryConsistencyDynamic extends DataFactoryConsistencyBase {
-
- public TestDataFactory createTestDataFactory() {
-
- return new StandardDynamicFactory();
- }
-
-
-}
diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataFactory/DataFactoryConsistencySuite.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataFactory/DataFactoryConsistencySuite.java deleted file mode 100644 index 0bc165b725..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataFactory/DataFactoryConsistencySuite.java +++ /dev/null @@ -1,31 +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: 537762 $ $Date: 2007-05-14 10:38:19 +0100 (Mon, 14 May 2007) $
- */
-package test.sdo21.tests.api.DataFactory;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses( {DataFactoryConsistencyDynamic.class,
- DataFactoryConsistencyXSD.class})
-public class DataFactoryConsistencySuite {
-
-}
diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataFactory/DataFactoryConsistencyXSD.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataFactory/DataFactoryConsistencyXSD.java deleted file mode 100644 index 3572d63c68..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataFactory/DataFactoryConsistencyXSD.java +++ /dev/null @@ -1,34 +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: 537762 $ $Date: 2007-05-14 10:38:19 +0100 (Mon, 14 May 2007) $
- */
-package test.sdo21.tests.api.DataFactory;
-
-import test.sdo21.tests.TestData.StandardXSDFactory;
-import test.sdo21.tests.TestData.TestDataFactory;
-
-public class DataFactoryConsistencyXSD extends DataFactoryConsistencyBase {
-
- public TestDataFactory createTestDataFactory() {
-
- return new StandardXSDFactory();
- }
-
-
-}
diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataGraph/DataGraphConsistencyBase.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataGraph/DataGraphConsistencyBase.java deleted file mode 100644 index c5c488e709..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataGraph/DataGraphConsistencyBase.java +++ /dev/null @@ -1,147 +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: 536535 $ $Date: 2007-05-09 15:04:49 +0100 (Wed, 09 May 2007) $
- */
-package test.sdo21.tests.api.DataGraph;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import test.sdo21.tests.TestData.StandardFactory;
-import test.sdo21.tests.api.CTSConsistencyBase;
-
-import commonj.sdo.DataGraph;
-import commonj.sdo.DataObject;
-import commonj.sdo.Type;
-import commonj.sdo.helper.HelperContext;
-import commonj.sdo.impl.HelperProvider;
-
-public abstract class DataGraphConsistencyBase extends CTSConsistencyBase {
-
-
- @Before
- public void setUp () throws Exception {
- super.setUp();
- }
-
- @After
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
- /**
- * Verify the proper function of DataGraph.createRootObject(Type).
- */
- @Test
- public void testCreateRootObjectByType() {
- Type testType = testDO.getType();
-
- DataGraph dataGraph = getTestHelper().createDataGraph();
- DataObject rootDO = dataGraph.createRootObject(testType);
-
- assertEquals("DataObject.getDataGraph() did not return the expected DataGraph.",
- rootDO.getDataGraph(),
- dataGraph);
-
- assertEquals("DataGraph.getRootObject() did not return the expected DataObject.",
- dataGraph.getRootObject(),
- rootDO);
- }
-
- /**
- * Verify the proper function of DataGraph.createRootObject(URI,Name).
- * @throws Exception
- */
- @Test
- public void testCreateRootObjectByURI() throws Exception {
- // we are constrained to work with the default helper context for these APIs
- // so lets override the default behaviour of the test framework for this method
-
- HelperContext globalScope = HelperProvider.getDefaultContext();
- factory.defineMetaData(globalScope);
- testDO = factory.createTestData(globalScope, StandardFactory.API_TYPE);
- Type testType = testDO.getType();
-
- DataGraph dataGraph = getTestHelper().createDataGraph();
- DataObject rootDO = dataGraph.createRootObject(testType.getURI(), testType.getName());
-
- assertEquals("DataObject.getDataGraph() did not return the expected DataGraph.",
- rootDO.getDataGraph(),
- dataGraph);
-
- assertEquals("DataGraph.getRootObject() did not return the expected DataObject.",
- dataGraph.getRootObject(),
- rootDO);
- }
-
-
-
- /**
- * Verify the proper function of DataGraph.getType(URI, Name) when the
- * DataGraph RootObject was created by Type
- * @throws Exception
- */
- @Test
- public void testDataGraphGetType() throws Exception {
- // we are constrained to work with the default helper context for these APIs
- // so lets override the default behaviour of the test framework for this method
-
- HelperContext globalScope = HelperProvider.getDefaultContext();
- //factory.defineMetaData(globalScope); // Don't need to defineMetaData because already done in the previous test
- testDO = factory.createTestData(globalScope, StandardFactory.API_TYPE);
-
- Type testType = testDO.getType();
-
- DataGraph dataGraph = getTestHelper().createDataGraph();
- dataGraph.createRootObject(testType);
-
- assertEquals("DataGraph.getType() did not return the expected Type.",
- dataGraph.getType(testType.getURI(), testType.getName()),
- testType);
- }
-
- /**
- * Verify the proper function of DataGraph.getType(URI, Name) when the
- * DataGraph RootObject was created by URI
- * @throws Exception
- */
- @Test
- public void testDataGraphGetURI() throws Exception {
- // we are constrained to work with the default helper context for these APIs
- // so lets override the default behaviour of the test framework for this method
-
- HelperContext globalScope = HelperProvider.getDefaultContext();
- //factory.defineMetaData(globalScope); // Don't need to defineMetaData because already done in the previous test
- testDO = factory.createTestData(globalScope, StandardFactory.API_TYPE);
-
- Type testType = testDO.getType();
-
- DataGraph dataGraph = getTestHelper().createDataGraph();
- dataGraph.createRootObject(testType.getURI(), testType.getName());
-
- assertEquals("DataGraph.getType() did not return the expected Type.",
- dataGraph.getType(testType.getURI(), testType.getName()),
- testType);
- }
-
-
-}
diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataGraph/DataGraphConsistencyDynamic.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataGraph/DataGraphConsistencyDynamic.java deleted file mode 100644 index 8d85b2783d..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataGraph/DataGraphConsistencyDynamic.java +++ /dev/null @@ -1,34 +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: 537762 $ $Date: 2007-05-14 10:38:19 +0100 (Mon, 14 May 2007) $
- */
-package test.sdo21.tests.api.DataGraph;
-
-import test.sdo21.tests.TestData.StandardDynamicFactory;
-import test.sdo21.tests.TestData.TestDataFactory;
-
-public class DataGraphConsistencyDynamic extends DataGraphConsistencyBase {
-
- public TestDataFactory createTestDataFactory() {
-
- return new StandardDynamicFactory();
- }
-
-
-}
diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataGraph/DataGraphConsistencySuite.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataGraph/DataGraphConsistencySuite.java deleted file mode 100644 index f362fef26a..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataGraph/DataGraphConsistencySuite.java +++ /dev/null @@ -1,31 +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: 537762 $ $Date: 2007-05-14 10:38:19 +0100 (Mon, 14 May 2007) $
- */
-package test.sdo21.tests.api.DataGraph;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses( {DataGraphConsistencyDynamic.class,
- DataGraphConsistencyXSD.class})
-public class DataGraphConsistencySuite {
-
-}
diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataGraph/DataGraphConsistencyXSD.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataGraph/DataGraphConsistencyXSD.java deleted file mode 100644 index bdbfefcd95..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataGraph/DataGraphConsistencyXSD.java +++ /dev/null @@ -1,34 +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: 537762 $ $Date: 2007-05-14 10:38:19 +0100 (Mon, 14 May 2007) $
- */
-package test.sdo21.tests.api.DataGraph;
-
-import test.sdo21.tests.TestData.StandardXSDFactory;
-import test.sdo21.tests.TestData.TestDataFactory;
-
-public class DataGraphConsistencyXSD extends DataGraphConsistencyBase {
-
- public TestDataFactory createTestDataFactory() {
-
- return new StandardXSDFactory();
- }
-
-
-}
diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectConsistencyBase.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectConsistencyBase.java deleted file mode 100644 index 0654a7dc99..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectConsistencyBase.java +++ /dev/null @@ -1,739 +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.DataObject; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Test; - -import test.sdo21.tests.TestData.StandardFactory; -import test.sdo21.tests.api.CTSConsistencyBase; - -import commonj.sdo.DataObject; -import commonj.sdo.Property; -import commonj.sdo.Sequence; -import commonj.sdo.Type; -import commonj.sdo.helper.DataFactory; - -/** - * Tests for proper updates to DataObject and their value changes due to the - * updates. - */ -public abstract class DataObjectConsistencyBase extends CTSConsistencyBase { - - - /** - * testActiveUpdatingList verifies that updates made to a List returned from - * a DataObject are reflected in the DataObject and vice versa. - * @throws Exception - */ - @Test - public void testActiveUpdatingList() throws Exception { - DataObject root = factory.createTestData(getScope(), StandardFactory.API_TYPE); - DataObject child1 = factory.createTestData(getScope(), StandardFactory.API_TYPE); - DataObject child2 = factory.createTestData(getScope(), StandardFactory.API_TYPE); - DataObject child3 = factory.createTestData(getScope(), StandardFactory.API_TYPE); - - List addList = new ArrayList(); - List returnedList; - - addList.add(child1); - - root.setList("containMany", addList); - - // Verify the pre-condition. The List initially has a size of 1. - assertEquals("The List returned by getList was not of the expected size.", 1, root.getList("containMany").size()); - - returnedList = root.getList("containMany"); - - /** - * Add a member to the returned List and verify that it is reflected in - * the DataObject. - */ - - returnedList.add(child2); - - assertEquals("Update to returned List did not affect DataObject correctly. Size of children is not 2", - 2, root.getList("containMany").size()); - assertEquals("Update to returned List did not affect DataObject correctly. child1's container is not equal to root", - root, child1.getContainer()); - assertEquals("Update to returned List did not affect DataObject correctly. child2's container is not equal to root", - root, child2.getContainer()); - - /** - * Delete a child and verify that the returned List is automatically - * affected. - */ - - child1.delete(); - assertEquals("Deleting a DataObject did not affect the returned List.", 1, returnedList.size()); - - /** - * Verify that the DataObject delete did not affect the original List - * used in the DataObject.setList(). - */ - - assertEquals("Deleting a DataObject should not affect a List unassociated with the DataObject.", - 1, - addList.size()); - - /** - * Call DataObject.setList() and verify that the previously returned - * List reflects the new List. - */ - - addList.add(child2); - addList.add(child3); - root.setList("containMany", addList); - - assertEquals("The List returned by DataObject.getList() was not affected by a subsequent DataObject.setList().", - 3, - returnedList.size()); - /** - * Call List.remove() on the returned List and verify that the - * DataObject is affected. - */ - - DataObject child = (DataObject)returnedList.get(1); - - // Verify the precondition. The child should have root as its container. - assertEquals("List.setList() did not cause the expected containment relationship.", root, child.getContainer()); - - returnedList.remove(1); - - assertEquals("List.remove() did not have the expected effect on the DataObject. There are more than 2 children", - 2, root.getList("containMany").size()); - assertNull("List.remove() did not have the expected effect on the DataObject. child container is not null", - child.getContainer()); - - /** - * Call List.clear() and veirfy that the DataObject is affected. - */ - returnedList.clear(); - - assertEquals("List.clear() on the returned List did not have the expected effect on the DataObject. The size of the list of children is not 0", - 0,root.getList("containMany").size()); - assertNull("List.clear() on the returned List did not have the expected effect on the DataObject. child1.getContainer is not null", - child1.getContainer()); - assertNull("List.clear() on the returned List did not have the expected effect on the DataObject. child2.getContainer is not null", - child2.getContainer()); - - } - - /** - * testActiveUpdatingSequence verifies that updates made to a Sequence - * returned from a DataObject are reflected in the DataObject and vice - * versa. - * @throws Exception - */ - @Test - public void testActiveUpdatingSequence() throws Exception { - - DataObject sequenceDO = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE); - Sequence sequence = sequenceDO.getSequence(); - List letterList = sequenceDO.getList("Letters"); - List numberList = sequenceDO.getList("Numbers"); - - assertTrue("The Type of sequencedElem is not sequenced. testActiveUpdatingSequence may not proceed", - sequenceDO.getType().isSequenced()); - - letterList.clear(); - numberList.clear(); - - // Verify the precondition. The Sequence should be empty. - assertEquals("The Sequence should initially be empty.", 0, sequence.size()); - - /** - * Add values to the DataObject and verify that the Sequence is - * affected. - */ - - letterList.add("A"); - letterList.add("B"); - numberList.add(Integer.valueOf(8)); - - // The expected arrangement of sequence is as follows - // {<Letters, "A">, <Letters, "B">, <Numbers, 8>} - - assertEquals("Adding values to the DataObject did not affect the returned Sequence. Sequence size is not 3", - 3, sequence.size()); - assertEquals("Adding values to the DataObject did not affect the returned Sequence. getValue[0] is not A", - "A", sequence.getValue(0)); - assertEquals("Adding values to the DataObject did not affect the returned Sequence. getValue[1] is not B", - "B", sequence.getValue(1) - ); - assertEquals("Adding values to the DataObject did not affect the returned Sequence. getValue[2] is not equal to 8", - sequence.getValue(2), - Integer.valueOf(8)); - - /** - * Remove a value from the DataObject and verify that the Sequence is - * affected. - */ - - letterList.remove(1); - - // The expected arrangement of sequence is as follows: {<Letters, "A">, - // <Numbers, 8>} - assertEquals("Removing a value from the DataObject did not affect the returned Sequence.", sequence.size(), 2); - assertEquals("Removing a value from the DataObject did not affect the returned Sequence.", - "A", sequence.getValue(0) - ); - assertEquals("Removing a value from the DataObject did not affect the returned Sequence.", - Integer.valueOf(8), - sequence.getValue(1)); - - /** - * Remove a value from the Sequence and verify that the DataObject is - * affected. - */ - - sequence.remove(1); - - // The expected arrangement of sequence is as follows: {<Letters, "A">} - - assertEquals("Removing a value from the Sequence did not affect the DataObject. Size of List for numbers is not 0", - 0, sequenceDO.getList("Numbers").size()); - - /** - * Add a value to the Sequence and verify that the DataObject is - * affected. - */ - sequence.add("Numbers", Integer.valueOf(16)); - - // The expected arrangement of sequence is as follows: {<Letters, "A">, - // <Numbers, 16>} - - assertEquals("Adding a value to the Sequence did not have the expected effect on the DataObject.", sequenceDO - .getList("Numbers").size(), 1); - assertEquals("Adding a value to the Sequence did not have the expected effect on the DataObject.", sequenceDO - .getList("Numbers").get(0), Integer.valueOf(16)); - - // Add several values to the Sequence (via the DataObject) to make - // Sequence.move() meaningful. - - letterList.add("C"); - numberList.add(Integer.valueOf(15)); - numberList.add(Integer.valueOf(4)); - letterList.add("K"); - letterList.add("M"); - numberList.add(Integer.valueOf(-10)); - - // The expected arrangement of sequence is as follows - // {<Letters, "A">, <Numbers, 16>, <Letters, "C">, <Numbers, 15>, - // <Numbers, 4>, <Letters, "K">, <Letters, "M">, <Numbers, -10>} - - /** - * Use Sequence.move() and verify that the changes are reflected in the - * DataObject. - */ - - sequence.move(1, 5); - sequence.move(4, 2); - - // The expected arrangement of sequence is as follows - // {<Letters, "A">, <Letters, "K">, <Letters, "C">, <Numbers, 15>, - // <Numbers, 16>, <Numbers, 4>, <Letters, "M">, <Numbers, -10>} - - assertEquals("Sequence.move() did not have the expected effect on the DataObject represented by the Sequence.", - 4, - letterList.size()); - assertEquals("Sequence.move() did not have the expected effect on the DataObject represented by the Sequence.", - "A", - letterList.get(0)); - assertEquals("Sequence.move() did not have the expected effect on the DataObject represented by the Sequence.", - "K", - letterList.get(1)); - assertEquals("Sequence.move() did not have the expected effect on the DataObject represented by the Sequence.", - "C", - letterList.get(2)); - assertEquals("Sequence.move() did not have the expected effect on the DataObject represented by the Sequence.", - "M", - letterList.get(3)); - - assertEquals("Sequence.move() did not have the expected effect on the DataObject represented by the Sequence.", - 4, - numberList.size()); - assertEquals("Sequence.move() did not have the expected effect on the DataObject represented by the Sequence.", - Integer.valueOf(15), - numberList.get(0)); - assertEquals("Sequence.move() did not have the expected effect on the DataObject represented by the Sequence.", - Integer.valueOf(16), - numberList.get(1)); - assertEquals("Sequence.move() did not have the expected effect on the DataObject represented by the Sequence.", - Integer.valueOf(4), - numberList.get(2)); - assertEquals("Sequence.move() did not have the expected effect on the DataObject represented by the Sequence.", - Integer.valueOf(-10), - numberList.get(3)); - - // TODO: Add a value to a specific location within the Sequence and - // veirfy the effect on the DataObject. Awaiting Tuscany-931 - } - - /** - * Verfies that the Property being tested throughout these tests is a - * contaiment Property - */ - @Test - public void verifyIsContainment() { - Property containmentProp = testDO.getInstanceProperty("containMany"); - assertTrue("Property.isContainment() returned an unexpected value.", containmentProp.isContainment()); - } - - /** - * Verifies that the initial state after clearContainer is a state in which - * the DataObject does not have a container. - */ - @Test - public void verifyNullContainer() { - assertNull("DataObject.getContainer() returned an unexpected value.", testDO.getContainer()); - } - - /** - * Verfiies that the containerless DataObject returns null for - * getContainmentProperty - */ - @Test - public void verifyNullContainmentProperty() { - assertNull("DataObject.getContainmentProprety() returned an unexpected value.", testDO.getContainmentProperty()); - } - - /** - * Assign both dataObj1 and dataObj2 to testDO container, then verify - * DataObject.getContainer() for dataObj1 and dataObj2 - */ - @Test - public void verifyGetContainer() { - List addList = new ArrayList(); - Type type = testDO.getType(); - Property containmentProp = testDO.getInstanceProperty("containMany"); - - DataObject dataObj1 = getScope().getDataFactory().create(type); - DataObject dataObj2 = getScope().getDataFactory().create(type); - - // Ensure that any previous containment relationships are broken. - - addList.clear(); - testDO.setList("containMany", addList); - testDO.detach(); - addList.clear(); - - addList.add(dataObj1); - addList.add(dataObj2); - testDO.setList(containmentProp, addList); - - // Verify containment of dataObj1 and dataObj2 by testDO - - assertEquals("DataObject.getContainer() did not return the appropriate DataObject.", testDO, dataObj1 - .getContainer()); - - assertEquals("DataObject.getContainer() did not return the appropriate DataObject.", testDO, dataObj2 - .getContainer()); - } - - /** - * Assign both dataObj1 and dataObj2 to testDO container, then verify - * DataObject.getContainmentProperty for dataObj1 and dataObj2 - */ - @Test - public void verifyGetContainmentProperty() { - Property containmentProp = testDO.getInstanceProperty("containMany"); - List addList = new ArrayList(); - Type type = testDO.getType(); - DataObject dataObj1 = getScope().getDataFactory().create(type); - DataObject dataObj2 = getScope().getDataFactory().create(type); - - addList.add(dataObj1); - addList.add(dataObj2); - testDO.setList(containmentProp, addList); - - assertEquals("DataObject.getContainmentProperty() did not return the appropriate Property.", - containmentProp, - dataObj1.getContainmentProperty()); - - assertEquals("DataObject.getContainmentProperty() did not return the appropriate Property.", - containmentProp, - dataObj2.getContainmentProperty()); - } - - /** - * Assign both dataObj1 and dataObj2 to testDO container, then verify the - * contents of the containing property in testDO - */ - @Test - public void verifyContainmentContents() { - assertNull("testDO container != null", testDO.getContainer()); - assertEquals("testDO.containMany != 0", 0, testDO.getList("containMany").size()); - - Property containmentProp = testDO.getInstanceProperty("containMany"); - List addList = new ArrayList(); - Type type = testDO.getType(); - DataObject dataObj1 = getScope().getDataFactory().create(type); - DataObject dataObj2 = getScope().getDataFactory().create(type); - - addList.add(dataObj1); - addList.add(dataObj2); - testDO.setList(containmentProp, addList); - - List returnedList = testDO.getList(containmentProp); - - assertEquals("DataObject.getList() size is incorrect", 2, returnedList.size()); - assertEquals("DataObject.getList() did not return the List specified in DataObject.setList()", - dataObj1, - returnedList.get(0)); - assertEquals("DataObject.getList() did not return the List specified in DataObject.setList()", - dataObj2, - returnedList.get(1)); - } - - /** - * Assign both dataObj1 and dataObj2 to testDO container, then Assign - * dataObj2 to dataObj1 container. Verify dataObj2 is automatically removed - * from testDO container - */ - @Test - public void verifyAutomaticRemoval() { - Property containmentProp = testDO.getInstanceProperty("containMany"); - List addList = new ArrayList(); - Type type = testDO.getType(); - DataObject dataObj1 = getScope().getDataFactory().create(type); - DataObject dataObj2 = getScope().getDataFactory().create(type); - - addList.add(dataObj1); - addList.add(dataObj2); - testDO.setList(containmentProp, addList); - - // Verify the precondition - - assertEquals("DataObject.getContainer() did not return the appropriate DataObject.", testDO, dataObj1 - .getContainer()); - - assertEquals("DataObject.getContainer() did not return the appropriate DataObject.", testDO, dataObj2 - .getContainer()); - - // After the following section, it should be true that: testDO contains - // dataObj1 contains dataObj2 - - addList.clear(); - addList.add(dataObj2); - dataObj1.setList(containmentProp, addList); - - // Verify automatic removal of dataObj2 from testDO container - - List returnedList = testDO.getList(containmentProp); - assertEquals("Once placed in a new container, the DataObject should no longer appear in the former container.", - 1, - returnedList.size()); - assertEquals("Once placed in a new container, the DataObject should no longer appear in the former container.", - dataObj1, - returnedList.get(0)); - } - - /** - * Assign both dataObj1 and dataObj2 to testDO container, then Assign - * dataObj2 to dataObj1 container. Verify dataObj2 is contained by dataObj1 - */ - @Test - public void verifyNewContainer() { - Property containmentProp = testDO.getInstanceProperty("containMany"); - List addList = new ArrayList(); - Type type = testDO.getType(); - DataObject dataObj1 = getScope().getDataFactory().create(type); - DataObject dataObj2 = getScope().getDataFactory().create(type); - - addList.add(dataObj1); - addList.add(dataObj2); - testDO.setList(containmentProp, addList); - - // After the following section, it should be true that: testDO contains - // dataObj1 contains dataObj2 - - addList.clear(); - addList.add(dataObj2); - dataObj1.setList(containmentProp, addList); - - // Verify that dataObj2 was correctly added to dataObj1 container - - List returnedList = dataObj1.getList(containmentProp); - assertEquals("Once assigned to a new container, the DataObject should appear in the new container.", - 1, - returnedList.size()); - assertEquals("Once assigned to a new container, the DataObject should appear in the new container.", - dataObj2, - returnedList.get(0)); - assertEquals("DataObject.getContainer() did not return the appropriate DataObject.", dataObj1, dataObj2 - .getContainer()); - } - - /** - * Verify that detach() removes the object from its container. - */ - @Test - public void verifyDetachRemoval() { - Property containmentProp = testDO.getInstanceProperty("containMany"); - List addList = new ArrayList(); - Type type = testDO.getType(); - DataObject dataObj1 = getScope().getDataFactory().create(type); - DataObject dataObj2 = getScope().getDataFactory().create(type); - - // After the following section, it should be true that: dataObj1 - // contains testDO contains dataObj2 - - addList.add(dataObj2); - testDO.setList(containmentProp, addList); - addList.clear(); - addList.add(testDO); - dataObj1.setList(containmentProp, addList); - - testDO.detach(); - - List returnedList = dataObj1.getList(containmentProp); - assertEquals("Detaching the contained object did not remove it from container", 0, returnedList.size()); - - assertNull("DataObject.getContainer() did not return null as expected for a detached DataObject.", testDO - .getContainer()); - } - - /** - * Verify that DataObject.detach() does not affect objects contained by the - * detached DataObject - */ - @Test - public void verifyDetachContainer() { - Property containmentProp = testDO.getInstanceProperty("containMany"); - List addList = new ArrayList(); - Type type = testDO.getType(); - DataObject dataObj1 = getScope().getDataFactory().create(type); - DataObject dataObj2 = getScope().getDataFactory().create(type); - - // After the following section, it should be true that: dataObj1 - // contains testDO contains dataObj2 - - addList.add(testDO); - dataObj1.setList(containmentProp, addList); - addList.clear(); - addList.add(dataObj2); - testDO.setList(containmentProp, addList); - - testDO.detach(); - - List returnedList = testDO.getList(containmentProp); - - assertEquals("Detaching a DataObject should not detach its contained DataObjects.", 1, returnedList.size()); - assertEquals("Detaching a DataObject should not affect it as a container.", dataObj2, returnedList.get(0)); - } - - /** - * Verify that DataObject.detach() does not affect objects contained by the - * detached DataObject - */ - @Test - public void verifyDetachContainedDOs() { - Property containmentProp = testDO.getInstanceProperty("containMany"); - List addList = new ArrayList(); - Type type = testDO.getType(); - DataObject dataObj1 = getScope().getDataFactory().create(type); - DataObject dataObj2 = getScope().getDataFactory().create(type); - - // After the following section, it should be true that: dataObj1 - // contains testDO contains dataObj2 - - addList.add(testDO); - dataObj1.setList(containmentProp, addList); - addList.clear(); - addList.add(dataObj2); - testDO.setList(containmentProp, addList); - - testDO.detach(); - - assertEquals("Detaching a DataObject should not affect contained DataObjects.", testDO, dataObj2.getContainer()); - } - - /** - * Verify that DataObject.delete() removes the object from its container. - */ - @Test - public void verifyDeleteRemoval() { - Property containmentProp = testDO.getInstanceProperty("containMany"); - List addList = new ArrayList(); - Type type = testDO.getType(); - DataObject dataObj1 = getScope().getDataFactory().create(type); - DataObject dataObj2 = getScope().getDataFactory().create(type); - - // After the following section, it should be true that: dataObj1 - // contains testDO contains dataObj2 - - addList.add(testDO); - dataObj1.setList(containmentProp, addList); - addList.clear(); - addList.add(dataObj2); - testDO.setList(containmentProp, addList); - - testDO.delete(); - - assertEquals("Deleting the DataObject did not remove it from its container.", 0, dataObj1 - .getList(containmentProp).size()); - } - - /** - * Verify that DataObject.delete() removes the containment reflected by the - * deleted DataObject - */ - @Test - public void verifyDeleteResultsOnDeleted() { - Property containmentProp = testDO.getInstanceProperty("containMany"); - List addList = new ArrayList(); - Type type = testDO.getType(); - DataObject dataObj1 = getScope().getDataFactory().create(type); - DataObject dataObj2 = getScope().getDataFactory().create(type); - - // After the following section, it should be true that: dataObj1 - // contains testDO contains dataObj2 - - addList.add(testDO); - dataObj1.setList(containmentProp, addList); - addList.clear(); - addList.add(dataObj2); - testDO.setList(containmentProp, addList); - - testDO.delete(); - - assertNotNull("A deleted DataObject should remain programatically accessible.", testDO); - assertNull("Deleting the DataObject did not affect its view of its container.", testDO.getContainer()); - } - - /** - * Verify that DataObject.delete() removes its contents as a container. - */ - @Test - public void verifyDeleteAsContainer() { - Property containmentProp = testDO.getInstanceProperty("containMany"); - List addList = new ArrayList(); - Type type = testDO.getType(); - DataObject dataObj1 = getScope().getDataFactory().create(type); - DataObject dataObj2 = getScope().getDataFactory().create(type); - - // After the following section, it should be true that: dataObj1 - // contains testDO contains dataObj2 - - addList.add(testDO); - dataObj1.setList(containmentProp, addList); - addList.clear(); - addList.add(dataObj2); - testDO.setList(containmentProp, addList); - - testDO.delete(); - - assertNotNull("A deleted DataObject should remain programatically accessible.", testDO); - assertEquals("Deleting the DataObject did not empty it as a container.", 0, testDO.getList(containmentProp) - .size()); - } - - /** - * Verify that DataObject.delete() affects contained DataObjects. - */ - @Test - public void verifyDeleteAffectOnContained() { - Property containmentProp = testDO.getInstanceProperty("containMany"); - List addList = new ArrayList(); - Type type = testDO.getType(); - DataObject dataObj1 = getScope().getDataFactory().create(type); - DataObject dataObj2 = getScope().getDataFactory().create(type); - - // After the following section, it should be true that: dataObj1 - // contains testDO contains dataObj2 - - addList.add(testDO); - dataObj1.setList(containmentProp, addList); - addList.clear(); - addList.add(dataObj2); - testDO.setList(containmentProp, addList); - - testDO.delete(); - - assertNull("Deleting the containing DataObject was not reflected in the contained DataObject.", dataObj2 - .getContainer()); - } - - /** - * testRecursiveDeletion verifies that when a DataObject is deleted, all - * (recursively) contained DataObjects are also deleted. - */ - @Test - public void testRecursiveDeletion() { - Type type = testDO.getType(); - Property containmentProp = type.getProperty("containMany"); - - assertTrue("Cannot continue with test because Property.isContainment() is false.", containmentProp - .isContainment()); - - DataFactory df = getScope().getDataFactory(); - DataObject child1 = df.create(type); - DataObject child2 = df.create(type); - DataObject child3 = df.create(type); - - List addList = new ArrayList(); - - /** - * Establish a series of containment relationships - */ - - addList.add(child1); - testDO.setList(containmentProp, addList); - - addList.clear(); - addList.add(child2); - child1.setList(containmentProp, addList); - - addList.clear(); - addList.add(child3); - child2.setList(containmentProp, addList); - - /** - * Verify that containment has been established correctly. - */ - - assertEquals("The expected containment relationships were not correctly formed.", child3.getContainer(), child2); - assertEquals("The expected containment relationships were not correctly formed.", child2.getContainer(), child1); - assertEquals("The expected containment relationships were not correctly formed.", child1.getContainer(), testDO); - - /** - * Delete the root DataObject and verify that contained DataObjects are - * recursively affected. - */ - - testDO.delete(); - - assertEquals("DataObject.delete() did not recursively affect contained DataObjects.", testDO - .getList(containmentProp).size(), 0); - assertNull("DataObject.delete() did not recursively affect contained DataObjects.", child1.getContainer()); - assertNull("DataObject.delete() did not recursively affect contained DataObjects.", child2.getContainer()); - assertNull("DataObject.delete() did not recursively affect contained DataObjects.", child3.getContainer()); - - } -} diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectConsistencyDynamic.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectConsistencyDynamic.java deleted file mode 100644 index 4b1d2fc4a0..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectConsistencyDynamic.java +++ /dev/null @@ -1,34 +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.DataObject; - -import test.sdo21.tests.TestData.StandardDynamicFactory; -import test.sdo21.tests.TestData.TestDataFactory; - -public class DataObjectConsistencyDynamic extends DataObjectConsistencyBase { - - public TestDataFactory createTestDataFactory() { - - return new StandardDynamicFactory(); - } - - -} diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectConsistencySuite.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectConsistencySuite.java deleted file mode 100644 index 1ef7b0cb3e..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectConsistencySuite.java +++ /dev/null @@ -1,31 +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.DataObject; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -@RunWith(Suite.class) -@Suite.SuiteClasses( {DataObjectConsistencyDynamic.class, - DataObjectConsistencyXSD.class}) -public class DataObjectConsistencySuite { - -} diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectConsistencyXSD.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectConsistencyXSD.java deleted file mode 100644 index 2ce75bbf37..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectConsistencyXSD.java +++ /dev/null @@ -1,34 +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.DataObject; - -import test.sdo21.tests.TestData.StandardXSDFactory; -import test.sdo21.tests.TestData.TestDataFactory; - -public class DataObjectConsistencyXSD extends DataObjectConsistencyBase { - - public TestDataFactory createTestDataFactory() { - - return new StandardXSDFactory(); - } - - -} diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectTest.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectTest.java deleted file mode 100644 index ce40f7b8d3..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectTest.java +++ /dev/null @@ -1,395 +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.DataObject; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; - -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -import test.sdo21.framework.CTSTestCase; -import test.sdo21.tests.util.CTSUtil; - -import commonj.sdo.DataObject; -import commonj.sdo.Property; -import commonj.sdo.Type; -import commonj.sdo.helper.HelperContext; -import commonj.sdo.helper.XMLDocument; - -import java.util.List; -import java.util.ArrayList; - -/** - * Set of tests for DataObject APIs. - * Currently limited to a fairly narrow set of tests on the set(Property, value), isSet(), and unSet() - * methods. - * <p/> - * TODO Need to extend the test set or migrate tests from other existing tests as yet unidentified. - */ -public class DataObjectTest extends CTSTestCase { - - private boolean debug = false; - private static int uniqueNumber = 1; - - @Before - public void setUp() throws Exception { - super.setUp(); - } - - - - - /** - * This test checks that getInstanceProperties returns all properties - * defined by the DataObject's type, regardless of whether they are set or - * not. It also checks that open content properties only appear in - * getInstanceProperties if they are set. Related sections in the - * specification are / 3.1.9 / 3.1.11 Related JIRA SDO-179 - * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=14">2.1 spec section 3.1.1</a> - * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=18">2.1 spec section 3.1.9</a> - * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=20">2.1 spec section 3.1.11</a> - * @see <a href="http://www.xcalia.com/support/browse/SDO-179">SDO Spec JIRA 179</a> - * @throws Exception - */ - @Test - @Ignore("On demand open content property is not yet implemented in Tuscany.") - public void testGetInstancePropertiesSize() throws Exception { - - // define a type with two properties - HelperContext helperContext = getScope(); - String typeName = getTypeName(); - DataObject typeDef = CTSUtil.createTypeDef("", typeName, true, helperContext); - CTSUtil.createPropertyDef(typeDef, "p1", "commonj.sdo#String", false, false, helperContext); - CTSUtil.createPropertyDef(typeDef, "p2", "commonj.sdo#String", false, false, helperContext); - helperContext.getTypeHelper().define(typeDef); - - // create a DataObject that uses this type - DataObject dobj = helperContext.getDataFactory().create("", typeName); - - // getInstanceProperties() should return p1, p2 even though they are not - // set - // System.out.println(dobj.getInstanceProperties()); - assertEquals(2, dobj.getInstanceProperties().size()); - - dobj.set("p1", "foo"); - - // getInstanceProperties() should still return p1, p2 - assertEquals(2, dobj.getInstanceProperties().size()); - - dobj.unset("p1"); - - // getInstanceProperties() should still return p1, p2 - assertEquals(2, dobj.getInstanceProperties().size()); - - // set an on-demand open content property - dobj.set("p3", "foo"); - - // getInstanceProperties() should now return p1, p2, p3 - assertEquals(3, dobj.getInstanceProperties().size()); - - // unset the on-demand property - dobj.unset("p3"); - - // the spec says that open content properties only appear in - // getInstancePropeties if - // they are set so we expect the list to be smaller now - assertEquals(2, dobj.getInstanceProperties().size()); - } - - /** - * Tests an isMany=false Boolean type property in an open type for being set to false/unset. - * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=16">2.1 spec section 3.1.5</a> - * @see commonj.sdo.DataObject#isSet() - * @see commonj.sdo.DataObject#unset() - * @see commonj.sdo.DataObject#set(Property, Boolean) - * @throws Exception - */ - @Test - public void testIsSet_Boolean_false() throws Exception { - - // define a type with two properties - HelperContext helperContext = getScope(); - String typeName = getTypeName(); - DataObject typeDef = CTSUtil.createTypeDef("", typeName, true, helperContext); - CTSUtil.createPropertyDef(typeDef, "b1", "commonj.sdo#Boolean", false, false, helperContext); - helperContext.getTypeHelper().define(typeDef); - - // create a DataObject that uses this type - DataObject testDO = helperContext.getDataFactory().create("", typeName); - - Property p = testDO.getInstanceProperty("b1"); - testDO.unset(p); - assertFalse("Property was set", testDO.isSet(p)); - testDO.set(p, false); - assertTrue("Property was not set ", testDO.isSet(p)); - } - - /** - * Tests an isMany=false Boolean type property in an open type for being set to true/unset. - * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=16">2.1 spec section 3.1.5</a> - * @see commonj.sdo.DataObject#getInstanceProperty(String) - * @see commonj.sdo.DataObject#isSet() - * @see commonj.sdo.DataObject#unset() - * @see commonj.sdo.DataObject#set(Property, Boolean) - * @throws Exception - */ - @Test - public void testIsSet_Boolean_true() throws Exception { - - // define a type with two properties - HelperContext helperContext = getScope(); - String typeName = getTypeName(); - DataObject typeDef = CTSUtil.createTypeDef("", typeName, true, helperContext); - CTSUtil.createPropertyDef(typeDef, "b1", "commonj.sdo#Boolean", false, false, helperContext); - helperContext.getTypeHelper().define(typeDef); - - // create a DataObject that uses this type - DataObject testDO = helperContext.getDataFactory().create("", typeName); - - Property p = testDO.getInstanceProperty("b1"); - testDO.unset(p); - assertFalse("Property was set", testDO.isSet(p)); - testDO.set(p, true); - assertTrue("Property was not set " + testDO.get(p), testDO - .isSet(p)); - } - - /** - * Tests isSet() of Integer property where isMany = false in an open type. - * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=16">2.1 spec section 3.1.5</a> - * @see commonj.sdo.DataObject#isSet() - * @see commonj.sdo.DataObject#unset() - * @see commonj.sdo.DataObject#set(Property, Integer) - * @throws Exception - */ - @Test - public void testIsSet_Integer_0() throws Exception { - - // define a type with two properties - HelperContext helperContext = getScope(); - String typeName = getTypeName(); - DataObject typeDef = CTSUtil.createTypeDef("", typeName, true, helperContext); - CTSUtil.createPropertyDef(typeDef, "i1", "commonj.sdo#Integer", false, false, helperContext); - helperContext.getTypeHelper().define(typeDef); - - // create a DataObject that uses this type - DataObject testDO = helperContext.getDataFactory().create("", typeName); - - Property p = testDO.getInstanceProperty("i1"); - testDO.unset(p); - assertFalse("Property was set", testDO.isSet(p)); - testDO.set(p, java.math.BigInteger.valueOf(0)); - assertTrue("Property was not set" + testDO.get(p), testDO.isSet(p)); - } - - /** - * Ensures correct behaviour (returns null) on attempting to get a non existent property in an open type.<br/> - * Tests isSet() after unset() and set() on isMany=false property - * @see commonj.sdo.DataObject#getInstanceProperty(String) - * @see commonj.sdo.DataObject#isSet() - * @see commonj.sdo.DataObject#unset() - * @see commonj.sdo.DataObject#set(Property, Integer) - * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=16">2.1 spec section 3.1.5</a> - * @throws Exception - */ - @Test - public void testIsSet_Integer_1() throws Exception { - - HelperContext helperContext = getScope(); - String typeName = getTypeName(); - DataObject typeDef = CTSUtil.createTypeDef("", typeName, true, helperContext); - CTSUtil.createPropertyDef(typeDef, "i1", "commonj.sdo#Integer", false, false, helperContext); - helperContext.getTypeHelper().define(typeDef); - - // create a DataObject that uses this type - DataObject testDO = helperContext.getDataFactory().create("", typeName); - try { - Property p = testDO.getInstanceProperty("default"); - assertTrue("non null return for non-existent property in an open type", p==null); - } catch (Exception e) { - assertTrue("getInstanceProperty throws exception for non-existent property "+e, false); - } - - Property p = testDO.getInstanceProperty("i1"); - testDO.unset(p); - assertFalse("Property was set ", testDO.isSet(p)); - - testDO.set(p, java.math.BigInteger.valueOf(1)); - assertTrue("Property was not set ", testDO.isSet(p)); - } - - /** - * Tests isSet() after unset() and set() on isMany=false property of type Int in an open type - * @see commonj.sdo.DataObject#getInstanceProperty(String) - * @see commonj.sdo.DataObject#isSet() - * @see commonj.sdo.DataObject#unset() - * @see commonj.sdo.DataObject#set(Property, Integer) - * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=16">2.1 spec section 3.1.5</a> - * @throws Exception - */ - @Test - public void testIsSet_int_1() throws Exception { - - HelperContext helperContext = getScope(); - String typeName = getTypeName(); - DataObject typeDef = CTSUtil.createTypeDef("", typeName, true, helperContext); - Type intType = helperContext.getTypeHelper().getType("commonj.sdo", "Int"); - - CTSUtil.createPropertyDef(typeDef, "i1", intType, false, false); - helperContext.getTypeHelper().define(typeDef); - - // create a DataObject that uses this type - DataObject testDO = helperContext.getDataFactory().create("", typeName); - - Property p = testDO.getInstanceProperty("i1"); - testDO.unset(p); - assertFalse("Property was not unset", testDO.isSet(p)); - - testDO.set(p, 1); - assertTrue("Property was not set " , testDO.isSet(p)); - } - - /** - * Tests an open type - * @throws Exception - */ - @Test - public void testIsSet_int_0() throws Exception { - try { - - HelperContext helperContext = getScope(); - String typeName = getTypeName(); - DataObject typeDef = CTSUtil.createTypeDef("", typeName, true, helperContext); - Type intType = helperContext.getTypeHelper().getType("commonj.sdo", "Int"); - CTSUtil.createPropertyDef(typeDef, "i1", intType, false, false); - helperContext.getTypeHelper().define(typeDef); - - // create a DataObject that uses this type - DataObject testDO = helperContext.getDataFactory().create("", typeName); - - Property p = testDO.getInstanceProperty("i1"); - testDO.unset(p); - assertFalse("Property was set", testDO.isSet(p)); - - testDO.set(p, 0); - if (debug) { - helperContext.getXMLHelper().save(testDO, "http://www.example.com/api_test", "apiTestElem", System.out); - } - assertTrue("Property was not set", testDO.isSet(p)); - - } catch (Exception e) { - assertFalse("No exception expected: received " + e.toString(), true); - } - } - - @Test - public void testOpenTypeBadPropertyReturnsDefault() { - // define an open type with no properties - HelperContext helperContext = getScope(); - String typeName = getTypeName(); - DataObject typeDef = CTSUtil.createTypeDef("", typeName, true, helperContext); - helperContext.getTypeHelper().define(typeDef); - - // create a DataObject that uses this type - DataObject testDO = helperContext.getDataFactory().create("", typeName); - - // get() should not throw an exception but return an appropriate default value - assertEquals( null, testDO.get( "foo" ) ); - assertEquals( null, testDO.getDataObject( "foo" ) ); - assertEquals( null, testDO.getList( "foo" ) ); - assertEquals( null, testDO.getString( "foo" ) ); - assertEquals( null, testDO.getBigDecimal( "foo" ) ); - assertEquals( null, testDO.getBigInteger( "foo" ) ); - assertEquals( null, testDO.getDate( "foo" ) ); - assertEquals( null, testDO.getBytes( "foo" ) ); - assertEquals( (byte) 0, testDO.getByte( "foo" ) ); - assertEquals( (short) 0, testDO.getShort( "foo" ) ); - assertEquals( (int) 0, testDO.getInt( "foo" ) ); - assertEquals( (long) 0, testDO.getLong( "foo" ) ); - assertEquals( (double) 0, testDO.getDouble( "foo" ) ); - assertEquals( (float) 0, testDO.getFloat( "foo" ) ); - } - - /** - * Test that getList() returns null for an unset open content property. - * - */ - @Test - public void testGetList() { - - // define an open type with no properties - HelperContext helperContext = getScope(); - String typeName = getTypeName(); - DataObject typeDef = CTSUtil.createTypeDef("", typeName, true, helperContext); - helperContext.getTypeHelper().define(typeDef); - - // create a DataObject that uses this type - DataObject testDO = helperContext.getDataFactory().create("", typeName); - - // test that getList() returns null for an unst open content property - assertNull( testDO.getList("foo") ); - testDO.set("foo", new ArrayList()); - assertNotNull( testDO.getList("foo") ); - testDO.unset("foo"); - assertNull( testDO.getList("foo") ); - } - - /** - * Test that it is possible to add a null value to a List retrieved by calling DataObject.getList() - * - */ - @Test - public void testAddNullToList() { - HelperContext helperContext = getScope(); - XMLDocument doc = helperContext.getXMLHelper().load("<catalog2><product2/><product2/></catalog2>"); - List listTest = doc.getRootObject().getList("product2"); - assertNotNull(listTest); - assertEquals(2, listTest.size()); - listTest.add( null ); - assertEquals(3, listTest.size()); - String xml = helperContext.getXMLHelper().save( doc.getRootObject(), doc.getRootElementURI(), doc.getRootElementName() ); - assertTrue( xml.indexOf("xsi:nil=\"true\"") > 0 ); - - } - - /** - * Creates a unique type name for each test so that the types won't clash if an implementation - * provides its default HelperContext when running the tests. - * - * @return - */ - private String getTypeName() { - return "DataObjectTestType" + (++uniqueNumber); - } - - @Override - @After - public void tearDown() throws Exception { - super.tearDown(); - } -} diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DynamicTypesFromSchemaTestCase.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DynamicTypesFromSchemaTestCase.java deleted file mode 100644 index 3fb6c2f310..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DynamicTypesFromSchemaTestCase.java +++ /dev/null @@ -1,295 +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 java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.List; -import java.util.ListIterator; -import java.util.SortedSet; -import java.util.TreeSet; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.fail; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertNotNull; - -import test.sdo21.framework.CTSTestCase; -import test.sdo21.framework.TestHelper; - -import commonj.sdo.DataObject; -import commonj.sdo.Property; -import commonj.sdo.Type; -import commonj.sdo.helper.DataFactory; -import commonj.sdo.helper.HelperContext; -import commonj.sdo.helper.TypeHelper; -import commonj.sdo.helper.XMLDocument; -import commonj.sdo.helper.XMLHelper; -import commonj.sdo.helper.XSDHelper; - -/** - * Tests methods of DataGraph except for change summary which is tested elsewhere. - */ -public class DynamicTypesFromSchemaTestCase extends CTSTestCase { - private final String DYNAMIC_ROOT_TYPE_0 = "TestType0"; - - private final String DYNAMIC_ROOT_TYPE_1 = "TestType1"; - - private final String DYNAMIC_ROOT_TYPE_2 = "TestType2"; - - private final String DYNAMIC_TYPES_SCHEMA = "/dynamicTypesFromSchema.xsd"; - - private final String DYNAMIC_TYPES_URI = "http://www.example.com/dynamicTypesFromSchema"; - - private HelperContext hc; - - private final String TEST_XML_DOC_0 = "/dynamicTypesFromSchema0.xml"; - - private final String TEST_XML_DOC_1 = "/dynamicTypesFromSchema1.xml"; - - private final String TEST_XML_DOC_2 = "/dynamicTypesFromSchema2.xml"; - - private List typeList; - - @Before - public void setUp() throws Exception { - TestHelper testHelper = getTestHelper(); - hc = testHelper.createHelperContext(); - - // Populate the meta data for the types defined in schema - URL url = getClass().getResource(DYNAMIC_TYPES_SCHEMA); - InputStream inputStream = url.openStream(); - XSDHelper xsdHelper = hc.getXSDHelper(); - typeList = xsdHelper.define(inputStream, url.toString()); - inputStream.close(); - } - - /** - * test of Schema complex types - */ - @Test - public void testDynamicTypeList() throws IOException { - if (typeList == null) { - fail("typeList unexpectedly null"); - } - - ListIterator li = typeList.listIterator(); - SortedSet<String> typeNameSet = new TreeSet<String>(); - while (li.hasNext()) { - Object obj = li.next(); - if (obj instanceof Type) { - typeNameSet.add(((Type)obj).getName()); - } else { - fail("a type list entry was not a type: " + obj.toString()); - } - } - assertTrue(typeNameSet.contains("Address")); - assertTrue(typeNameSet.contains("Component")); - assertTrue(typeNameSet.contains("TestType0")); - assertTrue(typeNameSet.contains("TestType1")); - assertTrue(typeNameSet.contains("TestType2")); - assertTrue(typeNameSet.contains("evenNumberOfOddOrEvenDigits")); - assertTrue(typeNameSet.contains("evenNumberOfOddOrEvenDigitsObject")); - assertTrue(typeNameSet.contains("month")); - assertTrue(typeNameSet.contains("monthList")); - assertTrue(typeNameSet.contains("monthObject")); - assertTrue(typeNameSet.contains("oddOrEvenDigits")); - assertTrue(typeNameSet.contains("oddOrEvenDigitsObject")); - assertTrue(typeNameSet.contains("smallBigDecimal")); - assertTrue(typeNameSet.contains("smallBigInteger")); - assertTrue(typeNameSet.contains("smallInt")); - assertTrue(typeNameSet.contains("smallIntObject")); - assertTrue(typeNameSet.contains("smallOddNumber")); - assertTrue(typeNameSet.contains("smallOddNumberObject")); - assertTrue(typeNameSet.contains("status")); - assertTrue(typeNameSet.contains("statusOrMonthList")); - } - - /** - * test #0 of Schema primitive datatypes - */ - @Test - public void testDynamicTypesGroup0() throws IOException { - if (hc == null) { - fail("the HelperContext unexpectedly null"); - } - - TypeHelper th = hc.getTypeHelper(); - Type rootType0 = th.getType(DYNAMIC_TYPES_URI, DYNAMIC_ROOT_TYPE_0); - - assertNotNull(rootType0); - - DataFactory df = hc.getDataFactory(); - DataObject rootObject = df.create(rootType0); - - assertNotNull(rootObject); - - XMLHelper xh = hc.getXMLHelper(); - XMLDocument doc = xh.load(getClass().getResourceAsStream(TEST_XML_DOC_0)); - DataObject rootObject0 = doc.getRootObject(); - - assertNotNull(rootObject0); - List propList = rootObject0.getInstanceProperties(); - SortedSet<String> propNameSet = new TreeSet<String>(); - ListIterator li1 = propList.listIterator(); - while (li1.hasNext()) { - Object obj = li1.next(); - if (obj instanceof Property) { - propNameSet.add(((Property)obj).getName()); - } else { - fail("getInstanceProperties list contained: " + obj.toString()); - } - } - assertTrue("Property name set does not contain 'anyURI'.", propNameSet.contains("anyURI")); - assertTrue("Property name set does not contain 'base64Binary'.", propNameSet.contains("base64Binary")); - assertTrue("Property name set does not contain 'boolean'.", propNameSet.contains("boolean")); - assertTrue("Property name set does not contain 'date'.", propNameSet.contains("date")); - assertTrue("Property name set does not contain 'dateTime'.", propNameSet.contains("dateTime")); - assertTrue("Property name set does not contain 'decimal'.", propNameSet.contains("decimal")); - assertTrue("Property name set does not contain 'double'.", propNameSet.contains("double")); - assertTrue("Property name set does not contain 'duration'.", propNameSet.contains("duration")); - assertTrue("Property name set does not contain 'float'.", propNameSet.contains("float")); - assertTrue("Property name set does not contain 'gDay'.", propNameSet.contains("gDay")); - assertTrue("Property name set does not contain 'gMonth'.", propNameSet.contains("gMonth")); - assertTrue("Property name set does not contain 'gMonthDay'.", propNameSet.contains("gMonthDay")); - assertTrue("Property name set does not contain 'gYear'.", propNameSet.contains("gYear")); - assertTrue("Property name set does not contain 'gYearMonth'.", propNameSet.contains("gYearMonth")); - assertTrue("Property name set does not contain 'hexBinary'.", propNameSet.contains("hexBinary")); - assertTrue("Property name set does not contain 'string'.", propNameSet.contains("string")); - assertTrue("Property name set does not contain 'time'.", propNameSet.contains("time")); - } - - /** - * test #1 of Schema derived datatypes - */ - @Test - public void testDynamicTypesGroup1() throws IOException { - if (hc == null) { - fail("the HelperContext unexpectedly null"); - } - - TypeHelper th = hc.getTypeHelper(); - Type rootType = th.getType(DYNAMIC_TYPES_URI, DYNAMIC_ROOT_TYPE_1); - - assertNotNull(rootType); - - DataFactory df = hc.getDataFactory(); - DataObject rootObject = df.create(rootType); - - assertNotNull(rootObject); - - XMLHelper xh = hc.getXMLHelper(); - XMLDocument doc = xh.load(getClass().getResourceAsStream(TEST_XML_DOC_1)); - DataObject rootObject1 = doc.getRootObject(); - - assertNotNull(rootObject1); - List propList = rootObject1.getInstanceProperties(); - SortedSet<String> propNameSet = new TreeSet<String>(); - ListIterator li1 = propList.listIterator(); - while (li1.hasNext()) { - Object obj = li1.next(); - if (obj instanceof Property) { - propNameSet.add(((Property)obj).getName()); - } else { - fail("getInstanceProperties list contained: " + obj.toString()); - } - } - assertTrue("Property name set does not contain 'ID'.", propNameSet.contains("ID")); - assertTrue("Property name set does not contain 'IDREF'.", propNameSet.contains("IDREF")); - assertTrue("Property name set does not contain 'IDREFS'.", propNameSet.contains("IDREFS")); - assertTrue("Property name set does not contain 'NCName'.", propNameSet.contains("NCName")); - assertTrue("Property name set does not contain 'NMTOKEN'.", propNameSet.contains("NMTOKEN")); - assertTrue("Property name set does not contain 'NMTOKENS'.", propNameSet.contains("NMTOKENS")); - assertTrue("Property name set does not contain 'Name'.", propNameSet.contains("Name")); - assertTrue("Property name set does not contain 'byte'.", propNameSet.contains("byte")); - assertTrue("Property name set does not contain 'int'.", propNameSet.contains("int")); - assertTrue("Property name set does not contain 'integer'.", propNameSet.contains("integer")); - assertTrue("Property name set does not contain 'language'.", propNameSet.contains("language")); - assertTrue("Property name set does not contain 'long'.", propNameSet.contains("long")); - assertTrue("Property name set does not contain 'negativeInteger'.", propNameSet.contains("negativeInteger")); - assertTrue("Property name set does not contain 'nonNegativeInteger'.", propNameSet.contains("nonNegativeInteger")); - assertTrue("Property name set does not contain 'nonPositiveInteger'.", propNameSet.contains("nonPositiveInteger")); - assertTrue("Property name set does not contain 'normalizedString'.", propNameSet.contains("normalizedString")); - assertTrue("Property name set does not contain 'positiveInteger'.", propNameSet.contains("positiveInteger")); - assertTrue("Property name set does not contain 'short'.", propNameSet.contains("short")); - assertTrue("Property name set does not contain 'token'.", propNameSet.contains("token")); - assertTrue("Property name set does not contain 'unsignedByte'.", propNameSet.contains("unsignedByte")); - assertTrue("Property name set does not contain 'unsignedInt'.", propNameSet.contains("unsignedInt")); - assertTrue("Property name set does not contain 'unsignedLong'.", propNameSet.contains("unsignedLong")); - assertTrue("Property name set does not contain 'unsignedShort'.", propNameSet.contains("unsignedShort")); - } - - /** - * test #2 of more Schema derived datatypes - */ - @Test - public void testDynamicTypesGroup2() throws IOException { - if (hc == null) { - fail("the HelperContext unexpectedly null"); - } - - TypeHelper th = hc.getTypeHelper(); - Type rootType = th.getType(DYNAMIC_TYPES_URI, DYNAMIC_ROOT_TYPE_2); - - assertNotNull(rootType); - - DataFactory df = hc.getDataFactory(); - DataObject rootObject = df.create(rootType); - - assertNotNull(rootObject); - - XMLHelper xh = hc.getXMLHelper(); - XMLDocument doc = xh.load(getClass().getResourceAsStream(TEST_XML_DOC_2)); - DataObject rootObject2 = doc.getRootObject(); - - assertNotNull(rootObject2); - List propList = rootObject2.getInstanceProperties(); - SortedSet<String> propNameSet = new TreeSet<String>(); - ListIterator li1 = propList.listIterator(); - while (li1.hasNext()) { - Object obj = li1.next(); - if (obj instanceof Property) { - propNameSet.add(((Property)obj).getName()); - } else { - fail("getInstanceProperties list contained: " + obj.toString()); - } - } - assertTrue("Property name set does not contain 'addresses'.", propNameSet.contains("addresses")); - assertTrue("Property name set does not contain 'cluster'.", propNameSet.contains("cluster")); - assertTrue("Property name set does not contain 'clusters'.", propNameSet.contains("clusters")); - assertTrue("Property name set does not contain 'components'.", propNameSet.contains("components")); - assertTrue("Property name set does not contain 'headerValue'.", propNameSet.contains("headerValue")); - assertTrue("Property name set does not contain 'item'.", propNameSet.contains("item")); - assertTrue("Property name set does not contain 'items'.", propNameSet.contains("items")); - assertTrue("Property name set does not contain 'nCName'.", propNameSet.contains("nCName")); - assertTrue("Property name set does not contain 'otherTag'.", propNameSet.contains("otherTag")); - assertTrue("Property name set does not contain 'overallStatus'.", propNameSet.contains("overallStatus")); - assertTrue("Property name set does not contain 'smallBigDecimal'.", propNameSet.contains("smallBigDecimal")); - assertTrue("Property name set does not contain 'smallBigInteger'.", propNameSet.contains("smallBigInteger")); - assertTrue("Property name set does not contain 'smallInt'.", propNameSet.contains("smallInt")); - assertTrue("Property name set does not contain 'smallOddNumber'.", propNameSet.contains("smallOddNumber")); - assertTrue("Property name set does not contain 'statusOrMonthList'.", propNameSet.contains("statusOrMonthList")); - assertTrue("Property name set does not contain 'wierdNumber'.", propNameSet.contains("wierdNumber")); - } -} diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/PropertyTest.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/PropertyTest.java deleted file mode 100644 index e70226c10a..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/PropertyTest.java +++ /dev/null @@ -1,263 +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 static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.util.List; - -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -import test.sdo21.framework.CTSTestCase; -import test.sdo21.tests.TestData.StandardDynamicFactory; -import test.sdo21.tests.TestData.StandardFactory; -import test.sdo21.tests.TestData.TestDataFactory; - -import commonj.sdo.DataObject; -import commonj.sdo.Property; - - -public class PropertyTest extends CTSTestCase { - private DataObject testDO; - TestDataFactory factory; - - public PropertyTest() { - // Tests on the Property interface should be independent of the metadata creation mechanism - // so just pick one Standard Factory - factory = new StandardDynamicFactory(); - } - - @Before - public void setUp () throws Exception { - super.setUp(); - factory.defineMetaData(getScope()); - testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE); - } - - - @After - public void tearDown() throws Exception { - super.tearDown(); - } - - /** - * Verify Property.getDefault() for a newly created DataObject. - * @throws Exception - */ - @Test - public void testGetDefaultNewDO() throws Exception { - verifyGetDefault(factory.createTestData(getScope(), StandardFactory.API_TYPE)); - } - - /** - * Verify Property.getDefault() for a cleared DataObject. - */ - @Test - public void testGetDefaultClearedDO() { - // Set the values for each Property using populateFields, then unset - // them using unsetFields. - try { - ((StandardFactory)factory).populateFields(testDO, getScope()); - } catch (Exception e) { - fail("could not populate DataObject fields"); - } - unsetFields(testDO); - verifyGetDefault(testDO); - } - - /** - * Verify Property.getName() - */ - @Test - public void testPropertyGetName() { - Property property = testDO.getInstanceProperty("containMany"); - assertEquals("Property.getName() returned an unexpected value.", property.getName(), "containMany"); - } - - /** - * Verify Property.getType() - */ - @Test - public void testPropertyGetType() { - Property property = testDO.getInstanceProperty("containMany"); - - assertEquals("Property.getType() returned an unexpected value.", property.getType(), testDO.getType()); - } - - /** - * Verify Property.isMany()==true - */ - @Test - public void testPropertyIsManyTrue() { - Property property = testDO.getInstanceProperty("containMany"); - assertTrue("Property.isMany() returned an unexpected value.", property.isMany()); - } - - /** - * Verify Property.isMany()==false - */ - @Test - public void testPropertyIsManyFalse() { - Property property = testDO.getInstanceProperty("booleanVal"); - assertFalse("Property.isMany() returned an unexpected value.", property.isMany()); - } - - /** - * Verify Property.isContainment()==true - */ - @Test - public void testPropertyIsContainmentTrue() { - Property property = testDO.getInstanceProperty("containMany"); - assertTrue("Property.isContainment() returned an unexpected value.", property.isContainment()); - } - - /** - * Verify Property.isContainment()==false - */ - @Test - public void testPropertyIsContainmentFalse() { - Property property = testDO.getInstanceProperty("booleanVal"); - assertFalse("Property.isContainment() returned true when expecting false.", property.isContainment()); - } - - /** - * Verify Property.isReadOnly()==true - */ - @Test - public void testPropertyIsReadOnlyTrue() { - Property property = testDO.getInstanceProperty("readOnlyVal"); - assertTrue("Property.isReadOnly() returned false when expecting true.", property.isReadOnly()); - } - - /** - * Verify Property.isReadOnly()==false - */ - @Test - public void testPropertyIsReadOnlyFalse() { - Property property = testDO.getInstanceProperty("booleanVal"); - assertFalse("Property.isReadOnly() returned true when expecting false.", property.isReadOnly()); - } - - /** - * Verify Property.getContainingType - */ - @Test - public void testPropertyGetContainingType() { - Property property = testDO.getInstanceProperty("booleanVal"); - assertEquals("Property.getContainingType() returned an unexpected value.", property.getContainingType(), testDO - .getType()); - } - - /** - * Verify Property.getAliasNames() == empty List - */ - @Test - public void testPropertyGetAliasNamesEmpty() { - Property property = testDO.getInstanceProperty("booleanVal"); - assertEquals("Property.getAliasNames() returned a List of unexpected size.", 0, property.getAliasNames().size()); - } - - /** - * Verify Property.getAliasNames() == populated List - */ - @Ignore("Awaiting implementation of SDOUtil.addAliasName") - @Test - public void testPropertyGetAliasNames() { - List aliasNames = testDO.getInstanceProperty("decimalVal2").getAliasNames(); - assertEquals("Property.getAliasNames() returned a List of unexpected size.", 1, aliasNames.size()); - - String alias = (String)aliasNames.get(0); - assertEquals("Property.getAliasNames() returned a List with unexpected contents.", "Dec2", alias); - } - - /** - * Verify Property.getOpposite() == null - */ - @Test - public void testPropertyGetOppositeNull() { - Property property = testDO.getInstanceProperty("booleanVal"); - assertNull("Property.getOpposite() did not return null as expected.", property.getOpposite()); - } - - /** - * Verify Property.getOpposite() != null - */ - @Test - @Ignore - public void testPropertyGetOpposite() { - // TODO write this test - } - - /** - * verifyGetDefault is a private method that loops through each Property in - * the passed DataObject and verifies that the value is equal to the value - * returned by getDefault for each Property. The precondition is that unset - * has been called for any Property for which a value has been set. - * - * @param testedDO - */ - - private void verifyGetDefault(DataObject testedDO) { - List properties = testedDO.getInstanceProperties(); - Property property; - - for (int i = 0; i < properties.size(); i++) { - property = (Property)properties.get(i); - if (!(property.isReadOnly())) { - if (property.isMany()) { - assertNull("Property.getDefault() did not return null for many-valued Property " + property.getName() - + "'.", property.getDefault()); - } else { - assertEquals("Property.getDefault() did not return the correct default value for Property '" + property - .getName() - + "'.", testedDO.get(property), property.getDefault()); - } - } - } - } - - /** - * unsetFields() is a private method that loops through the Properties in - * the passed DataObject and unsets each Property. - * - * @param unsetDO - */ - - private void unsetFields(DataObject unsetDO) { - List properties = unsetDO.getInstanceProperties(); - Property currProp; - - for (int i = 0; i < properties.size(); i++) - { - currProp = (Property) properties.get(i); - if (!(currProp.isReadOnly())) { - unsetDO.unset(i); - } - } - } -} diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceConsistencyBase.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceConsistencyBase.java deleted file mode 100644 index 2e554e31c3..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceConsistencyBase.java +++ /dev/null @@ -1,907 +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: 536535 $ $Date: 2007-05-09 15:04:49 +0100 (Wed, 09 May 2007) $
- */
-package test.sdo21.tests.api.Sequence;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.List;
-
-import org.junit.Test;
-import org.junit.Before;
-
-import test.sdo21.tests.TestData.StandardFactory;
-import test.sdo21.tests.api.CTSConsistencyBase;
-
-import commonj.sdo.DataObject;
-import commonj.sdo.Property;
-import commonj.sdo.Sequence;
-
-public abstract class SequenceConsistencyBase extends CTSConsistencyBase {
- private DataObject sequenceDO;
-
- /**
- * getIndex is a private method used by the SequenceConsistencyBase class to accept as
- * input a Property and return the index of that Property within the
- * 'Sequenced' Type
- */
- private int getIndex(Property property) {
- List properties = sequenceDO.getType().getProperties();
- int propertyIndex = -1;
- int i = 0;
-
- while (i < properties.size() && propertyIndex < 0) {
- if (((Property)properties.get(i)).equals(property))
- propertyIndex = i;
- i++;
- }
-
- return propertyIndex;
- }
-
- /**
- * populateSequence is called before each test. It provides a set of
- * consistent data for the tests to work with. The expected outcome of
- * populateSequence is a Sequence as follows: {<Letters, "A">, <Letters,
- * "B">, <Numbers, 5>, <Letters, "C">, <Numbers, 16>}
- * @throws Exception
- */
- @Before
- public void populateSequence() throws Exception {
- sequenceDO = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE);
-
- if (sequenceDO.getType().isSequenced()) {
- Sequence sequence = sequenceDO.getSequence();
-
- // Add elements to the Sequence by updating the DataObject
-
- List letterList = sequenceDO.getList("Letters");
- List numberList = sequenceDO.getList("Numbers");
-
- letterList.add("A");
- letterList.add("B");
- numberList.add(Integer.valueOf(5));
- letterList.add("C");
- numberList.add(Integer.valueOf(16));
- }
- }
-
- /**
- * Verify that Sequence.getProperty(index) throws an Exception for an
- * invalid index.
- */
- @Test
- public void getPropertyInvalidIndexException() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
-
- try {
- sequence.getProperty(5);
- fail("Sequence.getProperty(int) should throw an Exception when an invalid index is provided.");
- } catch (Exception e) {
- }
- }
-
- /**
- * Verify that Sequence.getValue() throws an Exception for an invalid index.
- */
- @Test
- public void getValueInvalidIndexException() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
-
- try {
- sequence.getValue(5);
- fail("Sequence.getValue(int) should throw an Exception when an invalid index is provided.");
- } catch (Exception e) {
- }
- }
-
- /**
- * Verify that Sequence.remove() throws an Exception for an invalid index.
- */
- @Test
- public void removeInvalidIndexException() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
-
- try {
- sequence.remove(-1);
- fail("Sequence.remove(int) should throw an Exception when an invalid index is provided.");
- } catch (Exception e) {
- }
- }
-
- /**
- * Verify that Sequence.setValue() throws an Exception for an invalid index.
- */
- @Test
- public void setValueInvalidIndexException() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
-
- try {
- sequence.setValue(5, "attempt");
- fail("Sequence.setValue(int, Object) should throw an Exception when an invalid index is provided.");
- } catch (Exception e) {
- }
- }
-
- /**
- * Verify that Sequence.size() returns the expected value.
- */
- @Test
- public void testSize() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
-
- assertEquals("Sequence.size() returned an unexpected value.", sequence.size(), 5);
- }
-
- /**
- * Verify that Sequence.getProperty() returns the expected values.
- */
- @Test
- public void testGetProperty() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
-
- assertEquals("Sequence.getProperty() returned an unexpected Property.",
- sequenceDO.getInstanceProperty("Letters"),
- sequence.getProperty(1));
- assertEquals("Sequence.getProperty() returned an unexpected Property.",
- sequenceDO.getInstanceProperty("Numbers"),
- sequence.getProperty(4));
- }
-
- /**
- * Verify that Sequence.getValue() returns the expected values.
- */
- @Test
- public void testGetValue() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
-
- assertEquals("Sequence.getValue() returned an unexpected value.", "A", sequence.getValue(0));
- assertEquals("Sequence.getValue() returned an unexpected value.", 5, sequence.getValue(2));
- }
-
- /**
- * Use Sequence.setValue() to modify the Sequence, then verify the outcome
- */
- @Test
- public void testSetValue() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
-
- sequence.setValue(1, "F");
-
- // {<Letters, "A">, <Letters, "F">, <Numbers, 5>, <Letters, "C">,
- // <Numbers, 16>}
-
- assertEquals("Sequence.setValue() did not have the intended effect.", sequence.getValue(1), "F");
-
- List letters = sequenceDO.getList("Letters");
- assertEquals("Sequence.setValue() had an unexpected effect on the size of the List in the underlying DataObject.",
- 3,
- letters.size());
- assertEquals("Sequence.setValue() did not have the expected effect on the underlying DataObject.",
- "F",
- (String)letters.get(1));
- }
-
- /**
- * Use Sequence.remove() to modify the Sequence, then verify the outcome
- */
- @Test
- public void testRemove() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
-
- sequence.remove(1);
-
- // {<Letters, "A">, <Numbers, 5>, <Letters, "C">, <Numbers, 16>}
-
- assertEquals("Sequence.remove() did not decrement the size of the Sequence.", 4, sequence.size());
- assertEquals("Sequence.remove() did not shift the elements as expected.", 5, sequence.getValue(1));
-
- List letters = sequenceDO.getList("Letters");
- assertEquals("Sequence.remove() did not have the expected effect on the size of the List in the underlying DataObject.",
- 2,
- letters.size());
- assertEquals("Sequence.remove() did not have the expected effect on the underlying DataObject.",
- "C",
- (String)letters.get(1));
- }
-
- /**
- * Use Sequence.addText(String) to modify the Sequence, then verify the
- * outcome
- */
- @Test
- public void testAddText() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
-
- String addString = new String("Structured text at the end.");
- sequence.addText(addString);
-
- // {<Letters, "A">, <Letters, "B">, <Numbers, 5>, <Letters, "C">,
- // <Numbers, 16>, "Structured text at the end."}
-
- assertEquals("Sequence.add(String) did not increment the size of the Sequence.", 6, sequence.size());
- assertEquals("Sequence.add(String) did not place the correct value at the correct index.",
- addString,
- sequence.getValue(5));
- assertNull("Sequence.add(String) should result in a null Property in the final index.", sequence.getProperty(5));
- }
-
- /**
- * Use Sequence.addText(int, String) to modify the Sequence, then verify the
- * outcome
- */
- @Test
- public void testAddTextWithIndex() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
-
- String addString = new String("Structured text in the middle.");
- sequence.addText(2, addString);
-
- // {<Letters, "A">, <Letters, "B">, "Structured text in the middle.",
- // <Numbers, 5>, <Letters, "C">, <Numbers, 16>}
-
- assertEquals("Sequence.addText(int, String) did not increment the size of the Sequence.", 6, sequence
- .size());
- assertEquals("Sequence.addText(int, String) did not place the correct value at the correct index.",
- addString,
- sequence.getValue(2));
- assertNull("Sequence.addText(int, String) should result in a null Property in the specified index.",
- sequence.getProperty(2));
- }
-
- /**
- * Use Sequence.move() to modify the Sequence, then verify the outcome
- */
- @Test
- public void testMove() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
-
- sequence.move(1, 3);
-
- // {<Letters, "A">, <Letters, "C">, <Letters, "B">, <Numbers, 5>,
- // <Numbers, 16>}
-
- assertEquals("Sequence.move() had an unexpected effect on the size of the Sequence.", 5, sequence.size());
- assertEquals("Sequence.move() did not place the expected value at the expected location.", "C", sequence
- .getValue(1));
- assertEquals("Sequence.move() had an unexpected effect on the index following the move-to index.",
- "B",
- sequence.getValue(2));
-
- List letters = sequenceDO.getList("Letters");
- assertEquals("Sequence.remove() did not have the expected effect on the size of the List in the underlying DataObject.",
- 3,
- letters.size());
- assertEquals("Sequence.remove() did not have the expected effect on the underlying DataObject.",
- "A",
- (String)letters.get(0));
- assertEquals("Sequence.remove() did not have the expected effect on the underlying DataObject.",
- "C",
- (String)letters.get(1));
- assertEquals("Sequence.remove() did not have the expected effect on the underlying DataObject.",
- "B",
- (String)letters.get(2));
- }
-
- /**
- * Verify that Sequence.move() throws an Exception for an invalid to index.
- */
- @Test
- public void moveInvalidToIndexException() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
-
- try {
- sequence.move(5, 0);
- fail("Sequence.move(int, int) should throw an Exception when an invalid 'to' index is provided.");
- } catch (Exception e) {
- }
- }
-
- /**
- * Verify that Sequence.move() throws an Exception for an invalid from
- * index.
- */
- @Test
- public void moveInvalidFromIndexException() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
-
- try {
- sequence.move(0, -1);
- fail("Sequence.move(int, int) should throw an Exception when an invalid 'from' index is provided.");
- } catch (Exception e) {
- }
- }
-
- /**
- * Use Sequence.add(Property, Object) to modify the Sequence, then verify
- * the outcome
- */
- @Test
- public void testAddPropertyObject() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
- Property numberProp = sequenceDO.getInstanceProperty("Numbers");
-
- sequence.add(numberProp, Integer.valueOf(8));
-
- // {<Letters, "A">, <Letters, "B">, <Numbers, 5>, <Letters, "C">,
- // <Numbers, 16>, <Numbers, 8>}
-
- assertEquals("Sequence.add(Property, Object) did not increment the size of the Sequence.", 6, sequence
- .size());
- assertEquals("Sequence.add(Property, Object) did not place the expected value at the expected index.",
- 8,
- sequence.getValue(5));
- assertEquals("Sequence.add(Property, Object) did not place the expected Property at the expected index.",
- numberProp,
- sequence.getProperty(5));
-
- List numbers = sequenceDO.getList("Numbers");
-
- assertEquals("Sequence.add(Property, Object) did not have the expected effect on the size of the List in the underlying DataObject.",
- 3,
- numbers.size());
- assertEquals("Sequence.add(Property, Object) did not have the expected effect on the underlying DataObject.",
- 5,
- numbers.get(0));
- assertEquals("Sequence.add(Property, Object) did not have the expected effect on the underlying DataObject.",
- 16,
- numbers.get(1));
- assertEquals("Sequence.add(Property, Object) did not have the expected effect on the underlying DataObject.",
- 8,
- numbers.get(2));
- }
-
- /**
- * Attempt add(Property, Object) with an invalid Property and verify the
- * error handling
- * @throws Exception
- */
- @Test
- public void addPropertyObjectInvalidProperty() throws Exception {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
- DataObject testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE);
- try {
- sequence.add(testDO.getInstanceProperty("dateVal"), "A");
- fail("Sequence.add(Property, Object) should throw an Exception when an invalid Property is provided.");
- } catch (Exception e) {
- }
- }
-
- /**
- * Attempt add(Property, Object) with an invalid Object and verify the error
- * handling
- */
- @Test
- public void addPropertyObjectInvalidObject() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
-
- try {
- sequence.add(sequenceDO.getInstanceProperty("Numbers"), "A");
- fail("Sequence.add(Property, Object) should throw an Exception when an invalid Object is provided.");
- } catch (Exception e) {
- }
- }
-
- /**
- * Use Sequence.add(String, Object) to modify the Sequence, then verify the
- * outcome
- */
- @Test
- public void testAddStringObject() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
-
- sequence.add("Letters", "K");
-
- // {<Letters, "A">, <Letters, "B">, <Numbers, 5>, <Letters, "C">,
- // <Numbers, 16>, <Letters, "K">}
-
- assertEquals("Sequence.add(String, Object) did not increment the size of the Sequence.", 6, sequence
- .size());
- assertEquals("Sequence.add(String, Object) did not place the expected value at the expected index.",
- "K",
- sequence.getValue(5));
- assertEquals("Sequence.add(String, Object) did not place the expected Property at the expected index.",
- sequenceDO.getInstanceProperty("Letters"),
- sequence.getProperty(5));
-
- List letters = sequenceDO.getList("Letters");
- assertEquals("Sequence.add(String, Object) did not have the expected effect on the size of the List in the underlying DataObject.",
- 4,
- letters.size());
- assertEquals("Sequence.add(String, Object) did not have the expected effect on the underlying DataObject.",
- "A",
- (String)letters.get(0));
- assertEquals("Sequence.add(String, Object) did not have the expected effect on the underlying DataObject.",
- "B",
- (String)letters.get(1));
- assertEquals("Sequence.add(String, Object) did not have the expected effect on the underlying DataObject.",
- "C",
- (String)letters.get(2));
- assertEquals("Sequence.add(String, Object) did not have the expected effect on the underlying DataObject.",
- "K",
- (String)letters.get(3));
- }
-
- /**
- * Attempt add(String, Object) with an invalid String and verify the error
- * handling
- */
- @Test
- public void addStringObjectInvalidString() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
-
- try {
- sequence.add("NoSuchProperty", "A");
- fail("Sequence.add(String, Object) should throw an Exception when an invalid String is provided.");
- } catch (Exception e) {
- }
- }
-
- /**
- * Attempt add(String, Object) with an invalid Object and verify the error
- * handling
- */
- @Test
- public void addStringObjectInvalidObject() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
-
- try {
- sequence.add("Numbers", "A");
- fail("Sequence.add(String, Object) should throw an Exception when an invalid Object is provided.");
- } catch (Exception e) {
- }
- }
-
- /**
- * Use Sequence.add(int, Object) to modify the Sequence, then verify the
- * outcome
- */
- @Test
- public void testAddIntObject() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
-
- sequence.add(getIndex(sequenceDO.getInstanceProperty("Numbers")), Integer.valueOf(10));
-
- // {<Letters, "A">, <Letters, "B">, <Numbers, 5>, <Letters, "C">,
- // <Numbers, 16>, <Numbers, 10>}
-
- assertEquals("Sequence.add(Property, Object) did not increment the size of the Sequence.", 6, sequence
- .size());
- assertEquals("Sequence.add(Property, Object) did not place the expected value at the expected index.",
- 10,
- sequence.getValue(5));
- assertEquals("Sequence.add(Property, Object) did not place the expected Property at the expected index.",
- sequenceDO.getInstanceProperty("Numbers"),
- sequence.getProperty(5));
-
- List numbers = sequenceDO.getList("Numbers");
-
- assertEquals("Sequence.add(Property, Object) did not have the expected effect on the size of the List in the underlying DataObject.",
- 3,
- numbers.size());
- assertEquals("Sequence.add(Property, Object) did not have the expected effect on the underlying DataObject.",
- 5,
- numbers.get(0));
- assertEquals("Sequence.add(Property, Object) did not have the expected effect on the underlying DataObject.",
- 16,
- numbers.get(1));
- assertEquals("Sequence.add(Property, Object) did not have the expected effect on the underlying DataObject.",
- 10,
- numbers.get(2));
- }
-
- /**
- * Attempt add(int, Object) with an invalid int and verify the error
- * handling
- */
- @Test
- public void addIntObjectInvalidInt() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
-
- List properties = sequenceDO.getType().getProperties();
- int invalidIndex = properties.size();
-
- try {
- sequence.add(invalidIndex, Integer.valueOf(16));
- fail("Sequence.add(int, Object) should throw an Exception when an invalid index is provided.");
- } catch (Exception e) {
- }
- }
-
- /**
- * Attempt add(int, Object) with an invalid Object and verify the error
- * handling
- */
- @Test
- public void addIntObjectInvalidObject() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
-
- try {
- sequence.add(getIndex(sequenceDO.getInstanceProperty("Letters")), 7);
- fail("Sequence.add(int, Object) should throw an Exception when an invalid Object is provided.");
- } catch (Exception e) {
- }
- }
-
- /**
- * Use Sequence.add(int, String, Object) to modify the Sequence, then verify
- * the outcome
- */
- @Test
- public void testAddIntStringObject() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
-
- int sequenceIndex = 0;
-
- sequence.add(sequenceIndex, "Numbers", Integer.valueOf(10));
-
- // {<Numbers, 10>, <Letters, "A">, <Letters, "B">, <Numbers, 5>,
- // <Letters, "C">, <Numbers, 16>}
-
- assertEquals("Sequence.add(int, String, Object) did not increment the size of the Sequence.", 6, sequence
- .size());
- assertEquals("Sequence.add(int, String, Object) did not place the expected value at the expected index.",
- 10,
- sequence.getValue(sequenceIndex));
- assertEquals("Sequence.add(int, String, Object) did not place the expected Property at the expected index.",
- sequenceDO.getInstanceProperty("Numbers"),
- sequence.getProperty(sequenceIndex));
-
- List numbers = sequenceDO.getList("Numbers");
- assertEquals("Sequence.add(int, String, Object) did not have the expected effect on the size of the List in the underlying DataObject.",
- 3,
- numbers.size());
- assertEquals("Sequence.add(int, String, Object) did not have the expected effect on the underlying DataObject.",
- 10,
- (String)numbers.get(0));
- assertEquals("Sequence.add(int, String, Object) did not have the expected effect on the underlying DataObject.",
- 5,
- (String)numbers.get(1));
- assertEquals("Sequence.add(int, String, Object) did not have the expected effect on the underlying DataObject.",
- 16,
- (String)numbers.get(2));
- }
-
- /**
- * Attempt add(int, String, Object) with an invalid int and verify the error
- * handling
- */
- @Test
- public void addIntStringObjectInvalidInt() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
-
- try {
- sequence.add(-1, "Letters", "A");
- fail("Sequence.add(int, String, Object) should throw an Exception when an invalid Sequence index is provided.");
- } catch (Exception e) {
- }
- }
-
- /**
- * Attempt add(int, String, Object) with an invalid String and verify the
- * error handling
- */
- @Test
- public void addIntStringObjectInvalidString() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
-
- try {
- sequence.add(0, "Does Not Exist", "A");
- fail("Sequence.add(int, String, Object) should throw an Exception when an invalid String is provided.");
- } catch (Exception e) {
- }
- }
-
- /**
- * Attempt add(int, String, Object) with an invalid Object and verify the
- * error handling
- */
- @Test
- public void addIntStringObjectInvalidObject() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
-
- try {
- sequence.add(0, "Numbers", "A");
- fail("Sequence.add(int, String, Object) should throw an Exception when an invalid Object is provided.");
- } catch (Exception e) {
- }
- }
-
- /**
- * Use Sequence.add(int, Property, Object) to modify the Sequence, then
- * verify the outcome
- */
- @Test
- public void testAddIntPropertyObject() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
-
- int sequenceIndex = 3;
- sequence.add(sequenceIndex, "Letters", "K");
-
- // {<Letters, "A">, <Letters, "B">, <Numbers, 5>, <Letters, "K">,
- // <Letters, "C">, <Numbers, 16>}
-
- assertEquals("Sequence.add(int, Property, Object) did not increment the size of the Sequence.",
- 6,
- sequence.size());
- assertEquals("Sequence.add(int, Property, Object) did not place the expected value at the expected index.",
- "K",
- sequence.getValue(sequenceIndex));
- assertEquals("Sequence.add(int, Property, Object) did not place the expected Property at the expected index.",
- sequenceDO.getInstanceProperty("Letters"),
- sequence.getProperty(sequenceIndex));
-
- List letters = sequenceDO.getList("Letters");
- assertEquals("Sequence.add(int, Property, Object) did not have the expected effect on the size of the List in the underlying DataObject.",
- 4,
- letters.size());
- assertEquals("Sequence.add(int, Property, Object) did not have the expected effect on the underlying DataObject.",
- "A",
- (String)letters.get(0));
- assertEquals("Sequence.add(int, Property, Object) did not have the expected effect on the underlying DataObject.",
- "B",
- (String)letters.get(1));
- assertEquals("Sequence.add(int, Property, Object) did not have the expected effect on the underlying DataObject.",
- "K",
- (String)letters.get(2));
- assertEquals("Sequence.add(int, Property, Object) did not have the expected effect on the underlying DataObject.",
- "C",
- (String)letters.get(3));
- }
-
- /**
- * Attempt add(int, Property, Object) with an invalid int and verify the
- * error handling
- */
- @Test
- public void addIntPropertyObjectInvalidInt() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
-
- try {
- sequence.add(-1, sequenceDO.getInstanceProperty("Letters"), "A");
- fail("Sequence.add(int, Property, Object) should throw an Exception when an invalid Sequence index is provided.");
- } catch (Exception e) {
- }
- }
-
- /**
- * Attempt add(int, Property, Object) with an invalid Property and verify
- * the error handling
- * @throws Exception
- */
- @Test
- public void addIntPropertyObjectInvalidProperty() throws Exception {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
- DataObject testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE);
-
- try {
- sequence.add(0, testDO.getInstanceProperty("dateVal"), "A");
- fail("Sequence.add(int, Property, Object) should throw an Exception when an invalid Property is provided.");
- } catch (Exception e) {
- }
- }
-
- /**
- * Attempt add(int, Property, Object) with an invalid Object and verify the
- * error handling
- */
- @Test
- public void addIntPropertyObjectInvalidObject() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
-
- try {
- sequence.add(0, sequenceDO.getInstanceProperty("Numbers"), "A");
- fail("Sequence.add(int, Property, Object) should throw an Exception when an invalid Object is provided.");
- } catch (Exception e) {
- }
- }
-
- /**
- * Use Sequence.add(int, int, Object) to modify the Sequence, then verify
- * the outcome
- */
- @Test
- public void testAddIntIntObject() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
-
- int sequenceIndex = 5;
-
- sequence.add(sequenceIndex, "Numbers", Integer.valueOf(10));
-
- // {<Letters, "A">, <Letters, "B">, <Numbers, 5>, <Letters, "C">,
- // <Numbers, 16>, <Numbers, 10>}
-
- assertEquals("Sequence.add(int, String, Object) did not increment the size of the Sequence.", 6, sequence
- .size());
- assertEquals("Sequence.add(int, String, Object) did not place the expected value at the expected index.",
- 10,
- sequence.getValue(sequenceIndex));
- assertEquals("Sequence.add(int, String, Object) did not place the expected Property at the expected index.",
- sequenceDO.getInstanceProperty("Numbers"),
- sequence.getProperty(sequenceIndex));
-
- List numbers = sequenceDO.getList("Numbers");
- assertEquals("Sequence.add(int, String, Object) did not have the expected effect on the size of the List in the underlying DataObject.",
- 3,
- numbers.size());
- assertEquals("Sequence.add(int, String, Object) did not have the expected effect on the underlying DataObject.",
- 5,
- (String)numbers.get(0));
- assertEquals("Sequence.add(int, String, Object) did not have the expected effect on the underlying DataObject.",
- 16,
- (String)numbers.get(1));
- assertEquals("Sequence.add(int, String, Object) did not have the expected effect on the underlying DataObject.",
- 10,
- (String)numbers.get(2));
- }
-
- /**
- * Attempt add(int, int, Object) with an invalid Sequence index and verify
- * the error handling
- */
- @Test
- public void addIntIntObjectInvalidSequenceIndex() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
-
- try {
- sequence.add(6, getIndex(sequenceDO.getInstanceProperty("Letters")), "A");
- fail("Sequence.add(int, int, Object) should throw an Exception when an invalid Sequence index is provided.");
- } catch (Exception e) {
- }
- }
-
- /**
- * Attempt add(int, int, Object) with an invalid Property index and verify
- * the error handling
- */
- @Test
- public void addIntIntObjectInvalidPropertyIndex() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
-
- try {
- sequence.add(0, -1, "A");
- fail("Sequence.add(int, int, Object) should throw an Exception when an invalid Property index is provided.");
- } catch (Exception e) {
- }
- }
-
- /**
- * Attempt add(int, int, Object) with an invalid Object and verify the error
- * handling
- */
- @Test
- public void addIntIntObjectInvalidObject() {
- assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
- sequenceDO.getType().isSequenced());
-
- Sequence sequence = sequenceDO.getSequence();
-
- try {
- sequence.add(0, getIndex(sequenceDO.getInstanceProperty("Letters")), 8);
- fail("Sequence.add(int, int, Object) should throw an Exception when an invalid Object is provided.");
- } catch (Exception e) {
- }
- }
-}
diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceConsistencyDynamic.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceConsistencyDynamic.java deleted file mode 100644 index b97aa8e405..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceConsistencyDynamic.java +++ /dev/null @@ -1,34 +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: 537775 $ $Date: 2007-05-14 11:55:54 +0100 (Mon, 14 May 2007) $
- */
-package test.sdo21.tests.api.Sequence;
-
-import test.sdo21.tests.TestData.StandardDynamicFactory;
-import test.sdo21.tests.TestData.TestDataFactory;
-
-public class SequenceConsistencyDynamic extends SequenceConsistencyBase {
-
- public TestDataFactory createTestDataFactory() {
-
- return new StandardDynamicFactory();
- }
-
-
-}
diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceConsistencySuite.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceConsistencySuite.java deleted file mode 100644 index 4c9d43a33a..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceConsistencySuite.java +++ /dev/null @@ -1,31 +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: 537775 $ $Date: 2007-05-14 11:55:54 +0100 (Mon, 14 May 2007) $
- */
-package test.sdo21.tests.api.Sequence;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses( {SequenceConsistencyDynamic.class,
- SequenceConsistencyXSD.class})
-public class SequenceConsistencySuite {
-
-}
diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceConsistencyXSD.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceConsistencyXSD.java deleted file mode 100644 index 4ebc45ae2f..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceConsistencyXSD.java +++ /dev/null @@ -1,34 +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: 537775 $ $Date: 2007-05-14 11:55:54 +0100 (Mon, 14 May 2007) $
- */
-package test.sdo21.tests.api.Sequence;
-
-import test.sdo21.tests.TestData.StandardXSDFactory;
-import test.sdo21.tests.TestData.TestDataFactory;
-
-public class SequenceConsistencyXSD extends SequenceConsistencyBase {
-
- public TestDataFactory createTestDataFactory() {
-
- return new StandardXSDFactory();
- }
-
-
-}
diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceTest.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceTest.java deleted file mode 100644 index b09d0597f3..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceTest.java +++ /dev/null @@ -1,100 +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.api.Sequence;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-import commonj.sdo.DataObject;
-import commonj.sdo.Sequence;
-import commonj.sdo.Type;
-import commonj.sdo.helper.DataFactory;
-import commonj.sdo.helper.TypeHelper;
-
-import test.sdo21.framework.CTSTestCase;
-
-/**
- * Set of tests for Sequence APIs.
- */
-public class SequenceTest extends CTSTestCase {
-
-
- @Before
- public void setUp() throws Exception {
- super.setUp();
- }
-
- @After
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
- /**
- * Test to ensure that once an isMany=false property within a sequenced type
- * retains an existing position in the sequence following an update.
- *@see <A href="http://www.xcalia.com/support/browse/SDO-242">SDO Spec Jira 242</a>
- */
- @Test
- public void testSeqWhenIsManyFalseAndValueUpdated()
- {
-
- DataFactory df = getScope().getDataFactory();
- TypeHelper th = getScope().getTypeHelper();
-
- Type stringType = th.getType("commonj.sdo", "String");
-
- DataObject typeModel = df.create("commonj.sdo", "Type");
- typeModel.set("name", "name");
- typeModel.set("uri", "example.org");
- typeModel.set("sequenced", true);
-
- DataObject property1 = typeModel.createDataObject("property");
- property1.set("name", "givenname");
- property1.set("type", stringType);
-
- DataObject property2 = typeModel.createDataObject("property");
- property2.set("name", "familyname");
- property2.set("type", stringType);
-
- th.define(typeModel);
-
- DataObject aName = df.create("example.org", "name");
-
- aName.set("familyname", "Smith");
- aName.set("givenname", "John");
-
- Sequence seq = aName.getSequence();
- // System.out.println(getScope().getXMLHelper().save(aName, "example./org", "aName"));
-
- assertEquals(seq.getValue(0), "Smith");
- assertEquals(seq.getValue(1), "John");
-
- aName.set("familyname", "Jones");
- // System.out.println(getScope().getXMLHelper().save(aName, "example./org", "aName"));
-
- assertEquals(seq.size(), 2);
-
- assertEquals(seq.getValue(0), "Jones");
- assertEquals(seq.getValue(1), "John");
-
- }
-}
diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/SequenceAddOpenTest.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/SequenceAddOpenTest.java deleted file mode 100644 index 73ea84f0d2..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/SequenceAddOpenTest.java +++ /dev/null @@ -1,435 +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 junit.framework.TestCase; -import test.sdo21.framework.TestHelper; -import test.sdo21.framework.junit3_8.CTSTestCase; -import test.sdo21.CTSSuite; -import commonj.sdo.DataObject; -import commonj.sdo.Property; -import commonj.sdo.Sequence; -import commonj.sdo.Type; -import commonj.sdo.helper.HelperContext; -import commonj.sdo.helper.TypeHelper; -import commonj.sdo.helper.DataFactory; - -/** - * Tests adding objects to a sequence. Note: the tests in this test case must be run sequentially as each test - * depends on state from the previous test. - */ -public class SequenceAddOpenTest extends CTSTestCase { - - protected TestHelper testHelper; - protected DataFactory dataFactory; - protected TypeHelper typeHelper; - protected DataObject testOpenDataObject; - - public SequenceAddOpenTest(String string) { - super(string); - } - - public void setUp() throws Exception { - super.setUp(); - - HelperContext scope = getScope(); - testHelper = getTestHelper(); - dataFactory = scope.getDataFactory(); - typeHelper = scope.getTypeHelper(); - - // define an open type if it is not already defined in the HelperContext provided - // by the implementation being tested - String typeURI = "http://www.example.com/cts/SequenceAddOpenTest"; - String typeName = "OpenDataObject"; - Type openType = typeHelper.getType(typeURI, typeName); - if (openType == null) { - DataObject typeDef = dataFactory.create("commonj.sdo", "Type"); - typeDef.set("uri", typeURI); - typeDef.set("name", typeName); - typeDef.set("open", true); - typeDef.set("sequenced", true); - openType = typeHelper.define(typeDef); - } - - testOpenDataObject = dataFactory.create( openType ); - } - - /** - * Tests the SDO 2.1 Sequence method for the - * java type of Boolean - * <p/> - * boolean add(String propertyName, Object value) - */ - public void testAddBooleanByName() throws Exception { - - //Get a sequence to add to - Sequence testSequence = testOpenDataObject.getSequence(); - - //Add 3 proprerties - testSequence.add("testBoolean1", Boolean.TRUE); - testSequence.add("testBoolean2", Boolean.FALSE); - testSequence.add("testBoolean3", Boolean.TRUE); - - //Check that the size is reported correctly - //with the size of 3. - assertEquals(3, testSequence.size()); - - //Check the values that were added - assertEquals(Boolean.TRUE, testSequence.getValue(0)); - assertEquals(Boolean.FALSE, testSequence.getValue(1)); - assertEquals(Boolean.TRUE, testSequence.getValue(2)); - - Property prop = testSequence.getProperty(0); - - //OnDemand property should be a string - //Checking only the first property - assertEquals("testBoolean1", prop.getName()); - assertEquals("BooleanObject", prop.getType().getName()); - - } - - /** - * Tests the SDO 2.1 Sequence method for the - * java type of Boolean - * <p/> - * boolean add(Property property, Object value) - */ - public void testAddBooleanByProperty() throws Exception { - - DataObject prop = dataFactory.create("commonj.sdo", "Property"); - prop.set("type", typeHelper.getType("commonj.sdo", "Boolean")); - prop.set("name", "testBoolean1"); - - Property openProp = typeHelper.defineOpenContentProperty(null, prop); - Sequence testSequence = testOpenDataObject.getSequence(); - testSequence.add(openProp, new Boolean(false)); - assertEquals(Boolean.FALSE, testSequence.getValue(0)); - - openProp = testSequence.getProperty(0); - - //OnDemand property should be a string - //Checking only the first property - assertEquals("testBoolean1", openProp.getName()); - assertEquals("Boolean", openProp.getType().getName()); - - } - - /** - * Tests the SDO 2.1 Sequence method for the - * java type of Boolean - * <p/> - * boolean add(int propertyIndex, Object value) - */ - public void testAddBooleanByPropertyIndex() throws Exception { - - Sequence testSequence = testOpenDataObject.getSequence(); - testSequence.add("testBoolean", new Boolean(true)); - testSequence.add("testBoolean", new Boolean(false)); - - //Actual value to test from sequence - testSequence.add(0, new Boolean(false)); - assertEquals(Boolean.FALSE, testSequence.getValue(2)); - - } - - /** - * Tests the SDO 2.1 Sequence method for the - * java type of Boolean - * <p/> - * boolean add(int index, String propertyName, Object value) - */ - public void testAddBooleanByIndexAndPropertyName() throws Exception { - - //Get a sequence from the test fixture DataObject - Sequence testSequence = testOpenDataObject.getSequence(); - - testSequence.add(0, "testBoolean", new Boolean(true)); - assertEquals(Boolean.TRUE, testSequence.getValue(0)); - - } - - /** - * Tests the SDO 2.1 Sequence method for the - * java type of Boolean - * <p/> - * boolean add(int index, Property property, Object value) - */ - public void testAddBooleanByIndexAndProperty() throws Exception { - - DataObject prop = dataFactory.create("commonj.sdo", "Property"); - prop.set("type", typeHelper.getType("commonj.sdo", "Boolean")); - prop.set("name", "testBoolean"); - - Property openProp = typeHelper.defineOpenContentProperty(null, prop); - Sequence testSequence = testOpenDataObject.getSequence(); - testSequence.add(0, openProp, new Boolean(false)); - assertEquals(Boolean.FALSE, testSequence.getValue(0)); - - } - - /** - * Tests the SDO 2.1 Sequence method for the - * java type of Boolean - * <p/> - * boolean add(int index, int propertyIndex, Object value) - */ - public void testSequenceAddBooleanByIndexAndPropertyIndex() throws Exception { - - Sequence testSequence = testOpenDataObject.getSequence(); - testSequence.add("testBoolean", new Boolean(true)); - testSequence.add("testBoolean", new Boolean(false)); - - //Actual value to test from sequence - testSequence.add(0, 0, new Boolean(false)); - assertEquals(Boolean.FALSE, testSequence.getValue(2)); - - } - - /** - * Tests the SDO 2.1 Sequence method for the - * java type of String - * <p/> - * boolean add(String propertyName, Object value) - */ - public void testAddStringByName() throws Exception { - - //Get a sequence to add to - Sequence testSequence = testOpenDataObject.getSequence(); - - testSequence.add("testString", new String("testString")); - assertEquals("testString", testSequence.getValue(0)); - - } - - /** - * Tests the SDO 2.1 Sequence method for the - * java type of String - * <p/> - * boolean add(Property property, Object value) - */ - public void testAddStringByProperty() throws Exception { - - DataObject prop = dataFactory.create("commonj.sdo", "Property"); - prop.set("type", typeHelper.getType("commonj.sdo", "String")); - prop.set("name", "testString"); - - Property openProp = typeHelper.defineOpenContentProperty(null, prop); - Sequence testSequence = testOpenDataObject.getSequence(); - - //Actual value to test - testSequence.add(openProp, new String("testString")); - assertEquals("testString", testSequence.getValue(0)); - - } - - /** - * Tests the SDO 2.1 Sequence method for the - * java type of String - * <p/> - * boolean add(int propertyIndex, Object value) - */ - public void testAddStringByPropertyIndex() throws Exception { - - Sequence testSequence = testOpenDataObject.getSequence(); - - //Add additional duplicate properties - testSequence.add("testString", new String("testString")); - testSequence.add("testString", new String("testString1")); - - //Actual value to check - testSequence.add(0, (Object)new String("testString2")); - assertEquals("testString2", testSequence.getValue(2)); - - - } - - /** - * Tests the SDO 2.1 Sequence method for the - * java type of String - * <p/> - * boolean add(int index, String propertyName, Object value) - */ - public void testAddStringByIndexAndPropertyName() throws Exception { - - //Get a sequence from the test fixture DataObject - Sequence testSequence = testOpenDataObject.getSequence(); - - //Actual value to test - testSequence.add(0, "testString", new String("testString")); - assertEquals("testString", testSequence.getValue(0)); - - } - - /** - * Tests the SDO 2.1 Sequence method for the - * java type of String - * <p/> - * boolean add(int index, Property property, Object value) - */ - public void testAddStringByIndexAndProperty() throws Exception { - - DataObject prop = dataFactory.create("commonj.sdo", "Property"); - prop.set("type", typeHelper.getType("commonj.sdo", "String")); - prop.set("name", "testString"); - - Property openProp = typeHelper.defineOpenContentProperty(null, prop); - Sequence testSequence = testOpenDataObject.getSequence(); - - //Actual value to test - testSequence.add(0, openProp, new String("testString")); - assertEquals("testString", testSequence.getValue(0)); - - } - - /** - * Tests the SDO 2.1 Sequence method for the - * java type of String - * <p/> - * boolean add(int index, int propertyIndex, Object value) - */ - public void testSequenceAddStringByIndexAndPropertyIndex() throws Exception { - - Sequence testSequence = testOpenDataObject.getSequence(); - testSequence.add("testString", new String("testString1")); - testSequence.add("testString", new String("testString2")); - - //Actual value to test from the sequence - testSequence.add(0, 0, new String("testString")); - assertEquals("testString2", testSequence.getValue(2)); - - } - - /** - * Tests the SDO 2.1 Sequence method for the - * java type of Character - * <p/> - * boolean add(Character propertyName, Object value) - */ - public void testAddCharacterByName() throws Exception { - - //Get a sequence to add to - Sequence testSequence = testOpenDataObject.getSequence(); - - testSequence.add("testCharacter", new Character('A')); - assertEquals('A', testSequence.getValue(0)); - - } - - /** - * Tests the SDO 2.1 Sequence method for the - * java type of Character - * <p/> - * boolean add(Property property, Object value) - */ - public void testAddCharacterByProperty() throws Exception { - - DataObject prop = dataFactory.create("commonj.sdo", "Property"); - prop.set("type", typeHelper.getType("commonj.sdo", "Character")); - prop.set("name", "testCharacter"); - - Property openProp = typeHelper.defineOpenContentProperty(null, prop); - Sequence testSequence = testOpenDataObject.getSequence(); - - //Actual value to test - testSequence.add(openProp, new Character('A')); - assertEquals('A', testSequence.getValue(0)); - - } - - /** - * Tests the SDO 2.1 Sequence method for the - * java type of Character - * <p/> - * boolean add(int propertyIndex, Object value) - */ - public void testAddCharacterByPropertyIndex() throws Exception { - - Sequence testSequence = testOpenDataObject.getSequence(); - - //Add additional duplicate properties - testSequence.add("testCharacter", new Character('A')); - testSequence.add("testCharacter", new Character('B')); - - //Actual value to check - testSequence.add(0, new Character('C')); - assertEquals('C', testSequence.getValue(2)); - - - } - - /** - * Tests the SDO 2.1 Sequence method for the - * java type of Character - * <p/> - * boolean add(int index, Character propertyName, Object value) - */ - public void testAddCharacterByIndexAndPropertyName() throws Exception { - - //Get a sequence from the test fixture DataObject - Sequence testSequence = testOpenDataObject.getSequence(); - - //Actual value to test - testSequence.add(0, "testCharacter", new Character('A')); - assertEquals('A', testSequence.getValue(0)); - - } - - /** - * Tests the SDO 2.1 Sequence method for the - * java type of Character - * <p/> - * boolean add(int index, Property property, Object value) - */ - public void testAddCharacterByIndexAndProperty() throws Exception { - - DataObject prop = dataFactory.create("commonj.sdo", "Property"); - prop.set("type", typeHelper.getType("commonj.sdo", "Character")); - prop.set("name", "testCharacter"); - - Property openProp = typeHelper.defineOpenContentProperty(null, prop); - Sequence testSequence = testOpenDataObject.getSequence(); - - //Actual value to test - testSequence.add(0, openProp, new Character('A')); - assertEquals('A', testSequence.getValue(0)); - - } - - /** - * Tests the SDO 2.1 Sequence method for the - * java type of Character - * <p/> - * boolean add(int index, int propertyIndex, Object value) - */ - public void testSequenceAddCharacterByIndexAndPropertyIndex() throws Exception { - - Sequence testSequence = testOpenDataObject.getSequence(); - testSequence.add("testCharacter", new Character('A')); - testSequence.add("testCharacter", new Character('B')); - - //Actual value to test from the sequence - testSequence.add(0, 0, new Character('C')); - assertEquals('C', testSequence.getValue(0)); - assertEquals('A', testSequence.getValue(1)); - assertEquals('B', testSequence.getValue(2)); - - } -} 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")); - - } -} diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/TypeHelper/TypeHelperTest.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/TypeHelper/TypeHelperTest.java deleted file mode 100644 index 31384c7372..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/TypeHelper/TypeHelperTest.java +++ /dev/null @@ -1,436 +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: 552500 $ $Date: 2007-07-02 15:18:46 +0100 (Mon, 02 Jul 2007) $
- */
-package test.sdo21.tests.api.TypeHelper;
-
-import commonj.sdo.helper.HelperContext;
-import commonj.sdo.helper.TypeHelper;
-import commonj.sdo.DataObject;
-import commonj.sdo.Type;
-
-import test.sdo21.tests.TestData.StandardFactory;
-import test.sdo21.tests.TestData.TestDataFactory;
-import test.sdo21.tests.TestData.StandardXSDFactory;
-import test.sdo21.tests.util.CTSUtil;
-import test.sdo21.framework.CTSTestCase;
-
-import java.util.List;
-import java.util.ArrayList;
-
-import static org.junit.Assert.*;
-
-import org.junit.*;
-
-public class TypeHelperTest extends CTSTestCase {
-
- TestDataFactory factory;
-
- public TypeHelperTest() {
- // Tests on the Property interface should be independent of the metadata creation mechanism
- // so just pick one Standard Factory
- factory = new StandardXSDFactory();
- }
-
- @Before
- public void setUp() throws Exception {
- super.setUp();
- factory.defineMetaData(getScope());
- }
-
-
- @After
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
- /**
- * Test that newly defined type has correct default values for open, sequenced, abstract, dataType
- */
- @Test
- public void testNewTypeDefaults() {
- HelperContext scope = getScope();
- TypeHelper typeHelper = scope.getTypeHelper();
- DataObject defineDO2 = scope.getDataFactory().create("commonj.sdo", "Type");
- defineDO2.set("uri", StandardFactory.TEST_NAMESPACE);
- defineDO2.set("name", "testNewTypeOpenIsFalse");
- Type t = typeHelper.define(defineDO2);
- assertFalse("Newly created type should have open=false by default", t.isOpen());
- assertFalse("Newly created type should have abstract=false by default", t.isAbstract());
- assertFalse("Newly created type should have sequenced=false by default", t.isSequenced());
- assertFalse("Newly created type should have dataType=false by default", t.isDataType());
- }
-
- /**
- * Verify the performance of TypeHelper.getType(URI, Name)
- *
- * @throws Exception
- */
- @Test
- public void getTypeByURI() throws Exception {
- DataObject testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE);
- Type testType = testDO.getType();
-
- TypeHelper typeHelper = getScope().getTypeHelper();
- Type returnedType = typeHelper.getType(testType.getURI(), testType.getName());
-
- // TODO I thinkk we can assert that the types are the same instance here?
- assertTrue("TypeHelper.getType(URI, Name) did not return the expected Type.", CTSUtil.areEqualTypes(returnedType, testType));
- }
-
- /**
- * Verify the performance of TypeHelper.getType(Class)
- *
- * @throws Exception
- */
- @Test
- @Ignore("this test currently never reaches the interesting assertion")
- public void getTypeByClass() throws Exception {
- DataObject testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE);
- Type testType = testDO.getType();
-
- TypeHelper typeHelper = getScope().getTypeHelper();
- Type returnedType = typeHelper.getType(testType.getURI(), testType.getName());
-
- if (testType.getInstanceClass() != null) {
- returnedType = typeHelper.getType(testType.getInstanceClass());
- assertTrue("TypeHelper.getType(Class) did not return the expected Type.",
- CTSUtil.areEqualTypes(returnedType, testType));
- }
- }
-
- /**
- * Verify the proper performance of TypeHelper.getType(Class) when a non-SDO
- * class is passed to TypeHelper.getType(Class)
- */
- @Test
- public void getTypeWithNonSDOClass() {
- TypeHelper typeHelper = getTestHelper().createHelperContext().getTypeHelper();
-
- assertNull("TypeHelper.getType(Class) should return null when no Type was defined for the interface Class.",
- typeHelper.getType(TypeHelperTest.class));
- }
-
- /**
- * Verify the proper performance of TypeHelper.getClass(URI, Name) when the
- * namespace for URI does not include Name
- */
- @Test
- public void getTypeByURIWithInvalidName() throws Exception {
- DataObject testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE);
- TypeHelper typeHelper = getScope().getTypeHelper();
-
- assertNull("TypeHelper.getType(URI, Name) should return null when no Type has the indicated Name in the URI namespace.",
- typeHelper.getType(testDO.getType().getURI(), "UndefinedName"));
- }
-
- /**
- * Verify the proper performance of TypeHelper.getClass(URI, Name) when the
- * Name exists but not in the namespace of the URI
- *
- * @throws Exception
- */
- @Test
- public void getTypeByURIWithInvalidURI() throws Exception {
- DataObject testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE);
- TypeHelper typeHelper = getScope().getTypeHelper();
-
- assertNull("TypeHelper.getType(URI, Name) should return null when no Type has the indicated Name in the URI namespace.",
- typeHelper.getType("UndefinedURI", testDO.getType().getName()));
- }
-
- /**
- * Verify the performance of TypeHelper.define(DataObject), use
- * DataFactory.create(URI, name) to verify
- *
- * @throws Exception
- */
- @Test
- public void DefineByDataObjectCreateByURI() throws Exception {
- HelperContext scope = getScope();
- DataObject testDO = factory.createTestData(scope, StandardFactory.API_TYPE);
-
- TypeHelper typeHelper = scope.getTypeHelper();
- Type stringType = typeHelper.getType("commonj.sdo", "String");
-
- DataObject defineTypeDO = scope.getDataFactory().create("commonj.sdo", "Type");
- defineTypeDO.set("uri", StandardFactory.TEST_NAMESPACE);
- defineTypeDO.set("name", "DefinedType1");
- DataObject IDProperty = defineTypeDO.createDataObject("property");
- IDProperty.set("name", "ID");
- IDProperty.set("type", stringType);
- DataObject DOProperty = defineTypeDO.createDataObject("property");
- DOProperty.set("name", "contained");
- DOProperty.set("type", testDO.getType());
- typeHelper.define(defineTypeDO);
-
- // Verify the Type definition by creating a DataObject of the newly
- // defined Type via DataFactory.create(URI, name).
-
- DataObject result =
- scope.getDataFactory().create(StandardFactory.TEST_NAMESPACE,
- defineTypeDO.getString("name"));
- assertNotNull("CTSSuite.getTestHelper().getDataFactory() returned null", result);
- assertEquals("CTSSuite.getTestHelper().getDataFactory()e did not create a Type that could be instantiated.",
- result.getType().getName(),
- "DefinedType1");
- assertNotNull("CTSSuite.getTestHelper().getDataFactory() did not create a Type that could be instantiated, getProperty(ID) was null",
- result.getInstanceProperty("ID"));
- }
-
- /**
- * Verify the performance of TypeHelper.define(DataObject), use
- * DataFactory.create(Type) to verify
- *
- * @throws Exception
- */
- @Test
- public void DefineByDataObjectCreateByType() throws Exception {
- HelperContext scope = getScope();
- DataObject testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE);
- TypeHelper typeHelper = scope.getTypeHelper();
- Type stringType = typeHelper.getType("commonj.sdo", "String");
-
- DataObject defineTypeDO = scope.getDataFactory().create("commonj.sdo", "Type");
- defineTypeDO.set("uri", StandardFactory.TEST_NAMESPACE);
- defineTypeDO.set("name", "DefinedType2");
- DataObject IDProperty = defineTypeDO.createDataObject("property");
- IDProperty.set("name", "ID");
- IDProperty.set("type", stringType);
- DataObject DOProperty = defineTypeDO.createDataObject("property");
- DOProperty.set("name", "contained");
- DOProperty.set("type", testDO.getType());
- Type definedType = typeHelper.define(defineTypeDO);
-
- // Verify the Type definition by creating a DataObject of the newly
- // defined Type via DataFactory.create(Type)
-
- DataObject result = scope.getDataFactory().create(definedType);
- assertNotNull("TypeHelper.define(DataObject) returned null", result);
- assertEquals("TypeHelper.define(DataObject) did not create a Type that could be instantiated.", result
- .getType().getName(), "DefinedType2");
- assertNotNull("TypeHelper.define(DataObject) did not create a Type that could be instantiated, getProperty(ID) was null",
- result.getInstanceProperty("ID"));
- }
-
- /**
- * Verify the performance of TypeHelper.define(List)
- *
- * @throws Exception
- */
- @Test
- public void DefineByList() throws Exception {
- HelperContext scope = getScope();
- DataObject testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE);
- TypeHelper typeHelper = scope.getTypeHelper();
- Type stringType = typeHelper.getType("commonj.sdo", "String");
-
- DataObject define3 = scope.getDataFactory().create("commonj.sdo", "Type");
- define3.set("uri", StandardFactory.TEST_NAMESPACE);
- define3.set("name", "DefinedType3");
- DataObject firstNameProperty = define3.createDataObject("property");
- firstNameProperty.set("name", "firstName");
- firstNameProperty.set("type", stringType);
- DataObject DOProperty = define3.createDataObject("property");
- DOProperty.set("name", "contained");
- DOProperty.set("type", testDO.getType());
-
- DataObject define4 = scope.getDataFactory().create("commonj.sdo", "Type");
- define4.set("uri", StandardFactory.TEST_NAMESPACE);
- define4.set("name", "DefinedType4");
- DataObject lastNameProperty = define4.createDataObject("property");
- lastNameProperty.set("name", "lastName");
- lastNameProperty.set("type", stringType);
- DataObject DOProperty2 = define4.createDataObject("property");
- DOProperty2.set("name", "contained");
- DOProperty2.set("type", testDO.getType());
-
- List DOList = new ArrayList();
- DOList.add(define3);
- DOList.add(define4);
-
- List types = typeHelper.define(DOList);
-
- assertEquals("TypeHelper.define(List) should define the same number of Types as is present in List.", 2, types
- .size());
- Type typeInList = (Type) types.get(0);
- Type define4Type;
- if (typeInList.getName().equals("DefinedType3")) {
- typeInList = (Type) types.get(1);
- assertEquals("TypeHelper.define(List) returned a List that did not include Types with the expected names.",
- "DefinedType4",
- typeInList.getName());
- define4Type = typeInList;
- } else {
- define4Type = typeInList;
- assertEquals("TypeHelper.define(List) returned a List that did not include Types with the expected names.",
- "DefinedType4",
- typeInList.getName());
- typeInList = (Type) types.get(1);
- assertEquals("TypeHelper.define(List) returned a List that did not include Types with the expected names.",
- "DefinedType3",
- typeInList.getName());
- }
-
- // Attempt to create one of the Types using DataFactory.create(URI,
- // name)
-
- DataObject result =
- scope.getDataFactory().create(StandardFactory.TEST_NAMESPACE,
- define3.getString("name"));
- assertNotNull("TypeHelper.define(List) did not create a Type that could be instantiated with DataFactory.create(URI, name). result is null.",
- result);
- assertEquals("TypeHelper.define(List) did not create a Type that could be instantiated with DataFactory.create(URI, name). getType() incorrect",
- result.getType().getName(),
- "DefinedType3");
- assertNotNull("TypeHelper.define(List) did not create a Type that could be instantiated with DataFactory.create(URI, name). firstName property returned null",
- result.getInstanceProperty("firstName"));
-
- // Attempt to create the other type using DataFactory.create(Type)
-
- result = scope.getDataFactory().create(define4Type);
-
- assertNotNull("TypeHelper.define(List) did not create a Type that could be instantiated with DataFactory.create(Type). result is null.",
- result);
- assertEquals("TypeHelper.define(List) did not create a Type that could be instantiated with DataFactory.create(Type). getType() incorrect",
- result.getType().getName(),
- "DefinedType4");
- assertNotNull("TypeHelper.define(List) did not create a Type that could be instantiated with DataFactory.create(Type). lastName property returned null",
- result.getInstanceProperty("lastName"));
- }
-
- /**
- * Verify the error handling of TypeHelper.define(List) when List contains a
- * member that is not a DataObject
- *
- * @throws Exception
- */
- @Test
- public void DefineByListInvalidListMember() throws Exception {
- HelperContext scope = getScope();
- DataObject testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE);
- TypeHelper typeHelper = scope.getTypeHelper();
- Type intType = typeHelper.getType("commonj.sdo", "Int");
-
- DataObject define5 = scope.getDataFactory().create("commonj.sdo", "Type");
- define5.set("uri", StandardFactory.TEST_NAMESPACE);
- define5.set("name", "DefinedType5");
- DataObject ID1Property = define5.createDataObject("property");
- ID1Property.set("name", "ID1");
- ID1Property.set("type", intType);
- DataObject DOProperty = define5.createDataObject("property");
- DOProperty.set("name", "contained");
- DOProperty.set("type", testDO.getType());
-
- DataObject define6 = scope.getDataFactory().create("commonj.sdo", "Type");
- define6.set("uri", StandardFactory.TEST_NAMESPACE);
- define6.set("name", "DefinedType6");
- DataObject ID2Property = define6.createDataObject("property");
- ID2Property.set("name", "ID2");
- ID2Property.set("type", intType);
-
- List DOList = new ArrayList();
- DOList.add(define5);
- DOList.add("A");
- DOList.add(define6);
-
- try {
- typeHelper.define(DOList);
- fail("TypeHelper.define(List) should throw an Exception when List " + "contains a member that is not a DataObject.");
- } catch (Exception e) {
- // Do nothing
- }
- }
-
- /**
- * Verify the expected behavior of TypeHelper.define(DataObject) when a Type
- * of the same name has already been defined differently.
- *
- * @throws Exception
- */
- @Test
- @Ignore
- public void singleRedefinitionDifferent() throws Exception {
- // TODO complete this test case
- HelperContext scope = getScope();
- DataObject testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE);
-
- TypeHelper typeHelper = scope.getTypeHelper();
- Type intType = typeHelper.getType("commonj.sdo", "Int");
-
- // Determine what should happen when a Type is redefined (same URI
- // & Name, but different properties).
- // When this is known, uncomment the following and supply the
- // appropriate test.
- // While it's not clear to what should happen (from the spec), what is
- // happening is that there is no
- // notification of the duplication, and the originally defined Type is
- // returned by the define() in the latter instance.
-
- DataObject defineDO = scope.getDataFactory().create("commonj.sdo", "Type");
- defineDO.set("uri", StandardFactory.TEST_NAMESPACE);
- defineDO.set("name", "DefineTypeAgain");
- DataObject numProperty = defineDO.createDataObject("property");
- numProperty.set("name", "num");
- numProperty.set("type", intType);
-
- typeHelper.define(defineDO);
-
- DataObject defineDO2 = scope.getDataFactory().create("commonj.sdo", "Type");
- defineDO2.set("uri", StandardFactory.TEST_NAMESPACE);
- defineDO2.set("name", "DefineTypeAgain");
- DataObject DOProperty = defineDO2.createDataObject("property");
- DOProperty.set("name", "contained");
- DOProperty.set("type", testDO.getType());
-
- typeHelper.define(defineDO2);
- }
-
- /**
- * Verify the expected behavior of TypeHelper.define(DataObject) when a Type
- * of the same name has already been defined, but defined identically.
- */
- @Test
- @Ignore
- public void singleRedefinitionSame() {
- // TODO implement test
- }
-
- /**
- * Verify the expected behavior of TypeHelper.define(List) when an element
- * of the List has already been defined differently.
- */
- @Test
- @Ignore
- public void listRedefinitionDifferent() {
- // TODO implement test
- }
-
- /**
- * Verify the expected behavior of TypeHelper.define(List) when an element
- * of the List has already been defined identically.
- */
- @Test
- @Ignore
- public void listRedefinitionSame() {
- //TODO implement test
- }
-
-
-}
diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/TypeTest.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/TypeTest.java deleted file mode 100644 index 5f5c23ad5f..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/TypeTest.java +++ /dev/null @@ -1,354 +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 static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.util.List; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import test.sdo21.tests.TestData.StandardDynamicFactory; -import test.sdo21.tests.TestData.StandardFactory; -import test.sdo21.tests.TestData.StandardXSDFactory; -import test.sdo21.tests.TestData.TestDataFactory; - -import commonj.sdo.Property; -import commonj.sdo.Type; - - -public abstract class TypeTest extends CTSConsistencyBase { - public TypeTest() { - } - - public static class DynamicMetadata extends TypeTest { - public DynamicMetadata() { - - } - public TestDataFactory createTestDataFactory() { - - return new StandardDynamicFactory(); - } - } - - public static class XSDMetadata extends TypeTest { - - public XSDMetadata() { - } - - public TestDataFactory createTestDataFactory() { - - return new StandardXSDFactory(); - } - } - - - @Before - public void setUp () throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - super.tearDown(); - } - - /** - * Verify the value returned by Type.getName() - */ - @Test - public void typeGetName() { - Type type = testDO.getType(); - assertEquals("Type.getName() returned an unexpected value.", StandardFactory.API_TYPE, type.getName()); - } - - /** - * Verify the value returned by Type.getURI() - */ - @Test - public void typeGetURI() { - Type type = testDO.getType(); - assertEquals("Type.getURI() returned an unexpected value.", StandardFactory.TEST_NAMESPACE, type.getURI()); - } - - - /** - * Verify the value returned by Type.isInstance() == true - */ - @Test - public void typeIsInstanceTrue() { - Type type = testDO.getType(); - - assertTrue("Type.getInstance() returned an unexpected value.", type.isInstance(testDO)); - } - - /** - * Verify the value returned by Type.isInstance() == false - */ - @Test - public void typeIsInstanceFalse() { - Type booleanType = testDO.getInstanceProperty("booleanVal").getType(); - Type type = testDO.getType(); - - assertFalse("Type.getInstance() returned an unexpected value.", type.isInstance(booleanType)); - } - - /** - * Verify the value returned by Type.isDataType() == true - */ - @Test - public void typeIsDataTypeTrue() { - Type booleanType = testDO.getInstanceProperty("booleanVal").getType(); - - assertTrue("Type.isDataType() returned an unexpected value.", booleanType.isDataType()); - } - - /** - * Verify the value returned by Type.isDataType() == False - */ - @Test - public void typeIsDataTypeFalse() { - Type type = testDO.getType(); - - assertFalse("Type.isDataType() returned an unexpected value.", type.isDataType()); - } - - /** - * Verify the value returned by Type.isSequenced() == true - */ - @Test - public void typeIsSequencedTrue() { - Type sequencedType = testDO.getInstanceProperty("sequencedElem").getType(); - - assertTrue("Type.isSequenced() returned an unexpected value.", sequencedType.isSequenced()); - } - - /** - * Verify the value returned by Type.isSequenced() == False - */ - @Test - public void typeIsSequencedFalse() { - Type type = testDO.getType(); - - assertFalse("Type.isSequenced() returned an unexpected value.", type.isSequenced()); - } - - /** - * Verify the value returned by Type.isOpen() == true - */ - @Test - public void typeIsOpenTrue() { - Type type = testDO.getInstanceProperty("openElem").getType(); - assertTrue("Type.isOpen() returned an unexpected value.", type.isOpen()); - } - - /** - * Verify the value returned by Type.isOpen() == False - */ - @Test - public void typeIsOpenFalse() { - Type type = testDO.getType(); - - assertFalse("Type.isOpen() returned an unexpected value.", type.isOpen()); - } - - /** - * Verify the value returned by Type.isAbstract() == true - */ - @Test - public void typeIsAbstractTrue() { - Type abstractType = - getScope().getTypeHelper().getType(StandardFactory.TEST_NAMESPACE, StandardFactory.ABSTRACT_TYPE); - - assertTrue("Type.isAbstract() returned an unexpected value.", abstractType.isAbstract()); - } - - /** - * Verify the value returned by Type.isAbstract() == False - */ - @Test - public void typeIsAbstractFalse() { - Type type = testDO.getType(); - - assertFalse("Type.isAbstract() returned an unexpected value.", type.isAbstract()); - } - - /** - * Verify the value returned by Type.getBaseTypes() when there are no base - * types - */ - @Test - public void typeGetBaseTypesNone() { - Type type = testDO.getType(); - - assertEquals("Type.getBaseTypes() returned a List of unexpected size.", 0, type.getBaseTypes().size()); - } - - /** - * Verify the value returned by Type.getBaseTypes() when there are base - * Types to return - */ - @Test - public void typeGetBaseTypes() { - Type extendedType = testDO.getInstanceProperty("extendedElem").getType(); - - assertNotSame("Type.getBaseTypes() did not return the expected base type.", 0, extendedType.getBaseTypes() - .size()); - } - - /** - * Verify the value returned by Type.getAliasNames() when there are no alias - * names - */ - @Test - public void typeGetAliasNamesNone() { - Type type = testDO.getType(); - - assertEquals("Type.getAliasNames() returned a List of unexpected size.", 0, type.getAliasNames().size()); - } - - /** - * Verify the List returned by Type.getProperties() - */ - @Test - public void typeGetProperties() { - Type type = testDO.getType(); - - assertTrue("Type.getProperties() did not return the expected List.", verifyPropertyList(type.getProperties())); - } - - /** - * Verify the List returned by Type.getDeclaredProperties() - */ - @Test - public void typeGetDeclaredProperties() { - Type type = testDO.getType(); - - assertTrue("Type.getProperties() did not return the expected List.", verifyPropertyList(type - .getDeclaredProperties())); - } - - /** - * Verify the value returned by Type.getProperty() - */ - @Test - public void typeGetProperty() { - Type type = testDO.getType(); - - assertEquals("Type.getProperty() returned an unexpected Property.", "booleanVal", type - .getProperty("booleanVal").getName()); - } - - /** - * Verify the handling of an inaccurate name by Type.getProperty() - */ - @Test - public void typeGetPropertyInvalidString() { - Type type = testDO.getType(); - - assertNull("Type.getProperty() returned an unexpected Property.", type.getProperty("madeUpName")); - } - - /** - * verifyPropertyList is a private method used to ensure that all expected - * Properties are contained in the input List - * - * @param properties - * @return - */ - private static boolean verifyPropertyList(List properties) { - boolean stringValFound = false, booleanValFound = false, booleanVal2Found = false, byteValFound = false; - boolean stringVal2Found = false, decimalValFound = false, decimalVal2Found = false, intValFound = false; - boolean floatValFound = false, doubleValFound = false, dateValFound = false, shortValFound = false, longValFound = - false; - boolean containManyFound = false, bytesValFound = false, integerValFound = false, charValFound = false, sequencedElemFound = - false; - - Property currProperty; - for (int i = 0; i < properties.size(); i++) { - currProperty = (Property)properties.get(i); - - if (!stringValFound && currProperty.getName().equals("stringVal")) - stringValFound = true; - else if (!booleanValFound && currProperty.getName().equals("booleanVal")) - booleanValFound = true; - else if (!booleanVal2Found && currProperty.getName().equals("booleanVal2")) - booleanVal2Found = true; - else if (!byteValFound && currProperty.getName().equals("byteVal")) - byteValFound = true; - else if (!stringVal2Found && currProperty.getName().equals("stringVal2")) - stringVal2Found = true; - else if (!decimalValFound && currProperty.getName().equals("decimalVal")) - decimalValFound = true; - else if (!decimalVal2Found && currProperty.getName().equals("decimalVal2")) - decimalVal2Found = true; - else if (!intValFound && currProperty.getName().equals("intVal")) - intValFound = true; - else if (!floatValFound && currProperty.getName().equals("floatVal")) - floatValFound = true; - else if (!doubleValFound && currProperty.getName().equals("doubleVal")) - doubleValFound = true; - else if (!dateValFound && currProperty.getName().equals("dateVal")) - dateValFound = true; - else if (!shortValFound && currProperty.getName().equals("shortVal")) - shortValFound = true; - else if (!longValFound && currProperty.getName().equals("longVal")) - longValFound = true; - else if (!containManyFound && currProperty.getName().equals("containMany")) - containManyFound = true; - else if (!bytesValFound && currProperty.getName().equals("bytesVal")) - bytesValFound = true; - else if (!integerValFound && currProperty.getName().equals("integerVal")) - integerValFound = true; - else if (!charValFound && currProperty.getName().equals("charVal")) - charValFound = true; - else if (!sequencedElemFound && currProperty.getName().equals("sequencedElem")) - sequencedElemFound = true; - } - - if (stringValFound && booleanValFound - && booleanVal2Found - && byteValFound - && stringVal2Found - && decimalValFound - && decimalVal2Found - && intValFound - && floatValFound - && doubleValFound - && dateValFound - && shortValFound - && longValFound - && containManyFound - && bytesValFound - && integerValFound - && charValFound - && sequencedElemFound) - return true; - else - return false; - } -} diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLHelper/QNameTestCase.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLHelper/QNameTestCase.java deleted file mode 100644 index 2071abfa04..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLHelper/QNameTestCase.java +++ /dev/null @@ -1,137 +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.api.XMLHelper; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.io.IOException; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import test.sdo21.framework.CTSTestCase; - -import commonj.sdo.DataObject; -import commonj.sdo.Type; -import commonj.sdo.helper.XMLDocument; - - -public class QNameTestCase extends CTSTestCase { - private final String xsdString = - "<xsd:schema targetNamespace=\"http://www.example.com/simple\" " + - "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " + - "xmlns:simple=\"http://www.example.com/simple\"> " + - "<xsd:element name=\"stockQuote\" type=\"simple:Quote\"/> " + - "<xsd:complexType name=\"Quote\"> " + - "<xsd:sequence> " + - "<xsd:element name=\"symbol\" type=\"xsd:string\"/> " + - "<xsd:element name=\"policy\" type=\"xsd:QName\"/> " + - "</xsd:sequence> " + - "</xsd:complexType> " + - "</xsd:schema>"; - - private final String xmlString = - "<?xml version=\"1.0\" encoding=\"ASCII\"?> " + - "<simple:stockQuote xmlns:simple=\"http://www.example.com/simple\"> " + - "<symbol>fbnt</symbol> " + - "<policy>simple:stockQuote</policy> " + - "</simple:stockQuote>"; - - private final String TEST_NAMESPACE = "http://www.example.com/simple"; - - - /** - * Based on Spec 2.1, section 9.4.1, the return value of DataObject.get() on XSD QName property - * should be http://www.example.com/simple#stockQuote - * - * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=95">2.1 spec section 9.4.1</a> - * @throws IOException - */ - @Test - public void testLoad() throws IOException { - XMLDocument doc = getScope().getXMLHelper().load(xmlString); - DataObject root = doc.getRootObject(); - assertEquals("http://www.example.com/simple#stockQuote", root.get("policy")); - } - - /** - * After serialization, the value of XSD QName property in XML should be <prefix>:stockQuote - */ - @Test - public void testSave() throws IOException { - Type quoteType = getScope().getTypeHelper().getType(TEST_NAMESPACE, "Quote"); - DataObject quote = getScope().getDataFactory().create(quoteType); - - quote.setString("symbol", "fbnt"); - quote.set("policy", "http://www.example.com/simple#stockQuote"); - - String str = getScope().getXMLHelper().save(quote, TEST_NAMESPACE, "stockQuote"); - int start = str.indexOf("<policy>"); - int end = str.indexOf("</policy>"); - assertTrue(start != -1 && end != -1); - - String policyValue = str.substring(start + "<policy>".length(), end); - - Pattern pattern = Pattern.compile(".*:stockQuote"); // prefix can be anything - - Matcher matcher = pattern.matcher(policyValue); - assertTrue(matcher.find()); - } - - /** - * Test the scenario that the xsd:QName property value contains non-existent namespace - */ - @Test - public void testSave2() throws IOException { - Type quoteType = getScope().getTypeHelper().getType(TEST_NAMESPACE, "Quote"); - DataObject quote = getScope().getDataFactory().create(quoteType); - - quote.setString("symbol", "fbnt"); - quote.set("policy", "http://www.example.com/simple2#stockQuote"); - - String str = getScope().getXMLHelper().save(quote, TEST_NAMESPACE, "stockQuote"); - - // Make sure the non-existent namespace was serialized - Pattern pattern = Pattern.compile(".*xmlns:.*=\"http://www.example.com/simple2\""); - Matcher matcher = pattern.matcher(str); - assertTrue(matcher.find()); - } - - @Before - @Override - public void setUp() throws Exception { - super.setUp(); - - - getScope().getXSDHelper().define(xsdString); - } - - @Override - @After - public void tearDown() throws Exception { - super.tearDown(); - } - - -} diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLHelper/XMLHelperConsistencyBase.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLHelper/XMLHelperConsistencyBase.java deleted file mode 100644 index 541b0024c5..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLHelper/XMLHelperConsistencyBase.java +++ /dev/null @@ -1,156 +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.XMLHelper; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import test.sdo21.tests.TestData.StandardFactory; -import test.sdo21.tests.api.CTSConsistencyBase; -import test.sdo21.tests.util.CTSUtil; - -import commonj.sdo.DataObject; -import commonj.sdo.helper.HelperContext; - - -public abstract class XMLHelperConsistencyBase extends CTSConsistencyBase { - private DataObject testDO; - private HelperContext helperContext; - - - - @Before - public void setUp () throws Exception { - super.setUp(); - testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE); - helperContext = getScope(); - } - - - - @After - public void tearDown() throws Exception { - super.tearDown(); - } - - - /** - * Serialize the DataObject then Deserialize the output using Java serialization. Result should be - * equivalent to testDO. - */ - @Test - public void testJavaSerializeDeserialize() { - try { - ((StandardFactory)factory).populateFields(testDO, helperContext); - } catch (Exception e) { - fail("Could not populate DataObject"); - } - DataObject tempDO = null; - ByteArrayOutputStream baos = new ByteArrayOutputStream(); -// FIXME reintroduce -// try { -// ParamatizedTestUtil.serializeDataObjectJava(testDO, baos, helperContext); -// } catch (Exception e) { -// e.printStackTrace(); -// fail("An Exception occurred while serializing the DataObject: " + e.toString()); -// } -// -// try { -// ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); -// tempDO = ParamatizedTestUtil.deserializeDataObjectJava(bais, helperContext); -// } catch (Exception e) { -// e.printStackTrace(); -// fail("An Exception occurred while deserializing the output of the serialization: " + e.toString()); -// } -// -// assertNotNull("Deserialization returned a null value.", tempDO); -// assertTrue("Serialization and deserialization resulted in a nonequivalent DataObject.", -// ParamatizedTestUtil.equalDataObjects(testDO, tempDO)); - } - - /** - * Serialize the DataObject then Deserialize the output using the XMLHelper. Result should be - * equivalent to testDO. - */ - @Test - public void testXMLHelperSerializeDeserialize() { - try { - ((StandardFactory)factory).populateFields(testDO, helperContext); - } catch (Exception e) { - fail("Could not populate DataObject"); - } - DataObject tempDO = null; - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - try { - CTSUtil.serializeDataObjectXML(testDO, baos, helperContext); - } catch (Exception e) { - e.printStackTrace(); - fail("An Exception occurred while serializing the DataObject: " + e.toString()); - } - - try { - ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); - tempDO = CTSUtil.deserializeDataObjectXML(bais, helperContext); - } catch (Exception e) { - e.printStackTrace(); - fail("An Exception occurred while deserializing the output of the serialization: " + e.toString()); - } - - assertNotNull("Deserialization returned a null value.", tempDO); - assertTrue("Serialization and deserialization resulted in a nonequivalent DataObject.", - helperContext.getEqualityHelper().equal(testDO, tempDO)); - } - - /** - * Verifies that appropriate exception is thrown when an - * invalid XML document is specified. - */ - @Test - public void testFaultyXML() { - try { - helperContext.getXMLHelper().load(XMLHelperConsistencyBase.class.getResourceAsStream("/faulty.xml")); - fail("Attempting to load a faulty XML file should result in an Exception."); - } catch (Exception e) { - // success - } - } - - /** - * Tests the condition that an XML document is in itself valid, but does not comply with the XSD. - */ - @Test - public void testXMLWrongXSD() { - try { - helperContext.getXMLHelper().load(XMLHelperConsistencyBase.class.getResourceAsStream("/wrongNamespace.xml")); - fail("Attempting to load an XML specifying the wrong namespace file should result in an Exception."); - } catch (Exception e) { - // success - } - } -} diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLHelper/XMLHelperConsistencyDynamic.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLHelper/XMLHelperConsistencyDynamic.java deleted file mode 100644 index 17a74d60d3..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLHelper/XMLHelperConsistencyDynamic.java +++ /dev/null @@ -1,34 +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.XMLHelper; - -import test.sdo21.tests.TestData.StandardDynamicFactory; -import test.sdo21.tests.TestData.TestDataFactory; - -public class XMLHelperConsistencyDynamic extends XMLHelperConsistencyBase { - - public TestDataFactory createTestDataFactory() { - - return new StandardDynamicFactory(); - } - - -} diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLHelper/XMLHelperConsistencySuite.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLHelper/XMLHelperConsistencySuite.java deleted file mode 100644 index 568e3c8fe8..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLHelper/XMLHelperConsistencySuite.java +++ /dev/null @@ -1,31 +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.XMLHelper; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -@RunWith(Suite.class) -@Suite.SuiteClasses( {XMLHelperConsistencyDynamic.class, - XMLHelperConsistencyXSD.class}) -public class XMLHelperConsistencySuite { - -} diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLHelper/XMLHelperConsistencyXSD.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLHelper/XMLHelperConsistencyXSD.java deleted file mode 100644 index 94ba2f63f9..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLHelper/XMLHelperConsistencyXSD.java +++ /dev/null @@ -1,34 +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.XMLHelper; - -import test.sdo21.tests.TestData.StandardXSDFactory; -import test.sdo21.tests.TestData.TestDataFactory; - -public class XMLHelperConsistencyXSD extends XMLHelperConsistencyBase { - - public TestDataFactory createTestDataFactory() { - - return new StandardXSDFactory(); - } - - -} diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLWithoutSchemaTest.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLWithoutSchemaTest.java deleted file mode 100644 index 851bd5bb06..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLWithoutSchemaTest.java +++ /dev/null @@ -1,151 +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.api; - -import junit.framework.TestCase; -import commonj.sdo.helper.XMLHelper; -import commonj.sdo.helper.XMLDocument; -import commonj.sdo.DataObject; -import commonj.sdo.Property; - -/** - * This tests compliance with section 9.10 of the SDO 2.1 Java specification. - */ -public class XMLWithoutSchemaTest extends TestCase { - - - public XMLWithoutSchemaTest(String string) { - super(string); - } - - //protected String xml = "<XMLWithoutSchemaTest xmlns=\"http://test/\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" + - //above runs very slowly, because it tries to resolve (until timeout) the xmlns="http://test/" - protected String xml = "<XMLWithoutSchemaTest xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" + - "<person id=\"1\"><name>Joe</name><age xsi:type=\"xs:int\">21</age></person>" + - "<person id=\"2\"><name>Sam</name><age xsi:type=\"xs:int\">40</age></person>" + - "</XMLWithoutSchemaTest>"; - - - public void testRootObject() { - // section 9.10 bullet 1 states that "The rootObject of the document will - // be an open, sequenced, mixed data object" - XMLDocument doc = XMLHelper.INSTANCE.load( xml ); - DataObject root = doc.getRootObject(); - assertTrue( root.getType().isOpen() ); - assertTrue( root.getType().isSequenced() ); - } - - public void testAttributeProperties() { - // section 9.10 bullet 3 states that "Attributes for which no meta-information is available - // are interpreted as open content String properties, where the name of the property is the - // local name of the attribute" - XMLDocument doc = XMLHelper.INSTANCE.load( xml ); - DataObject root = doc.getRootObject(); - DataObject person = root.getDataObject( "person.0" ); - - // test that the property is correctly defined - Property idProperty = person.getInstanceProperty( "id" ); - assertTrue( idProperty.isOpenContent() ); - assertTrue( idProperty.getType().isDataType() ); - //FB assertEquals( "String", idProperty.getType().getName() ); - assertEquals( "Object", idProperty.getType().getName() ); //FB Tuscany is doing this. Is this right? - - // test that we can access the instance property - String name = person.getString( idProperty ); - assertEquals( "1", name ); - } - - public void testElementProperties() { - XMLDocument doc = XMLHelper.INSTANCE.load( xml ); - DataObject root = doc.getRootObject(); - - // section 9.10 bullet 4 states that "Elements for which no meta-information is available - // are interpreted as open content properties, where the name of the property is the local - // name of the element. The property will always have containment=true." - Property personProperty = root.getInstanceProperty( "person" ); - assertTrue( personProperty.isContainment() ); - - // section 9.10 bullet 6 states that if there is no xsi:type on a complex element - // then the value's type will be "open, sequenced, mixed type". - assertTrue( personProperty.isOpenContent() ); - //FB assertTrue( personProperty.getType().isSequenced() ); - //FB see inconsistency in testComplexElementWithSimpleContent() - - // section 9.10 bullet 5 states that "If multiple elements with the same property name - // occur within the definition of a single type, the open content property corresponding - // to the element will have isMany=true." - //FB assertTrue( personProperty.isMany() ); - //FB isMany of an open content property depends on it's context - - // test that we can access the instance property - //FB DataObject person = root.getDataObject( personProperty ); - DataObject person = root.getDataObject( "person.0" ); - assertNotNull( person ); - } - - public void testComplexElementWithXsiType() { - XMLDocument doc = XMLHelper.INSTANCE.load( xml ); - DataObject root = doc.getRootObject(); - // section 9.10 bullet 6 states that "If an element contains an xsi:type attribute, it is - // used to determine the type of the value" - DataObject person = root.getDataObject( "person.0" ); - Property ageProperty = person.getInstanceProperty( "age" ); - assertEquals( "commonj.sdo", ageProperty.getType().getURI() ); - //FB assertEquals( "Int", ageProperty.getType().getName() ); - assertEquals( "DataObject", ageProperty.getType().getName() ); //FB Tuscany, is this right? - } - - public void testElementsWithSimpleContent() { - // section 9.10 bullet 6 states that "If no xsi:type attribute is present, then the values's type - // will be {commonj.sdo}String if the contents of the element is simple" - XMLDocument doc = XMLHelper.INSTANCE.load( xml ); - DataObject root = doc.getRootObject(); - DataObject person = root.getDataObject( "person.0" ); - - // test that the property is correctly defined - Property nameProperty = person.getInstanceProperty( "name" ); - assertTrue( nameProperty.isOpenContent() ); - assertTrue( nameProperty.getType().isDataType() ); - assertEquals( "String", nameProperty.getType().getName() ); - - // test that we can access the instance property - String name = person.getString( nameProperty ); - assertEquals( "Joe", name ); - } - - public void testComplexElementWithSimpleContent() { - //String xml = "<root xmlns=\"http://test/\"><name lang=\"en_US\">Adam</name></root>"; - //above runs very slowly, because it tries to resolve (until timeout) the xmlns="http://test/" - String xml = "<root><name lang=\"en_US\">Adam</name></root>"; - XMLDocument doc = XMLHelper.INSTANCE.load( xml ); - DataObject root = doc.getRootObject(); - Property nameProperty = root.getInstanceProperty( "name" ); - - assertEquals( "commonj.sdo", nameProperty.getType().getURI() ); - assertEquals( "DataObject", nameProperty.getType().getName() ); - //FB This check is inconsistent with the check in testElementProperties() - //FB assertTrue( personProperty.getType().isSequenced() ); - //FB because commonj.sdo.DataObject is not a sequenced type.... - - DataObject dobj = root.getDataObject( "name.0" ); - assertEquals( "en_US", dobj.getString( "lang" ) ); - assertEquals( "Adam", dobj.getSequence().getValue(0) ); - } -} diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/package.html b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/package.html deleted file mode 100644 index 2f5eaaf7e5..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/package.html +++ /dev/null @@ -1,25 +0,0 @@ -<html> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - - $Rev$ $Date$ ---> -<body> -Contains test cases for API test. -</body> -</html> |