Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-09-01 08:56:18 +0000
committerEike Stepper2013-09-01 08:57:21 +0000
commit3e803ccb7fe84d07b25b3f3a2c7dbbcb421d14f2 (patch)
treefcd45537c31e27e04f6efd66890aa466df4ab332
parent4665db834f03a248f50427bf2d4f6872f4c8807e (diff)
downloadcdo-3e803ccb7fe84d07b25b3f3a2c7dbbcb421d14f2.tar.gz
cdo-3e803ccb7fe84d07b25b3f3a2c7dbbcb421d14f2.tar.xz
cdo-3e803ccb7fe84d07b25b3f3a2c7dbbcb421d14f2.zip
[396804] CDOMergingConflictResolver tests
https://bugs.eclipse.org/bugs/show_bug.cgi?id=396804
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ConflictResolverExtendedTest.java100
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOMergingConflictResolver.java11
2 files changed, 50 insertions, 61 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ConflictResolverExtendedTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ConflictResolverExtendedTest.java
index 8c42998727..cf1af1b831 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ConflictResolverExtendedTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ConflictResolverExtendedTest.java
@@ -1285,32 +1285,36 @@ public class ConflictResolverExtendedTest extends AbstractCDOTest
Root thisRoot = getTestModelRoot(thisTransaction);
Root thatRoot = thatTransaction.getObject(thisRoot);
+ // Access lists.
+ EList<BaseObject> thisListA = thisRoot.getListA();
+ EList<BaseObject> thatListA = thatRoot.getListA();
+
// Attach adapters.
thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
// Create objects.
BaseObject thisObject = createBaseObject("ThisBaseObject 0");
- thisRoot.getListA().add(0, thisObject);
+ thisListA.add(0, thisObject);
// Clear list.
- thatRoot.getListA().clear();
+ thatListA.clear();
commitAndSync(thisTransaction, thatTransaction);
commitAndSync(thatTransaction, thisTransaction);
// Print contents of lists
- printList("This ", thisRoot.getListA());
- printList("That ", thatRoot.getListA());
+ printList("This ", thisListA);
+ printList("That ", thatListA);
// Check indices.
assertEquals(false, thisTransaction.isDirty());
assertEquals(false, thatTransaction.isDirty());
assertEquals(false, thisTransaction.hasConflict());
assertEquals(false, thatTransaction.hasConflict());
- assertEquals(0, thisRoot.getListA().size());
- assertEquals(0, thatRoot.getListA().size());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisObject).cdoState());
+ assertEquals(1, thisListA.size()); // CLEAR means remove all *originally existing* elements
+ assertEquals(1, thatListA.size()); // CLEAR means remove all *originally existing* elements
+ assertEquals(CDOState.CLEAN, CDOUtil.getCDOObject(thisObject).cdoState());
}
public void testAddTailClearTest() throws Exception
@@ -1326,32 +1330,36 @@ public class ConflictResolverExtendedTest extends AbstractCDOTest
Root thisRoot = getTestModelRoot(thisTransaction);
Root thatRoot = thatTransaction.getObject(thisRoot);
+ // Access lists.
+ EList<BaseObject> thisListA = thisRoot.getListA();
+ EList<BaseObject> thatListA = thatRoot.getListA();
+
// Attach adapters.
thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
// Create objects.
BaseObject thisObject = createBaseObject("ThisBaseObject 0");
- thisRoot.getListA().add(thisObject);
+ thisListA.add(thisObject);
// Clear list.
- thatRoot.getListA().clear();
+ thatListA.clear();
commitAndSync(thisTransaction, thatTransaction);
commitAndSync(thatTransaction, thisTransaction);
// Print contents of lists
- printList("This ", thisRoot.getListA());
- printList("That ", thatRoot.getListA());
+ printList("This ", thisListA);
+ printList("That ", thatListA);
// Check indices.
assertEquals(false, thisTransaction.isDirty());
assertEquals(false, thatTransaction.isDirty());
assertEquals(false, thisTransaction.hasConflict());
assertEquals(false, thatTransaction.hasConflict());
- assertEquals(0, thisRoot.getListA().size());
- assertEquals(0, thatRoot.getListA().size());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisObject).cdoState());
+ assertEquals(1, thisListA.size()); // CLEAR means remove all *originally existing* elements
+ assertEquals(1, thatListA.size()); // CLEAR means remove all *originally existing* elements
+ assertEquals(CDOState.CLEAN, CDOUtil.getCDOObject(thisObject).cdoState());
}
public void testRemoveHeadAddHeadTest() throws Exception
@@ -1958,32 +1966,36 @@ public class ConflictResolverExtendedTest extends AbstractCDOTest
Root thisRoot = getTestModelRoot(thisTransaction);
Root thatRoot = thatTransaction.getObject(thisRoot);
+ // Access lists.
+ EList<BaseObject> thisListA = thisRoot.getListA();
+ EList<BaseObject> thatListA = thatRoot.getListA();
+
// Attach adapters.
thisRoot.eAdapters().add(new ListPrintingAdapter("This root: "));
thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
// Remove object (get it before deletion).
- BaseObject thisRemoveObject = thisRoot.getListA().get(0);
+ BaseObject thisRemoveObject = thisListA.get(0);
BaseObject thatRemoveObject = thatTransaction.getObject(thisRemoveObject);
- thisRoot.getListA().remove(0);
- BaseObject thisAfterRemoveObject = thisRoot.getListA().get(0);
+ thisListA.remove(0);
+ BaseObject thisAfterRemoveObject = thisListA.get(0);
// Clear.
- thatRoot.getListA().clear();
+ thatListA.clear();
commitAndSync(thisTransaction, thatTransaction);
commitAndSync(thatTransaction, thisTransaction);
// Print contents of lists
- printList("This ", thisRoot.getListA());
- printList("That ", thatRoot.getListA());
+ printList("This ", thisListA);
+ printList("That ", thatListA);
// Check indices.
assertEquals(false, thisTransaction.isDirty());
assertEquals(false, thatTransaction.isDirty());
- assertEquals(0, thisRoot.getListA().size());
- assertEquals(0, thatRoot.getListA().size());
+ assertEquals(0, thisListA.size());
+ assertEquals(0, thatListA.size());
assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisRemoveObject).cdoState());
assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatRemoveObject).cdoState());
assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thisAfterRemoveObject).cdoState());
@@ -3241,8 +3253,6 @@ public class ConflictResolverExtendedTest extends AbstractCDOTest
thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
// Remove containment.
- ContainmentObject thisToRemoveContainment = (ContainmentObject)thisRoot.getListB().get(0);
- ContainmentObject thisAfterRemoveContainment = (ContainmentObject)thisRoot.getListB().get(1);
thisRoot.getListB().remove(0);
// Add child to containment.
@@ -3260,22 +3270,10 @@ public class ConflictResolverExtendedTest extends AbstractCDOTest
thatParent.setContainmentOptional(thatAddContainment);
commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // Print contents of lists
- printList("This ", thisRoot.getListB());
- printList("That ", thatRoot.getListB());
-
- // Check indices.
assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisAfterRemoveContainment, thisRoot.getListB().get(0));
- assertEquals(thatTransaction.getObject(thisAfterRemoveContainment), thatRoot.getListB().get(0));
-
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisToRemoveContainment).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatParent).cdoState());
- // AssertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatUnsetContainment).cdoState()); <-- NPE
- assertEquals(CDOState.NEW, CDOUtil.getCDOObject(thatAddContainment).cdoState());
+ assertEquals(true, thatTransaction.isDirty());
+ assertEquals(false, thisTransaction.hasConflict());
+ assertEquals(true, thatTransaction.hasConflict());
}
public void testRemoveHeadRemoveChildHead() throws Exception
@@ -3296,32 +3294,16 @@ public class ConflictResolverExtendedTest extends AbstractCDOTest
thatRoot.eAdapters().add(new ListPrintingAdapter("That root: "));
// Remove containment.
- ContainmentObject thisToRemoveContainment = (ContainmentObject)thisRoot.getListB().get(0);
- ContainmentObject thisAfterRemoveContainment = (ContainmentObject)thisRoot.getListB().get(1);
thisRoot.getListB().remove(0);
- // Get parent object.
- ContainmentObject thatParent = (ContainmentObject)thatRoot.getListB().get(0);
-
// Remove child from containment.
- ContainmentObject thatDetachContainment = (ContainmentObject)thatParent.getContainmentList().remove(0);
+ ((ContainmentObject)thatRoot.getListB().get(0)).getContainmentList().remove(0);
commitAndSync(thisTransaction, thatTransaction);
- commitAndSync(thatTransaction, thisTransaction);
-
- // Print contents of lists
- printList("This ", thisRoot.getListB());
- printList("That ", thatRoot.getListB());
-
- // Check indices.
assertEquals(false, thisTransaction.isDirty());
- assertEquals(false, thatTransaction.isDirty());
- assertEquals(thisAfterRemoveContainment, thisRoot.getListB().get(0));
- assertEquals(thatTransaction.getObject(thisAfterRemoveContainment), thatRoot.getListB().get(0));
-
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thisToRemoveContainment).cdoState());
- assertEquals(CDOState.INVALID, CDOUtil.getCDOObject(thatParent).cdoState());
- assertEquals(CDOState.TRANSIENT, CDOUtil.getCDOObject(thatDetachContainment).cdoState());
+ assertEquals(true, thatTransaction.isDirty());
+ assertEquals(false, thisTransaction.hasConflict());
+ assertEquals(true, thatTransaction.hasConflict());
}
public void testRemoveHeadRemoveChildChildHead() throws Exception
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOMergingConflictResolver.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOMergingConflictResolver.java
index 8f90a76384..66538c598a 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOMergingConflictResolver.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOMergingConflictResolver.java
@@ -17,6 +17,7 @@ import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.model.EMFUtil;
+import org.eclipse.emf.cdo.common.revision.CDOList;
import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
import org.eclipse.emf.cdo.common.revision.CDORevisionValueVisitor;
import org.eclipse.emf.cdo.common.revision.delta.CDOAddFeatureDelta;
@@ -134,7 +135,7 @@ public class CDOMergingConflictResolver extends AbstractChangeSetsConflictResolv
// Compute new clean revision
CDORevisionDelta remoteDelta = remoteDeltas.get(id);
- InternalCDORevision newCleanRevision = cleanRevision.copy();
+ final InternalCDORevision newCleanRevision = cleanRevision.copy();
newCleanRevision.setVersion(newVersion);
remoteDelta.apply(newCleanRevision);
@@ -166,12 +167,18 @@ public class CDOMergingConflictResolver extends AbstractChangeSetsConflictResolv
@Override
public void visit(CDOClearFeatureDelta delta)
{
- // TODO: implement CDOMergingConflictResolver.resolveConflicts(...).new CDOFeatureDeltaVisitorImpl()
+ // TODO Only for reference features?
+ CDOList list = newCleanRevision.getList(delta.getFeature());
+ for (Object id : list)
+ {
+ recurse(detachedObjectsUpdater, (CDOID)id);
+ }
}
@Override
public void visit(CDORemoveFeatureDelta delta)
{
+ // TODO Only for reference features?
recurse(detachedObjectsUpdater, (CDOID)delta.getValue());
}

Back to the top