summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2006-08-21 12:54:22 (EDT)
committerEike Stepper2006-08-21 12:54:22 (EDT)
commitbfe020e9b49da7da397aa9be96d57fd77babe53e (patch)
treeb2f23a7ac075f810427084061bbf3ee88fdfeda9
parent4d88630d481cd3ceee238bdd62148e43e7679bf0 (diff)
downloadcdo-bfe020e9b49da7da397aa9be96d57fd77babe53e.zip
cdo-bfe020e9b49da7da397aa9be96d57fd77babe53e.tar.gz
cdo-bfe020e9b49da7da397aa9be96d57fd77babe53e.tar.bz2
[154522] Copy from CDO resource to XMI resource does not work
https://bugs.eclipse.org/bugs/show_bug.cgi?id=154389
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/NotificationTest.java47
1 files changed, 47 insertions, 0 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 f3785d5..593bab8 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
@@ -11,6 +11,8 @@
package org.eclipse.emf.cdo.tests.model1;
+import org.eclipse.emf.cdo.client.ResourceManager;
+
import org.eclipse.emf.ecore.resource.Resource;
import testmodel1.TreeNode;
@@ -124,4 +126,49 @@ public class NotificationTest extends AbstractModel1Test
Thread.sleep(1);
}
}
+
+ public void testListener() 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;
+ final boolean[] notificationReceived = { false};
+
+ // 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);
+
+ // Client2 remembers notifications
+ ResourceManager client2 = loaded.cdoGetResource().getResourceManager();
+ client2.addInvalidationListener(new ResourceManager.InvalidationListener()
+ {
+ public void notifyInvalidation(ResourceManager resourceManager, long[] oids)
+ {
+ notificationReceived[0] = true;
+ }
+ });
+
+ // 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();
+ while (System.currentTimeMillis() - start < TIME_LIMIT)
+ {
+ if (notificationReceived[0]) break;
+ Thread.sleep(1);
+ }
+
+ if (!notificationReceived[0]) fail();
+ }
}