Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/NotificationTest.java')
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/NotificationTest.java75
1 files changed, 74 insertions, 1 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/NotificationTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/NotificationTest.java
index ff0fcea2e2..f3785d51fe 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/NotificationTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/NotificationTest.java
@@ -19,7 +19,7 @@ import junit.framework.ComparisonFailure;
public class NotificationTest extends AbstractModel1Test
{
- public void testOneConnection() throws Exception
+ public void testRoot() throws Exception
{
final String RESOURCE = "/test/res";
final String ROOT = "root";
@@ -51,4 +51,77 @@ public class NotificationTest extends AbstractModel1Test
Thread.sleep(1);
}
}
+
+ public void testChildNotYetLoaded() throws Exception
+ {
+ final String RESOURCE = "/test/res";
+ final String ROOT = "root";
+ final String CHILD = "a";
+ final String NEW_NAME = "a2";
+ final long TIME_LIMIT = 100;
+
+ // Client1 creates resource
+ TreeNode root = createNode(ROOT);
+ TreeNode a = createNode(CHILD, root);
+ saveRoot(root, RESOURCE);
+
+ // Client2 loads resource
+ TreeNode loaded = (TreeNode) loadRoot(RESOURCE);
+ TreeNode loadedA = (TreeNode) loaded.getChildren().get(0);
+
+ // Client1 modifies and commits resource
+ a.setStringFeature(NEW_NAME);
+ Resource resource = root.eResource();
+ resource.save(null);
+
+ // Give server and client2 enough time to get notified
+ long start = System.currentTimeMillis();
+ try
+ {
+ assertNode(NEW_NAME, loadedA);
+ }
+ catch (ComparisonFailure ex)
+ {
+ long duration = System.currentTimeMillis() - start;
+ if (duration > TIME_LIMIT) throw ex;
+ Thread.sleep(1);
+ }
+ }
+
+ public void testChildAlreadyLoaded() throws Exception
+ {
+ final String RESOURCE = "/test/res";
+ final String ROOT = "root";
+ final String CHILD = "a";
+ final String NEW_NAME = "a2";
+ final long TIME_LIMIT = 100;
+
+ // Client1 creates resource
+ TreeNode root = createNode(ROOT);
+ TreeNode a = createNode(CHILD, root);
+ saveRoot(root, RESOURCE);
+
+ // Client2 loads resource
+ TreeNode loaded = (TreeNode) loadRoot(RESOURCE);
+ TreeNode loadedA = (TreeNode) loaded.getChildren().get(0);
+ assertNode(CHILD, loadedA);
+
+ // Client1 modifies and commits resource
+ a.setStringFeature(NEW_NAME);
+ Resource resource = root.eResource();
+ resource.save(null);
+
+ // Give server and client2 enough time to get notified
+ long start = System.currentTimeMillis();
+ try
+ {
+ assertNode(NEW_NAME, loadedA);
+ }
+ catch (ComparisonFailure ex)
+ {
+ long duration = System.currentTimeMillis() - start;
+ if (duration > TIME_LIMIT) throw ex;
+ Thread.sleep(1);
+ }
+ }
}

Back to the top