Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2006-08-23 16:48:02 -0400
committerEike Stepper2006-08-23 16:48:02 -0400
commitdd75668a423b99f76b2185d18b94a68ed4f3146d (patch)
tree4855ccda75dbaf7dce3fddbc330dc74895dfb3a9 /plugins/org.eclipse.emf.cdo.tests/src
parent5f7a63f633da56a443a523d05a3e21f9f3336ec3 (diff)
downloadcdo-dd75668a423b99f76b2185d18b94a68ed4f3146d.tar.gz
cdo-dd75668a423b99f76b2185d18b94a68ed4f3146d.tar.xz
cdo-dd75668a423b99f76b2185d18b94a68ed4f3146d.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/AdapterTest.java94
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/AllModel1Tests.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/OCLTest.java4
3 files changed, 100 insertions, 5 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/AdapterTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/AdapterTest.java
new file mode 100644
index 0000000000..249375d68e
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/AdapterTest.java
@@ -0,0 +1,94 @@
+/***************************************************************************
+ * 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.PausableChangeRecorder;
+import org.eclipse.emf.cdo.client.ResourceManager;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+import testmodel1.TreeNode;
+
+import java.util.Iterator;
+
+
+public class AdapterTest extends AbstractModel1Test
+{
+ public void testFiveLevels() throws Exception
+ {
+ final String RESOURCE = "/test/res";
+ final String ROOT = "root";
+ final String[] CHILDREN = { "a", "b", "c"};
+
+ TreeNode root = createNode(ROOT);
+ TreeNode[] children = createChildren(CHILDREN, root);
+ for (int i = 0; i < children.length; i++)
+ createChildren(new String[] { "a" + i, "b" + i, "c" + i}, children[i]);
+ CDOResource resource = saveRoot(root, RESOURCE);
+
+ ResourceManager resourceManager = resource.getResourceManager();
+ ResourceSet resourceSet = resourceManager.getResourceSet();
+ PausableChangeRecorder transaction = resourceManager.getTransaction();
+ assertAdapter(resourceSet, transaction);
+ }
+
+ protected void assertAdapter(Notifier notifier, Adapter adapter)
+ {
+ EList adapters = notifier.eAdapters();
+ assertNotNull(notifier.toString(), adapters);
+
+ int count = 0;
+ for (Iterator it = adapters.iterator(); it.hasNext();)
+ {
+ Adapter element = (Adapter) it.next();
+ count += element == adapter ? 1 : 0;
+ }
+ assertEquals(notifier.toString(), 1, count);
+
+ if (notifier instanceof ResourceSet)
+ {
+ ResourceSet resourceSet = (ResourceSet) notifier;
+ EList resources = resourceSet.getResources();
+ for (Iterator it = resources.iterator(); it.hasNext();)
+ {
+ Resource resource = (Resource) it.next();
+ assertAdapter(resource, adapter);
+ }
+ }
+ else if (notifier instanceof Resource)
+ {
+ Resource resource = (Resource) notifier;
+ EList contents = resource.getContents();
+ for (Iterator it = contents.iterator(); it.hasNext();)
+ {
+ EObject object = (EObject) it.next();
+ assertAdapter(object, adapter);
+ }
+ }
+ else if (notifier instanceof EObject)
+ {
+ EObject object = (EObject) notifier;
+ EList contents = object.eContents();
+ for (Iterator it = contents.iterator(); it.hasNext();)
+ {
+ EObject child = (EObject) it.next();
+ assertAdapter(child, adapter);
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/AllModel1Tests.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/AllModel1Tests.java
index a4a355e026..ce132bf2d2 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/AllModel1Tests.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/AllModel1Tests.java
@@ -21,11 +21,12 @@ public class AllModel1Tests
{
TestSuite suite = new TestSuite("Test for org.eclipse.emf.cdo.tests.model1");
suite.addTestSuite(BasicTest.class);
- suite.addTestSuite(Bugzilla154389Test.class);
- suite.addTestSuite(ExtentTest.class);
+ suite.addTestSuite(AdapterTest.class);
+ suite.addTestSuite(SerializationTest.class);
suite.addTestSuite(NotificationTest.class);
+ suite.addTestSuite(ExtentTest.class);
suite.addTestSuite(OCLTest.class);
- suite.addTestSuite(SerializationTest.class);
+ suite.addTestSuite(Bugzilla154389Test.class);
return suite;
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/OCLTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/OCLTest.java
index d37c23757b..6ecb807e33 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/OCLTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/OCLTest.java
@@ -38,7 +38,7 @@ public class OCLTest extends AbstractModel1Test
}
TreeNode root = (TreeNode) loadRoot(RESOURCE);
- IOCLHelper helper = HelperUtil.createOCLHelper();
+ IOCLHelper helper = CDOHelperUtil.createOCLHelper();
helper.setContext(root);
try
@@ -65,7 +65,7 @@ public class OCLTest extends AbstractModel1Test
}
TreeNode root = (TreeNode) loadRoot(RESOURCE);
- IOCLHelper helper = HelperUtil.createOCLHelper();
+ IOCLHelper helper = CDOHelperUtil.createOCLHelper();
helper.setContext(root);
try

Back to the top