summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaspar De Groot2011-02-04 05:05:38 (EST)
committerCaspar De Groot2011-02-04 05:05:38 (EST)
commit684b239e6caa4075c27ba6404f4a757037140547 (patch)
treefc905af40efa79ad2b504c5432944209d1b3350d
parentb3e4f5e9265d542b99875639ba5508c9626fa2ad (diff)
downloadcdo-684b239e6caa4075c27ba6404f4a757037140547.zip
cdo-684b239e6caa4075c27ba6404f4a757037140547.tar.gz
cdo-684b239e6caa4075c27ba6404f4a757037140547.tar.bz2
[336314] Partial commits choke on CDOMoveFeatureDeltas
https://bugs.eclipse.org/bugs/show_bug.cgi?id=336314
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_336314_Test.java107
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CommitIntegrityCheck.java8
3 files changed, 115 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 fa52034..9d8590b 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
@@ -196,6 +196,7 @@ public abstract class AllConfigs extends ConfigTestSuite
testClasses.add(Bugzilla_334608_Test.class);
testClasses.add(Bugzilla_335675_Test.class);
testClasses.add(Bugzilla_335004_Test.class);
+ testClasses.add(Bugzilla_336314_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_336314_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_336314_Test.java
new file mode 100644
index 0000000..5747ede
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_336314_Test.java
@@ -0,0 +1,107 @@
+/**
+ * Copyright (c) 2004 - 2011 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:
+ * Caspar De Groot - 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.tests.model1.Model1Factory;
+import org.eclipse.emf.cdo.tests.model1.OrderDetail;
+import org.eclipse.emf.cdo.tests.model1.Product1;
+import org.eclipse.emf.cdo.tests.model1.SalesOrder;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.ecore.EObject;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Bug 336314 - Partial commits choke on CDOMoveFeatureDeltas
+ *
+ * @author Caspar De Groot
+ */
+public class Bugzilla_336314_Test extends AbstractCDOTest
+{
+ public void test1() throws CommitException
+ {
+ test(new MoveIt()
+ {
+ public void move(SalesOrder order, OrderDetail detail)
+ {
+ order.getOrderDetails().remove(detail);
+ order.getOrderDetails().add(detail);
+ }
+ });
+ }
+
+ public void test2() throws CommitException
+ {
+ test(new MoveIt()
+ {
+ public void move(SalesOrder order, OrderDetail detail)
+ {
+ order.getOrderDetails().move(0, 1);
+ }
+ });
+ }
+
+ private static interface MoveIt
+ {
+ void move(SalesOrder order, OrderDetail detail);
+ }
+
+ private void test(MoveIt moveIt) throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+
+ assertEquals(true, getModel1Package().getOrder_OrderDetails().isOrdered());
+
+ Model1Factory mf = getModel1Factory();
+ CDOResource resource = tx.createResource("test");
+
+ OrderDetail detailY = mf.createOrderDetail();
+ detailY.setPrice(1.0f);
+
+ OrderDetail detailZ = mf.createOrderDetail();
+ detailY.setPrice(2.0f);
+
+ SalesOrder orderX = mf.createSalesOrder();
+ orderX.getOrderDetails().add(detailY);
+ orderX.getOrderDetails().add(detailZ);
+
+ resource.getContents().add(orderX);
+
+ // We need another object to make the later commit partial
+ Product1 product = mf.createProduct1();
+ product.setName("abc");
+ resource.getContents().add(product);
+
+ tx.commit();
+
+ // Remove then add back, so as to change ordering
+ moveIt.move(orderX, detailY);
+
+ // Partial commit
+ Set<EObject> committables = new HashSet<EObject>(1);
+ committables.add(orderX);
+ tx.setCommittables(committables);
+
+ // Make other object dirty too, so that commit becomes 'partial'
+ product.setName("def");
+
+ tx.commit();
+
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CommitIntegrityCheck.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CommitIntegrityCheck.java
index d2733c6..7a852e4 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CommitIntegrityCheck.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CommitIntegrityCheck.java
@@ -19,6 +19,7 @@ import org.eclipse.emf.cdo.common.revision.delta.CDOClearFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDOContainerFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOMoveFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDORemoveFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDOSetFeatureDelta;
@@ -249,9 +250,14 @@ public class CommitIntegrityCheck
CDOID id = (CDOID)transaction.convertObjectToID(idOrObject);
checkIncluded(id, "removed child of", dirtyObject);
}
+ else if (featureDelta instanceof CDOMoveFeatureDelta)
+ {
+ // Nothing to do: a move doesn't affect the child being moved
+ // so that child does not need to be included
+ }
else
{
- throw new RuntimeException("Unexpected delta type: " + featureDelta.getClass().getSimpleName());
+ throw new IllegalArgumentException("Unexpected delta type: " + featureDelta.getClass().getSimpleName());
}
}