summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2006-08-14 02:36:50 (EDT)
committerEike Stepper2006-08-14 02:36:50 (EDT)
commit569cb286f59f30cce08f07cab3631049c8120375 (patch)
tree3811bdea33c17275ca51b578efe06dd93fa11739
parent33e1b9b9a5911b941b2744073ea7ae0d04eb54aa (diff)
downloadcdo-569cb286f59f30cce08f07cab3631049c8120375.zip
cdo-569cb286f59f30cce08f07cab3631049c8120375.tar.gz
cdo-569cb286f59f30cce08f07cab3631049c8120375.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/AbstractModel1Test.java11
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/BasicTest.java147
2 files changed, 152 insertions, 6 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/AbstractModel1Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/AbstractModel1Test.java
index cb6f0e6..dba7114 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/AbstractModel1Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/AbstractModel1Test.java
@@ -11,9 +11,11 @@
package org.eclipse.emf.cdo.tests.model1;
+import org.eclipse.emf.cdo.client.CDOResource;
import org.eclipse.emf.cdo.tests.topology.AbstractTopologyTest;
import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.resource.Resource;
import org.springframework.jdbc.core.JdbcTemplate;
@@ -60,6 +62,15 @@ public abstract class AbstractModel1Test extends AbstractTopologyTest
assertNotNull(result);
}
+ protected void assertResource(String path, TreeNode node)
+ {
+ Resource resource = node.eResource();
+ assertTrue(resource instanceof CDOResource);
+
+ CDOResource cdoResource = (CDOResource) resource;
+ assertEquals(path, cdoResource.getPath());
+ }
+
protected TreeNode[] createChildren(String[] names, TreeNode parent)
{
List<TreeNode> result = new ArrayList<TreeNode>();
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/BasicTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/BasicTest.java
index c87bd9f..ba1e231 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/BasicTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/BasicTest.java
@@ -20,7 +20,6 @@ import org.eclipse.emf.ecore.resource.Resource;
import testmodel1.TreeNode;
-@SuppressWarnings("unused")
public class BasicTest extends AbstractModel1Test
{
public void testSimple() throws Exception
@@ -86,7 +85,7 @@ public class BasicTest extends AbstractModel1Test
assertNode(ROOT, root);
TreeNode a = findPath(PATH_A, root);
- TreeNode b = findPath(PATH_B, root);
+ findPath(PATH_B, root);
assertNode(PATH_B[3], (TreeNode) a.getReferences().get(0));
}
}
@@ -165,12 +164,148 @@ public class BasicTest extends AbstractModel1Test
{ // Verification
TreeNode root = (TreeNode) loadRoot(RESOURCE);
- CDOResource cdoResource = ((CDOPersistentImpl) root).cdoGetResource();
-
TreeNode a = findPath(PATH_A, root);
TreeNode b = (TreeNode) a.getReferences().get(0);
- Resource resource = b.eResource();
- assertEquals(cdoResource, resource);
+ assertResource(RESOURCE, b);
+ }
+ }
+
+ public void testInterResourceXRef1() throws Exception
+ {
+ final String RESOURCE1 = "/test/res1";
+ final String RESOURCE2 = "/test/res2";
+ final String ROOT1 = "root1";
+ final String ROOT2 = "root2";
+
+ { // Execution
+ TreeNode root1 = createNode(ROOT1);
+ saveRoot(root1, RESOURCE1);
+
+ TreeNode root2 = createNode(ROOT2);
+ root2.getReferences().add(root1);
+ saveRoot(root2, RESOURCE2);
+ }
+
+ { // Verification
+ TreeNode root2 = (TreeNode) loadRoot(RESOURCE2);
+ assertNode(ROOT2, root2);
+ assertResource(RESOURCE2, root2);
+
+ TreeNode root1 = (TreeNode) root2.getReferences().get(0);
+ assertNode(ROOT1, root1);
+ assertResource(RESOURCE1, root1);
+ }
+ }
+
+ public void testInterResourceXRef2() throws Exception
+ {
+ final String RESOURCE1 = "/test/res1";
+ final String RESOURCE2 = "/test/res2";
+ final String ROOT1 = "root1";
+ final String ROOT2 = "root2";
+ final String CHILD1 = "child1";
+
+ { // Execution
+ TreeNode root1 = createNode(ROOT1);
+ TreeNode child1 = createNode(CHILD1, root1);
+ saveRoot(root1, RESOURCE1);
+
+ TreeNode root2 = createNode(ROOT2);
+ root2.getReferences().add(child1);
+ saveRoot(root2, RESOURCE2);
+ }
+
+ { // Verification
+ TreeNode root2 = (TreeNode) loadRoot(RESOURCE2);
+ assertNode(ROOT2, root2);
+ assertResource(RESOURCE2, root2);
+
+ TreeNode child1 = (TreeNode) root2.getReferences().get(0);
+ assertNode(CHILD1, child1);
+ assertResource(RESOURCE1, child1);
+ }
+ }
+
+ public void testGetContainer() throws Exception
+ {
+ final String RESOURCE = "/test/res";
+ final String ROOT = "root";
+ final String[] PATH = { "a1", "a2", "a3", "a4"};
+
+ { // Execution
+ TreeNode root = createNode(ROOT);
+ createPath(PATH, root, false);
+ saveRoot(root, RESOURCE);
+ }
+
+ { // Verification
+ TreeNode root = (TreeNode) loadRoot(RESOURCE);
+ TreeNode a4 = findPath(PATH, root);
+
+ TreeNode a3 = a4.getParent();
+ assertNode(PATH[2], a3);
+ assertEquals(a3, a4.eContainer());
+
+ TreeNode a2 = a3.getParent();
+ assertNode(PATH[1], a2);
+ assertEquals(a2, a3.eContainer());
+
+ TreeNode a1 = a2.getParent();
+ assertNode(PATH[0], a1);
+ assertEquals(a1, a2.eContainer());
+
+ TreeNode a0 = a1.getParent();
+ assertNode(ROOT, a0);
+ assertEquals(a0, a1.eContainer());
+ assertEquals(a0, root);
+
+ assertResource(RESOURCE, a0);
+ assertResource(RESOURCE, a1);
+ assertResource(RESOURCE, a2);
+ assertResource(RESOURCE, a3);
+ assertResource(RESOURCE, a4);
+ }
+ }
+
+ public void testGetContainerWithXRef() throws Exception
+ {
+ final String RESOURCE = "/test/res";
+ final String ROOT = "root";
+ final String[] PATH = { "a1", "a2", "a3", "a4"};
+
+ { // Execution
+ TreeNode root = createNode(ROOT);
+ TreeNode a4 = createPath(PATH, root, false);
+ root.getReferences().add(a4);
+ saveRoot(root, RESOURCE);
+ }
+
+ { // Verification
+ TreeNode root = (TreeNode) loadRoot(RESOURCE);
+ TreeNode a4 = (TreeNode) root.getReferences().get(0);
+
+ TreeNode a3 = a4.getParent();
+ assertNode(PATH[2], a3);
+ assertEquals(a3, a4.eContainer());
+
+ TreeNode a2 = a3.getParent();
+ assertNode(PATH[1], a2);
+ assertEquals(a2, a3.eContainer());
+
+ TreeNode a1 = a2.getParent();
+ assertNode(PATH[0], a1);
+ assertEquals(a1, a2.eContainer());
+
+ TreeNode a0 = a1.getParent();
+ assertNode(ROOT, a0);
+ assertEquals(a0, a1.eContainer());
+ assertEquals(a0, root);
+
+ assertResource(RESOURCE, a0);
+ assertResource(RESOURCE, a1);
+ assertResource(RESOURCE, a2);
+ assertResource(RESOURCE, a3);
+ assertResource(RESOURCE, a4);
}
}
}