Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2006-08-22 09:06:09 -0400
committerEike Stepper2006-08-22 09:06:09 -0400
commit1328aece732445c867ee4c444329b7245f8acd7c (patch)
tree77cf7453e49641a74c9fb4db943b44c43b8ce4c7 /plugins/org.eclipse.emf.cdo.tests/src
parent78b35453b7b4b85ac9c7beaae2a4d90f54f28a6a (diff)
downloadcdo-1328aece732445c867ee4c444329b7245f8acd7c.tar.gz
cdo-1328aece732445c867ee4c444329b7245f8acd7c.tar.xz
cdo-1328aece732445c867ee4c444329b7245f8acd7c.zip
[151560] Query Language for CDO
https://bugs.eclipse.org/bugs/show_bug.cgi?id=151560
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/ExtentTest.java100
1 files changed, 100 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/ExtentTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/ExtentTest.java
new file mode 100644
index 0000000000..6e2c5a6928
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/ExtentTest.java
@@ -0,0 +1,100 @@
+/***************************************************************************
+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Fuggerstr. 39, 10777 Berlin, 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.ClassInfo;
+import org.eclipse.emf.cdo.client.PackageManager;
+import org.eclipse.emf.cdo.client.ResourceManager;
+import org.eclipse.emf.cdo.client.protocol.ClientCDOProtocolImpl;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EClass;
+
+import org.eclipse.net4j.core.Channel;
+
+import testmodel1.ExtendedNode;
+import testmodel1.TestModel1Package;
+import testmodel1.TreeNode;
+
+
+public class ExtentTest extends AbstractModel1Test
+{
+ public void testExactGlobal() throws Exception
+ {
+ final String RESOURCE = "/test/res";
+ final String ROOT = "root";
+ final String[] CHILDREN = { "a", "b", "c"};
+ final String OTHER_CHILD = "XYZ";
+
+ TreeNode root = createNode(ROOT);
+ TreeNode[] exactChildren = createChildren(CHILDREN, root);
+ createExtended(OTHER_CHILD, root);
+
+ CDOResource resource = saveRoot(root, RESOURCE);
+ ResourceManager resourceManager = resource.getResourceManager();
+ Channel channel = resourceManager.getChannel();
+
+ PackageManager packageManager = resourceManager.getPackageManager();
+ EClass eClass = TestModel1Package.eINSTANCE.getTreeNode();
+ ClassInfo classInfo = packageManager.getClassInfo(eClass);
+ int cid = classInfo.getCID();
+
+ EList extent = ClientCDOProtocolImpl.requestQueryExtent(channel, cid, true);
+ assertEquals(1 + CHILDREN.length, extent.size());
+
+ assertTrue(extent.contains(root));
+ assertResource(RESOURCE, root);
+
+ for (TreeNode child : exactChildren)
+ {
+ assertTrue(extent.contains(child));
+ assertResource(RESOURCE, child);
+ }
+ }
+
+ public void testDerivedGlobal() throws Exception
+ {
+ final String RESOURCE = "/test/res";
+ final String ROOT = "root";
+ final String[] CHILDREN = { "a", "b", "c"};
+ final String OTHER_CHILD = "XYZ";
+
+ TreeNode root = createNode(ROOT);
+ TreeNode[] exactChildren = createChildren(CHILDREN, root);
+ ExtendedNode otherChild = createExtended(OTHER_CHILD, root);
+
+ CDOResource resource = saveRoot(root, RESOURCE);
+ ResourceManager resourceManager = resource.getResourceManager();
+ Channel channel = resourceManager.getChannel();
+
+ PackageManager packageManager = resourceManager.getPackageManager();
+ EClass eClass = TestModel1Package.eINSTANCE.getTreeNode();
+ ClassInfo classInfo = packageManager.getClassInfo(eClass);
+ int cid = classInfo.getCID();
+
+ EList extent = ClientCDOProtocolImpl.requestQueryExtent(channel, cid, false);
+ assertEquals(2 + CHILDREN.length, extent.size());
+
+ assertTrue(extent.contains(root));
+ assertResource(RESOURCE, root);
+
+ assertTrue(extent.contains(otherChild));
+ assertResource(RESOURCE, otherChild);
+
+ for (TreeNode child : exactChildren)
+ {
+ assertTrue(extent.contains(child));
+ assertResource(RESOURCE, child);
+ }
+ }
+}

Back to the top