Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Fluegge2010-12-31 13:52:55 +0000
committerMartin Fluegge2010-12-31 13:52:55 +0000
commit65d21984b9ea473e5200e10db884eb6bab4aedf2 (patch)
tree1e42d40e77938cf8e0c128486f7f85d6f411a940
parenta0d3c3ff17518f09e299e5432878d328e83c7d3f (diff)
downloadcdo-65d21984b9ea473e5200e10db884eb6bab4aedf2.tar.gz
cdo-65d21984b9ea473e5200e10db884eb6bab4aedf2.tar.xz
cdo-65d21984b9ea473e5200e10db884eb6bab4aedf2.zip
[333299] Legacy fails when EClasses containing references are removed from an EPackage
https://bugs.eclipse.org/bugs/show_bug.cgi?id=333299
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_333299_Test.java66
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyWrapper.java2
3 files changed, 69 insertions, 1 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java
index c2ff5866f3..158042e119 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java
@@ -105,6 +105,7 @@ import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_329869_Test;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_330052_Test;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_331619_Test;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_333157_Test;
+import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_333299_Test;
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite;
@@ -280,6 +281,7 @@ public abstract class AllConfigs extends ConfigTestSuite
testClasses.add(Bugzilla_329869_Test.class);
testClasses.add(Bugzilla_331619_Test.class);
testClasses.add(Bugzilla_333157_Test.class);
+ testClasses.add(Bugzilla_333299_Test.class);
// TODO testClasses.add(NonCDOResourceTest.class);
// TODO testClasses.add(GeneratedEcoreTest.class);
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_333299_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_333299_Test.java
new file mode 100644
index 0000000000..e03a1ce1e2
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_333299_Test.java
@@ -0,0 +1,66 @@
+/**
+ * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EcoreFactory;
+
+/**
+ * @author Martin Fluegge
+ */
+public class Bugzilla_333299_Test extends AbstractCDOTest
+{
+ public void testMoveEcoreElement() throws CommitException
+ {
+ skipUnlessConfig(LEGACY);
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/res1");
+
+ EPackage ePackage = EcoreFactory.eINSTANCE.createEPackage();
+
+ EClass eClass = EcoreFactory.eINSTANCE.createEClass();
+ eClass.setName("clazz1");
+ EReference eReference = EcoreFactory.eINSTANCE.createEReference();
+ eReference.setName("eReference");
+
+ eClass.getEReferences().add(eReference);
+
+ resource.getContents().add(ePackage);
+ ePackage.getEClassifiers().add(eClass);
+
+ transaction.commit();
+ session.close();
+ }
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource("/res1");
+
+ EPackage ePackage = (EPackage)resource.getContents().get(0);
+ ePackage.getEClassifiers().remove(0);
+
+ transaction.commit();
+ session.close();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyWrapper.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyWrapper.java
index 441683e2c2..65e989fdce 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyWrapper.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyWrapper.java
@@ -194,7 +194,7 @@ public abstract class CDOLegacyWrapper extends CDOObjectWrapper
for (EStructuralFeature feature : CDOModelUtil.getAllPersistentFeatures(eClass))
{
EReference oppositeReference = ((EStructuralFeature.Internal)feature).getEOpposite();
- if (oppositeReference != null && !oppositeReference.isContainment())
+ if (oppositeReference != null && !oppositeReference.isContainment() && EMFUtil.isPersistent(oppositeReference))
{
if (feature.isMany())
{

Back to the top