summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-04-20 04:32:31 (EDT)
committerEike Stepper2008-04-20 04:32:31 (EDT)
commit865adced265bc84d1f9481185fd34d4e11949a18 (patch)
tree033517082f84688758c24eb14e33a27647e897ef
parentec4089b99e29ea04aa86851bed7249440ab8fd2d (diff)
downloadcdo-865adced265bc84d1f9481185fd34d4e11949a18.zip
cdo-865adced265bc84d1f9481185fd34d4e11949a18.tar.gz
cdo-865adced265bc84d1f9481185fd34d4e11949a18.tar.bz2
[226710] Containment problem when we set to NULL
https://bugs.eclipse.org/bugs/show_bug.cgi?id=226710
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ContainmentTest.java54
2 files changed, 62 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java
index 15d8e21..4e6785d 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java
@@ -19,6 +19,7 @@ import org.eclipse.emf.cdo.server.CDOServerUtil;
import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.server.IStore;
import org.eclipse.emf.cdo.tests.model1.Model1Package;
+import org.eclipse.emf.cdo.tests.model2.Model2Package;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.internal.cdo.util.FSMUtil;
@@ -84,6 +85,13 @@ public abstract class AbstractCDOTest extends AbstractTransportTest
return session;
}
+ protected CDOSession openModel2Session()
+ {
+ CDOSession session = openModel1Session();
+ session.getPackageRegistry().putEPackage(Model2Package.eINSTANCE);
+ return session;
+ }
+
protected static void assertTransient(CDOObject object)
{
assertTrue(FSMUtil.isTransient(object));
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ContainmentTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ContainmentTest.java
index 35b72f8..ec7e2f9 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ContainmentTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ContainmentTest.java
@@ -13,10 +13,13 @@ package org.eclipse.emf.cdo.tests;
import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.CDOTransaction;
import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.tests.model1.Address;
import org.eclipse.emf.cdo.tests.model1.Category;
import org.eclipse.emf.cdo.tests.model1.Company;
import org.eclipse.emf.cdo.tests.model1.Model1Factory;
import org.eclipse.emf.cdo.tests.model1.Supplier;
+import org.eclipse.emf.cdo.tests.model2.Model2Factory;
+import org.eclipse.emf.cdo.tests.model2.SpecialPurchaseOrder;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
@@ -269,4 +272,55 @@ public class ContainmentTest extends AbstractCDOTest
assertContent(category2, category3);
assertClean(category3, transaction);
}
+
+ public void testSetSingleContainment() throws Exception
+ {
+ Address address = Model1Factory.eINSTANCE.createAddress();
+ address.setName("Stepper");
+ address.setStreet("Home Ave. 007");
+ address.setCity("Berlin");
+
+ SpecialPurchaseOrder order = Model2Factory.eINSTANCE.createSpecialPurchaseOrder();
+ order.setShippingAddress(address);
+
+ CDOSession session = openModel2Session();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/test1");
+
+ resource.getContents().add(order);
+ transaction.commit();
+
+ assertClean(resource, transaction);
+ assertClean(order, transaction);
+ assertClean(address, transaction);
+ assertContent(resource, order);
+ assertContent(order, address);
+ }
+
+ public void testUnsetSingleContainment() throws Exception
+ {
+ Address address = Model1Factory.eINSTANCE.createAddress();
+ address.setName("Stepper");
+ address.setStreet("Home Ave. 007");
+ address.setCity("Berlin");
+
+ SpecialPurchaseOrder order = Model2Factory.eINSTANCE.createSpecialPurchaseOrder();
+ order.setShippingAddress(address);
+
+ CDOSession session = openModel2Session();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/test1");
+
+ resource.getContents().add(order);
+ transaction.commit();
+
+ order.setShippingAddress(null);
+ transaction.commit();
+
+ assertClean(resource, transaction);
+ assertClean(order, transaction);
+ assertTransient(address);
+ assertContent(resource, order);
+ assertNull(order.getShippingAddress());
+ }
}