Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-10-31 07:17:50 -0400
committerEike Stepper2012-10-31 07:17:50 -0400
commite255f970d7de2a032140ff808509899f0cbaaf55 (patch)
treecf70e6f52d03aa75576cab2672fca841587c24b4
parent4037005461a8af61010d6fa024d1816d782e74b7 (diff)
downloadcdo-e255f970d7de2a032140ff808509899f0cbaaf55.tar.gz
cdo-e255f970d7de2a032140ff808509899f0cbaaf55.tar.xz
cdo-e255f970d7de2a032140ff808509899f0cbaaf55.zip
[315026] Local rollback inadvertently brings in updates from other
sessions https://bugs.eclipse.org/bugs/show_bug.cgi?id=315026
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_315026_Test.java82
1 files changed, 82 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_315026_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_315026_Test.java
new file mode 100644
index 0000000000..c283f58c6b
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_315026_Test.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2004 - 2012 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.spi.common.revision.InternalCDORevisionManager;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.Model1Factory;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+/**
+ * Bug 315026: Local rollback inadvertently brings in updates from other sessions
+ *
+ * @author Caspar De Groot
+ */
+public class Bugzilla_315026_Test extends AbstractCDOTest
+{
+ private final static String ORIGINAL_NAME = "AAA";
+
+ private final static String DIRTY_NAME = "BBB";
+
+ private final static String OTHER_NAME = "CCC";
+
+ public void test() throws Exception
+ {
+ CDOSession session = openSession();
+ session.options().setPassiveUpdateEnabled(false);
+ CDOTransaction tx = session.openTransaction();
+ CDOResource r1 = tx.createResource(getResourcePath("/r1")); //$NON-NLS-1$
+
+ // Create clean content
+ Company company = Model1Factory.eINSTANCE.createCompany();
+ company.setName(ORIGINAL_NAME);
+ r1.getContents().add(company);
+ tx.commit();
+
+ // Make it dirty in this session
+ company.setName(DIRTY_NAME);
+
+ // Update and commit in another session
+ doSecondSession();
+
+ // Rollback this session
+ tx.rollback();
+
+ // Clear this session's revision cache
+ ((InternalCDORevisionManager)session.getRevisionManager()).getCache().clear();
+
+ // Verify that value in this session does *not* match value assigned in 2nd session
+ String name = company.getName();
+ assertEquals("Should not have the value committed by the other session", false, OTHER_NAME.equals(name));
+
+ // Verify that value in this session still matches value assigned in this session
+ assertEquals("Should have the value originally loaded in this session", ORIGINAL_NAME, name);
+ }
+
+ private void doSecondSession() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource r1 = tx.getResource(getResourcePath("/r1")); //$NON-NLS-1$
+
+ Company company = (Company)r1.getContents().get(0);
+ company.setName(OTHER_NAME);
+ tx.commit();
+
+ tx.close();
+ session.close();
+ }
+}

Back to the top