diff options
author | Eike Stepper | 2006-08-29 18:14:17 +0000 |
---|---|---|
committer | Eike Stepper | 2006-08-29 18:14:17 +0000 |
commit | cf19140a53ee1f44a44d59091c4332923bd0df8f (patch) | |
tree | e2eecf73487304a15bc187a86c45474e696c6ade /plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo | |
parent | b4d71a13f6c48fae1a249971f2706952e34fa0f8 (diff) | |
download | cdo-cf19140a53ee1f44a44d59091c4332923bd0df8f.tar.gz cdo-cf19140a53ee1f44a44d59091c4332923bd0df8f.tar.xz cdo-cf19140a53ee1f44a44d59091c4332923bd0df8f.zip |
[155508] Do not invalidate changed objects
https://bugs.eclipse.org/bugs/show_bug.cgi?id=155508
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo')
-rw-r--r-- | plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/RollbackTest.java | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/RollbackTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/RollbackTest.java new file mode 100644 index 0000000000..bdbbc5cef9 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/RollbackTest.java @@ -0,0 +1,83 @@ +/*************************************************************************** + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Germany. + * 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: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.tests.model1; + + +import org.eclipse.emf.cdo.client.OptimisticControlException; + +import testmodel1.TreeNode; + + +public class RollbackTest extends AbstractModel1Test +{ + public void testNoNotification() throws Exception + { + final String RESOURCE = "/test/res"; + final String ROOT = "root"; + final String NEW_ROOT1 = "new root 1"; + final String NEW_ROOT2 = "new root 2"; + final long TIME_LIMIT = 1000; + + // Client1 creates resource + TreeNode root = createNode(ROOT); + saveRoot(root, RESOURCE); + + // Client2 loads and modifies resource + TreeNode loaded = (TreeNode) loadRoot(RESOURCE); + loaded.setStringFeature(NEW_ROOT2); + + // Client1 modifies and commits resource + root.setStringFeature(NEW_ROOT1); + root.eResource().save(null); + + // Give server and client2 enough time to get notified + long start = System.currentTimeMillis(); + while (System.currentTimeMillis() - start < TIME_LIMIT) + { + assertNode(NEW_ROOT2, loaded); + Thread.sleep(1); + } + } + + public void testOptimisticControlException() throws Exception + { + final String RESOURCE = "/test/res"; + final String ROOT = "root"; + final String NEW_ROOT1 = "new root 1"; + final String NEW_ROOT2 = "new root 2"; + + // Client1 creates resource + TreeNode root = createNode(ROOT); + saveRoot(root, RESOURCE); + + // Client2 loads and modifies resource + TreeNode loaded = (TreeNode) loadRoot(RESOURCE); + loaded.setStringFeature(NEW_ROOT2); + + // Client1 modifies and commits resource + root.setStringFeature(NEW_ROOT1); + root.eResource().save(null); + + // Client2 commits resource + try + { + loaded.eResource().save(null); + fail("OptimisticControlException did not occur"); + } + catch (OptimisticControlException ex) + { + ; // This is the expected case + } + + // Verify that client2 is properly rolled back + assertNode(NEW_ROOT1, loaded); + } +} |