Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-03-19 02:34:04 -0400
committerEike Stepper2013-03-19 02:34:04 -0400
commit394eeb0f8062e61fcbc56f14d44a72c7d45fce1f (patch)
tree054f67d88c948831a011f1d2699ab780e1c15a55
parent59d9ad9d0b0673e52073bf2303f74659196fa982 (diff)
downloadcdo-394eeb0f8062e61fcbc56f14d44a72c7d45fce1f.tar.gz
cdo-394eeb0f8062e61fcbc56f14d44a72c7d45fce1f.tar.xz
cdo-394eeb0f8062e61fcbc56f14d44a72c7d45fce1f.zip
[402371] CDOCompareUtil.compare fails with models that use Containment
Proxies https://bugs.eclipse.org/bugs/show_bug.cgi?id=402371
-rw-r--r--plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/CDOComparisonScope.java14
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ContainmentTest.java40
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CrossReferenceTest.java3
3 files changed, 34 insertions, 23 deletions
diff --git a/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/CDOComparisonScope.java b/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/CDOComparisonScope.java
index e9b9b5f529..f159a19f3e 100644
--- a/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/CDOComparisonScope.java
+++ b/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/CDOComparisonScope.java
@@ -38,6 +38,7 @@ import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.EcoreUtil.ProperContentIterator;
import org.eclipse.emf.spi.cdo.InternalCDOSession;
import org.eclipse.emf.spi.cdo.InternalCDOSession.MergeData;
+import org.eclipse.emf.spi.cdo.InternalCDOView;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterators;
@@ -237,7 +238,18 @@ public abstract class CDOComparisonScope extends AbstractComparisonScope
}
else
{
- CDOID containerID = (CDOID)revisionData.getContainerID();
+ CDOID containerID;
+
+ Object containerOrID = revisionData.getContainerID();
+ if (containerOrID instanceof EObject)
+ {
+ containerID = (CDOID)((InternalCDOView)object.cdoView()).convertObjectToID(containerOrID);
+ }
+ else
+ {
+ containerID = (CDOID)containerOrID;
+ }
+
collectRequiredParentIDs(view, containerID, requiredParentIDs);
}
}
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 217949104c..47dfa71ee4 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
@@ -24,6 +24,8 @@ import org.eclipse.emf.cdo.tests.model2.TaskContainer;
import org.eclipse.emf.cdo.tests.model2.TransientContainer;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.util.DanglingReferenceException;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
@@ -564,10 +566,6 @@ public class ContainmentTest extends AbstractCDOTest
CDOSession session = openSession();
CDOTransaction transaction = session.openTransaction();
CDOResource resource = transaction.getOrCreateResource(getResourcePath("res1"));
-
- // Model1Package.eINSTANCE.getClass();
- // Resource resource = new XMIResourceImpl();
-
EList<EObject> contents = resource.getContents();
Company company = getModel1Factory().createCompany();
@@ -583,25 +581,27 @@ public class ContainmentTest extends AbstractCDOTest
EList<Supplier> suppliers = company.getSuppliers();
suppliers.add(supplier);
- // // Test succeeds with this intermediary commit:
- // transaction.commit();
+ // "Control" all company contents (supplier + category) to resource contents.
+ // These two objects now have eContainer and eDirectResource set
+ contents.addAll(company.eContents());
- EList<EObject> companyContents = company.eContents();
- contents.addAll(companyContents);
+ // Detach the eContainer of supplier + category
contents.remove(company);
- // FileOutputStream stream = IOUtil.openOutputStream("/develop/test.xml");
- //
- // try
- // {
- // resource.save(stream, null);
- // }
- // finally
- // {
- // IOUtil.close(stream);
- // }
-
- int fails;
+ try
+ {
+ transaction.commit();
+ fail("CommitException expected");
+ }
+ catch (CommitException expected)
+ {
+ assertInstanceOf(DanglingReferenceException.class, expected.getCause());
+ }
+
+ // Unset eContainer of supplier + category
+ company.getSuppliers().remove(supplier);
+ company.getCategories().remove(category);
+
transaction.commit();
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CrossReferenceTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CrossReferenceTest.java
index d163a7561e..66e67c4e3f 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CrossReferenceTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CrossReferenceTest.java
@@ -452,8 +452,7 @@ public class CrossReferenceTest extends AbstractCDOTest
CDORevisionData data = CDOUtil.getCDOObject(salesOrder).cdoRevision().data();
CDOID id = (CDOID)data.get(getModel1Package().getSalesOrder_Customer(), 0);
- int fails;
- assertEquals(false, id.isExternal());
+ assertEquals(true, id.isExternal());
}
@Skips("Hibernate")

Back to the top