Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2006-09-01 05:01:58 -0400
committerEike Stepper2006-09-01 05:01:58 -0400
commit8332ed884a4cdd292a24fe191f99fcf92c6be8c5 (patch)
treede882c92a9463d2bd9399be452c4f8f71be4e149 /plugins/org.eclipse.emf.cdo.tests/src
parent89b6d77d8645642ff3e0c733b4d56722c3138d62 (diff)
downloadcdo-8332ed884a4cdd292a24fe191f99fcf92c6be8c5.tar.gz
cdo-8332ed884a4cdd292a24fe191f99fcf92c6be8c5.tar.xz
cdo-8332ed884a4cdd292a24fe191f99fcf92c6be8c5.zip
[155899] Bidirectional XRefs are doubled at target side
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.tests/src')
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/Bugzilla155899Test.java173
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/topology/AbstractTopologyTest.java16
2 files changed, 185 insertions, 4 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/Bugzilla155899Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/Bugzilla155899Test.java
new file mode 100644
index 0000000000..81922f210e
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/Bugzilla155899Test.java
@@ -0,0 +1,173 @@
+/***************************************************************************
+ * 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.CDOResource;
+import org.eclipse.emf.cdo.client.ResourceManager;
+
+import org.eclipse.emf.ecore.resource.Resource;
+
+import testmodel1.ExtendedNode;
+import testmodel1.TreeNode;
+
+
+/**
+ * Bidirectional XRefs are doubled at target side
+ *
+ * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=155899
+ */
+public class Bugzilla155899Test extends AbstractModel1Test
+{
+ public void testTwoResourcesUniDi() throws Exception
+ {
+ final String SOURCE_RESOURCE = "/test/source";
+ final String TARGET_RESOURCE = "/test/target";
+ final String SOURCE = "sourceRoot";
+ final String TARGET = "targetRoot";
+
+ { // Execution
+ TreeNode target = createNode(TARGET);
+ CDOResource targetResource = saveRoot(target, TARGET_RESOURCE);
+ ResourceManager resourceManager = targetResource.getResourceManager();
+ Resource sourceResource = createResource(SOURCE_RESOURCE, resourceManager);
+
+ TreeNode source = createNode(SOURCE);
+ source.getReferences().add(target);
+ sourceResource.getContents().add(source);
+ resourceManager.commit();
+ }
+
+ { // Verification
+ TreeNode source = (TreeNode) loadRoot(SOURCE_RESOURCE);
+ assertEquals(1, source.getReferences().size());
+ assertNode(TARGET, (TreeNode) source.getReferences().get(0));
+
+ TreeNode target = (TreeNode) loadRoot(TARGET_RESOURCE);
+ assertEquals(0, target.getReferences().size());
+ }
+ }
+
+ public void testTwoResourcesBiDi() throws Exception
+ {
+ final String SOURCE_RESOURCE = "/test/source";
+ final String TARGET_RESOURCE = "/test/target";
+ final String SOURCE = "sourceRoot";
+ final String TARGET = "targetRoot";
+
+ { // Execution
+ ExtendedNode target = createExtended(TARGET);
+ CDOResource targetResource = saveRoot(target, TARGET_RESOURCE);
+ ResourceManager resourceManager = targetResource.getResourceManager();
+ Resource sourceResource = createResource(SOURCE_RESOURCE, resourceManager);
+
+ ExtendedNode source = createExtended(SOURCE);
+ source.getBidiSource().add(target);
+ sourceResource.getContents().add(source);
+ resourceManager.commit();
+ }
+
+ { // Verification
+ ExtendedNode source = (ExtendedNode) loadRoot(SOURCE_RESOURCE);
+ assertEquals(1, source.getBidiSource().size());
+ assertEquals(0, source.getBidiTarget().size());
+ assertNode(TARGET, (ExtendedNode) source.getBidiSource().get(0));
+
+ ExtendedNode target = (ExtendedNode) loadRoot(TARGET_RESOURCE);
+ assertEquals(0, target.getBidiSource().size());
+ assertEquals(1, target.getBidiTarget().size());
+ assertNode(SOURCE, (ExtendedNode) target.getBidiTarget().get(0));
+ }
+ }
+
+ public void testOneResourceTargetRoot() throws Exception
+ {
+ final String RESOURCE = "/test/res";
+ final String SOURCE = "source";
+ final String TARGET = "target";
+
+ { // Execution
+ ExtendedNode target = createExtended(TARGET);
+ ExtendedNode source = createExtended(SOURCE, target);
+ source.getBidiSource().add(target);
+ saveRoot(target, RESOURCE);
+ }
+
+ { // Verification
+ ExtendedNode target = (ExtendedNode) loadRoot(RESOURCE);
+ assertEquals(0, target.getBidiSource().size());
+ assertEquals(1, target.getBidiTarget().size());
+
+ ExtendedNode source = (ExtendedNode) findChild(SOURCE, target);
+ assertEquals(1, source.getBidiSource().size());
+ assertEquals(0, source.getBidiTarget().size());
+ }
+ }
+
+ public void testOneResourceSourceRoot() throws Exception
+ {
+ final String RESOURCE = "/test/res";
+ final String SOURCE = "source";
+ final String TARGET = "target";
+
+ { // Execution
+ ExtendedNode source = createExtended(SOURCE);
+ ExtendedNode target = createExtended(TARGET, source);
+ source.getBidiSource().add(target);
+ saveRoot(source, RESOURCE);
+ }
+
+ { // Verification
+ ExtendedNode source = (ExtendedNode) loadRoot(RESOURCE);
+ assertEquals(1, source.getBidiSource().size());
+ assertEquals(0, source.getBidiTarget().size());
+
+ ExtendedNode target = (ExtendedNode) findChild(TARGET, source);
+ assertEquals(0, target.getBidiSource().size());
+ assertEquals(1, target.getBidiTarget().size());
+ }
+ }
+
+ public void testTwoResourcesTwoResMans() throws Exception
+ {
+ final String SOURCE_RESOURCE = "/test/source";
+ final String TARGET_RESOURCE = "/test/target";
+ final String SOURCE = "sourceRoot";
+ final String TARGET = "targetRoot";
+
+ { // Execution
+ ExtendedNode target = createExtended(TARGET);
+ saveRoot(target, TARGET_RESOURCE);
+
+ ExtendedNode source = createExtended(SOURCE);
+ CDOResource sourceResource = saveRoot(source, SOURCE_RESOURCE);
+
+ ResourceManager resourceManager = sourceResource.getResourceManager();
+ Resource targetResource = getResource(TARGET_RESOURCE, resourceManager);
+ target = (ExtendedNode) targetResource.getContents().get(0);
+
+ source.getBidiTarget().add(target);
+ resourceManager.commit();
+ }
+
+ { // Verification
+ ExtendedNode source = (ExtendedNode) loadRoot(SOURCE_RESOURCE);
+ assertEquals(0, source.getBidiSource().size());
+ assertEquals(1, source.getBidiTarget().size());
+ assertNode(TARGET, (ExtendedNode) source.getBidiTarget().get(0));
+
+ ExtendedNode target = (ExtendedNode) loadRoot(TARGET_RESOURCE);
+ assertEquals(1, target.getBidiSource().size());
+ assertEquals(0, target.getBidiTarget().size());
+ assertNode(SOURCE, (ExtendedNode) target.getBidiSource().get(0));
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/topology/AbstractTopologyTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/topology/AbstractTopologyTest.java
index ad80e7cee4..ab505cb1f0 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/topology/AbstractTopologyTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/topology/AbstractTopologyTest.java
@@ -129,20 +129,28 @@ public abstract class AbstractTopologyTest extends TestCase implements ITopology
return topology.createResourceManager(resourceSet);
}
- protected CDOResource createResource(String path)
+ protected CDOResource createResource(String path, ResourceManager resourceManager)
{
- ResourceManager resourceManager = createResourceManager();
URI uri = CDOResourceFactoryImpl.formatURI(path);
return (CDOResource) resourceManager.createResource(uri);
}
- protected CDOResource getResource(String path)
+ protected CDOResource createResource(String path)
+ {
+ return createResource(path, createResourceManager());
+ }
+
+ protected CDOResource getResource(String path, ResourceManager resourceManager)
{
- ResourceManager resourceManager = createResourceManager();
URI uri = CDOResourceFactoryImpl.formatURI(path);
return (CDOResource) resourceManager.getResource(uri, true);
}
+ protected CDOResource getResource(String path)
+ {
+ return getResource(path, createResourceManager());
+ }
+
protected EObject loadRoot(String path) throws IOException
{
CDOResource resource = getResource(path);

Back to the top