You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ke...@apache.org on 2007/05/15 14:21:07 UTC

svn commit: r538150 - in /incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21: paramatizedTests/CTSParamatizedSuite.java paramatizedTests/general/ContainmentTest.java tests/api/DataObject/DataObjectConsistencyBase.java

Author: kelvingoodson
Date: Tue May 15 05:21:06 2007
New Revision: 538150

URL: http://svn.apache.org/viewvc?view=rev&rev=538150
Log:
move contents of containment test into DataObject test

Removed:
    incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/paramatizedTests/general/ContainmentTest.java
Modified:
    incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/paramatizedTests/CTSParamatizedSuite.java
    incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectConsistencyBase.java

Modified: incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/paramatizedTests/CTSParamatizedSuite.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/paramatizedTests/CTSParamatizedSuite.java?view=diff&rev=538150&r1=538149&r2=538150
==============================================================================
--- incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/paramatizedTests/CTSParamatizedSuite.java (original)
+++ incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/paramatizedTests/CTSParamatizedSuite.java Tue May 15 05:21:06 2007
@@ -25,7 +25,6 @@
 
 import test.sdo21.paramatizedTests.conversion.TypeConversionTest;
 import test.sdo21.paramatizedTests.general.ContainmentCycleSerializationTest;
-import test.sdo21.paramatizedTests.general.ContainmentTest;
 import test.sdo21.paramatizedTests.general.DeleteTest;
 import test.sdo21.tests.api.PropertyTest;
 import test.sdo21.tests.api.CopyHelper.CopyEqualityTest;
@@ -45,7 +44,7 @@
  * should be placed in the {@link test.sdo21.UnderReviewSuite} suite.
  */
 @RunWith(Suite.class)
-@Suite.SuiteClasses( {ContainmentTest.class, CopyEqualityTest.class,
+@Suite.SuiteClasses( {CopyEqualityTest.class,
                       DeleteTest.class, PropertyTest.class,
                       TypeConversionTest.class,
                       ContainmentCycleSerializationTest.class})

Modified: incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectConsistencyBase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectConsistencyBase.java?view=diff&rev=538150&r1=538149&r2=538150
==============================================================================
--- incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectConsistencyBase.java (original)
+++ incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectConsistencyBase.java Tue May 15 05:21:06 2007
@@ -21,6 +21,7 @@
 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;
 
@@ -33,7 +34,9 @@
 import test.sdo21.tests.api.CTSConsistencyBase;
 
 import commonj.sdo.DataObject;
+import commonj.sdo.Property;
 import commonj.sdo.Sequence;
+import commonj.sdo.Type;
 
 /**
  * Tests for proper updates to DataObject and their value changes due to the
@@ -289,5 +292,390 @@
 
         // 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());
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org