From bfe020e9b49da7da397aa9be96d57fd77babe53e Mon Sep 17 00:00:00 2001 From: Eike Stepper Date: Mon, 21 Aug 2006 16:54:22 +0000 Subject: [154522] Copy from CDO resource to XMI resource does not work https://bugs.eclipse.org/bugs/show_bug.cgi?id=154389 --- .../emf/cdo/tests/model1/NotificationTest.java | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) 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 f3785d51fe..593bab886a 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(); + } } -- cgit v1.2.3