summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2006-08-23 16:34:35 (EDT)
committerEike Stepper2006-08-23 16:34:35 (EDT)
commitc14ba23d13454e7f765199f58993b550c46bf0ce (patch)
treeb6104bc585d0a84b5e14099d31cb52a078f81275
parent6c7f744d1e78c56e9a623394d90bdea12c1415c6 (diff)
downloadcdo-c14ba23d13454e7f765199f58993b550c46bf0ce.zip
cdo-c14ba23d13454e7f765199f58993b550c46bf0ce.tar.gz
cdo-c14ba23d13454e7f765199f58993b550c46bf0ce.tar.bz2
https://bugs.eclipse.org/bugs/show_bug.cgi?id=151560
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/META-INF/net4j/embedded/net4j-embedded.properties2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/META-INF/net4j/net4j.properties2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/launches/CDO Adapter Test.launch38
-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.java354
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/SerializationTest.java65
7 files changed, 378 insertions, 184 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/META-INF/net4j/embedded/net4j-embedded.properties b/plugins/org.eclipse.emf.cdo.tests/META-INF/net4j/embedded/net4j-embedded.properties
index c5cac7c..d527a24 100644
--- a/plugins/org.eclipse.emf.cdo.tests/META-INF/net4j/embedded/net4j-embedded.properties
+++ b/plugins/org.eclipse.emf.cdo.tests/META-INF/net4j/embedded/net4j-embedded.properties
@@ -10,5 +10,5 @@ auth.users.file=plugin:/META-INF/auth.users
# Internal
randomizer.algorithm=SHA1PRNG
bufferPool.bufferSize=4096
-channel.responseTimeoutMillis=250000
+channel.responseTimeoutMillis=2000
connectionManager.maxConnections=50
diff --git a/plugins/org.eclipse.emf.cdo.tests/META-INF/net4j/net4j.properties b/plugins/org.eclipse.emf.cdo.tests/META-INF/net4j/net4j.properties
index 3d2f81b..451c043 100644
--- a/plugins/org.eclipse.emf.cdo.tests/META-INF/net4j/net4j.properties
+++ b/plugins/org.eclipse.emf.cdo.tests/META-INF/net4j/net4j.properties
@@ -1,4 +1,4 @@
# Internal
randomizer.algorithm=SHA1PRNG
bufferPool.bufferSize=4096
-channel.responseTimeoutMillis=250000
+channel.responseTimeoutMillis=2000
diff --git a/plugins/org.eclipse.emf.cdo.tests/launches/CDO Adapter Test.launch b/plugins/org.eclipse.emf.cdo.tests/launches/CDO Adapter Test.launch
new file mode 100644
index 0000000..7265c12
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/launches/CDO Adapter Test.launch
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig">
+<stringAttribute key="product" value="org.eclipse.platform.ide"/>
+<stringAttribute key="bootstrap" value=""/>
+<booleanAttribute key="useProduct" value="false"/>
+<stringAttribute key="deselected_workspace_plugins" value="org.eclipse.net4j.examples.mvc.swt,org.eclipse.net4j.examples.prov.client.ui,org.eclipse.net4j.examples.mvc,org.eclipse.net4j.examples.prov.server,org.eclipse.emf.cdo.dbgen.edit,org.eclipse.emf.cdo.examples.library,org.eclipse.emf.cdo.examples.library.ui,org.eclipse.emf.cdo.analysis.gmf,org.eclipse.emf.cdo.mapping.editor,org.eclipse.net4j.examples.server,org.eclipse.net4j.tests,org.eclipse.emf.cdo.doc,org.eclipse.datatools.enablement.mysql,org.eclipse.net4j.spring.tests,org.eclipse.emf.cdo,org.eclipse.emf.cdo.dbgen.editor,org.eclipse.net4j.examples.prov.edit,org.eclipse.emf.cdo.utilities.migrator,org.eclipse.emf.cdo.analysis,org.eclipse.emf.cdo.examples.server,org.eclipse.datatools.enablement.mysql.dbdefinition,org.eclipse.net4j.examples.prov,org.eclipse.emf.cdo.examples.client,org.eclipse.emf.cdo.examples.ui,org.eclipse.net4j.examples.client.ui,org.eclipse.net4j.examples.client,org.eclipse.net4j.doc,org.eclipse.net4j.examples.prov.client,org.eclipse.net4j.examples.prov.editor,org.eclipse.net4j"/>
+<booleanAttribute key="tracing" value="false"/>
+<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
+<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
+<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
+</listAttribute>
+<stringAttribute key="selected_target_plugins" value="com.ibm.icu,org.apache.ant,org.eclipse.ant.core,org.eclipse.core.contenttype,org.eclipse.core.expressions,org.eclipse.core.filesystem,org.eclipse.core.filesystem.win32.x86,org.eclipse.core.jobs,org.eclipse.core.resources,org.eclipse.core.resources.compatibility,org.eclipse.core.resources.win32,org.eclipse.core.runtime,org.eclipse.core.runtime.compatibility,org.eclipse.core.runtime.compatibility.auth,org.eclipse.core.runtime.compatibility.registry,org.eclipse.core.variables,org.eclipse.emf.common,org.eclipse.emf.ecore,org.eclipse.emf.ecore.change,org.eclipse.emf.ecore.edit,org.eclipse.emf.ecore.xmi,org.eclipse.emf.edit,org.eclipse.equinox.common,org.eclipse.equinox.preferences,org.eclipse.equinox.registry,org.eclipse.osgi,org.eclipse.update.configurator,org.junit"/>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="automaticValidate" value="true"/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<booleanAttribute key="automaticAdd" value="false"/>
+<stringAttribute key="checked" value="[NONE]"/>
+<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
+<stringAttribute key="selected_workspace_plugins" value="org.eclipse.emf.cdo.jdbc,org.eclipse.net4j.spring,org.eclipse.net4j.socket,org.eclipse.net4j.core,org.eclipse.net4j.spring.db,org.eclipse.emf.cdo.dbgen,org.eclipse.emf.ocl,org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.core,org.eclipse.emf.cdo.mapping,org.eclipse.emf.cdo.client,org.eclipse.net4j.util,org.eclipse.emf.cdo.client.ocl,org.eclipse.emf.cdo.server,org.eclipse.net4j.embedded,org.eclipse.emf.cdo.jdbc.derby,org.eclipse.emf.cdo.dbgen.derby,org.eclipse.emf.cdo.dbgen.oracle,org.eclipse.emf.cdo.jdbc.hsqldb,org.eclipse.emf.cdo.jdbc.mysql,org.eclipse.emf.cdo.dbgen.ansi92,org.eclipse.emf.cdo.dbgen.mysql,org.eclipse.emf.cdo.dbgen.hsqldb"/>
+<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
+<stringAttribute key="application" value="org.eclipse.pde.junit.runtime.coretestapplication"/>
+<booleanAttribute key="clearws" value="true"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.model1.AdapterTest"/>
+<stringAttribute key="pde.version" value="3.2a"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dcdo.test.mode=client-separated-server"/>
+<stringAttribute key="templateConfig" value="${target_home}\configuration\config.ini"/>
+<booleanAttribute key="default" value="false"/>
+<booleanAttribute key="clearConfig" value="true"/>
+<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
+<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
+<booleanAttribute key="useDefaultConfigArea" value="false"/>
+<booleanAttribute key="useDefaultConfig" value="true"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.emf.cdo.tests"/>
+<booleanAttribute key="askclear" value="false"/>
+<booleanAttribute key="includeOptional" value="true"/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
+</launchConfiguration>
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 0000000..249375d
--- /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 a4a355e..ce132bf 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 981c631..d37c237 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
@@ -13,7 +13,9 @@ package org.eclipse.emf.cdo.tests.model1;
import org.eclipse.emf.cdo.client.ocl.CDOHelperUtil;
+import org.eclipse.emf.ocl.helper.HelperUtil;
import org.eclipse.emf.ocl.helper.IOCLHelper;
+import org.eclipse.emf.ocl.helper.OCLParsingException;
import testmodel1.TreeNode;
@@ -22,181 +24,181 @@ import java.util.Set;
public class OCLTest extends AbstractModel1Test
{
- // public void testNotEmpty() throws Exception
- // {
- // final String RESOURCE = "/test/res";
- // final String ROOT = "root";
- // final String[] CHILDREN = { "a", "b", "c"};
- // final String EXPR = "self.children->isEmpty()";
- //
- // { // Create CDO resource
- // TreeNode root = createNode(ROOT);
- // createChildren(CHILDREN, root);
- // saveRoot(root, RESOURCE);
- // }
- //
- // TreeNode root = (TreeNode) loadRoot(RESOURCE);
- // IOCLHelper helper = HelperUtil.createOCLHelper();
- // helper.setContext(root);
- //
- // try
- // {
- // Object result = helper.evaluate(root, EXPR);
- // assertFalse(result);
- // }
- // catch (Exception ex)
- // {
- // ex.printStackTrace();
- // fail("Parse failed: " + ex.getLocalizedMessage());
- // }
- // }
- //
- // public void testEmpty() throws Exception
- // {
- // final String RESOURCE = "/test/res";
- // final String ROOT = "root";
- // final String EXPR = "self.children->isEmpty()";
- //
- // { // Create CDO resource
- // TreeNode root = createNode(ROOT);
- // saveRoot(root, RESOURCE);
- // }
- //
- // TreeNode root = (TreeNode) loadRoot(RESOURCE);
- // IOCLHelper helper = HelperUtil.createOCLHelper();
- // helper.setContext(root);
- //
- // try
- // {
- // Object result = helper.evaluate(root, EXPR);
- // assertTrue(result);
- // }
- // catch (Exception ex)
- // {
- // ex.printStackTrace();
- // fail("Parse failed: " + ex.getLocalizedMessage());
- // }
- // }
- //
- // public void testExtendedNodeExtent() throws Exception
- // {
- // final String RESOURCE = "/test/res";
- //
- // { // Create CDO resource
- // TreeNode root = createNode("root");
- // TreeNode a = createNode("a", root);
- // TreeNode b = createNode("b", root);
- // TreeNode c = createNode("c", root);
- // createNode("a1", a);
- // createNode("b1", b);
- // createNode("c1", c);
- // createExtended("a2", a);
- // createExtended("b2", b);
- // createExtended("c2", c);
- // saveRoot(root, RESOURCE);
- // }
- //
- // TreeNode root = (TreeNode) loadRoot(RESOURCE);
- // // CDOResource resource = root.cdoGetResource();
- // IOCLHelper helper = CDOHelperUtil.createOCLHelper();
- // helper.setContext(root);
- //
- // try
- // {
- // Set result = (Set) helper.evaluate(root, "ExtendedNode.allInstances()");
- // assertEquals(3, result.size());
- // }
- // catch (Exception ex)
- // {
- // ex.printStackTrace();
- // fail("Parse failed: " + ex.getLocalizedMessage());
- // }
- // }
- //
- // public void testTreeNodeExtent() throws Exception
- // {
- // final String RESOURCE = "/test/res";
- //
- // { // Create CDO resource
- // TreeNode root = createNode("root");
- // TreeNode a = createNode("a", root);
- // TreeNode b = createNode("b", root);
- // TreeNode c = createNode("c", root);
- // createNode("a1", a);
- // createNode("b1", b);
- // createNode("c1", c);
- // createExtended("a2", a);
- // createExtended("b2", b);
- // createExtended("c2", c);
- // saveRoot(root, RESOURCE);
- // }
- //
- // TreeNode root = (TreeNode) loadRoot(RESOURCE);
- // // CDOResource resource = root.cdoGetResource();
- // IOCLHelper helper = CDOHelperUtil.createOCLHelper();
- // helper.setContext(root);
- //
- // try
- // {
- // Set result = (Set) helper.evaluate(root, "TreeNode.allInstances()");
- // assertEquals(10, result.size());
- // }
- // catch (Exception ex)
- // {
- // ex.printStackTrace();
- // fail("Parse failed: " + ex.getLocalizedMessage());
- // }
- // }
- //
- // public void testExtentTwoResources() throws Exception
- // {
- // final String RESOURCE1 = "/test/res1";
- // final String RESOURCE2 = "/test/res2";
- //
- // { // Create first CDO resource
- // TreeNode root = createNode("root");
- // TreeNode a = createNode("a", root);
- // TreeNode b = createNode("b", root);
- // TreeNode c = createNode("c", root);
- // createNode("a1", a);
- // createNode("b1", b);
- // createNode("c1", c);
- // createExtended("a2", a);
- // createExtended("b2", b);
- // createExtended("c2", c);
- // saveRoot(root, RESOURCE1);
- // }
- //
- // { // Create second CDO resource
- // TreeNode root = createNode("root");
- // TreeNode a = createNode("a", root);
- // TreeNode b = createNode("b", root);
- // TreeNode c = createNode("c", root);
- // createNode("a1", a);
- // createNode("b1", b);
- // createNode("c1", c);
- // createExtended("a2", a);
- // createExtended("b2", b);
- // createExtended("c2", c);
- // saveRoot(root, RESOURCE2);
- // }
- //
- // TreeNode root = (TreeNode) loadRoot(RESOURCE1);
- // // CDOResource resource = root.cdoGetResource();
- // IOCLHelper helper = CDOHelperUtil.createOCLHelper();
- // helper.setContext(root);
- //
- // try
- // {
- // Set result = (Set) helper.evaluate(root, "ExtendedNode.allInstances()");
- // assertEquals(3, result.size());
- // }
- // catch (Exception ex)
- // {
- // ex.printStackTrace();
- // fail("Parse failed: " + ex.getLocalizedMessage());
- // }
- // }
+ public void testNotEmpty() throws Exception
+ {
+ final String RESOURCE = "/test/res";
+ final String ROOT = "root";
+ final String[] CHILDREN = { "a", "b", "c"};
+ final String EXPR = "self.children->isEmpty()";
+
+ { // Create CDO resource
+ TreeNode root = createNode(ROOT);
+ createChildren(CHILDREN, root);
+ saveRoot(root, RESOURCE);
+ }
+
+ TreeNode root = (TreeNode) loadRoot(RESOURCE);
+ IOCLHelper helper = HelperUtil.createOCLHelper();
+ helper.setContext(root);
+
+ try
+ {
+ Object result = helper.evaluate(root, EXPR);
+ assertFalse(result);
+ }
+ catch (OCLParsingException ex)
+ {
+ ex.printStackTrace();
+ fail("Parse failed: " + ex.getLocalizedMessage());
+ }
+ }
+
+ public void testEmpty() throws Exception
+ {
+ final String RESOURCE = "/test/res";
+ final String ROOT = "root";
+ final String EXPR = "self.children->isEmpty()";
+
+ { // Create CDO resource
+ TreeNode root = createNode(ROOT);
+ saveRoot(root, RESOURCE);
+ }
+
+ TreeNode root = (TreeNode) loadRoot(RESOURCE);
+ IOCLHelper helper = HelperUtil.createOCLHelper();
+ helper.setContext(root);
+
+ try
+ {
+ Object result = helper.evaluate(root, EXPR);
+ assertTrue(result);
+ }
+ catch (OCLParsingException ex)
+ {
+ ex.printStackTrace();
+ fail("Parse failed: " + ex.getLocalizedMessage());
+ }
+ }
+
+ public void testExtendedNodeExtent() throws Exception
+ {
+ final String RESOURCE = "/test/res";
+
+ { // Create CDO resource
+ TreeNode root = createNode("root");
+ TreeNode a = createNode("a", root);
+ TreeNode b = createNode("b", root);
+ TreeNode c = createNode("c", root);
+ createNode("a1", a);
+ createNode("b1", b);
+ createNode("c1", c);
+ createExtended("a2", a);
+ createExtended("b2", b);
+ createExtended("c2", c);
+ saveRoot(root, RESOURCE);
+ }
+
+ TreeNode root = (TreeNode) loadRoot(RESOURCE);
+ // CDOResource resource = root.cdoGetResource();
+ IOCLHelper helper = CDOHelperUtil.createOCLHelper();
+ helper.setContext(root);
+
+ try
+ {
+ Set result = (Set) helper.evaluate(root, "ExtendedNode.allInstances()");
+ assertEquals(3, result.size());
+ }
+ catch (OCLParsingException ex)
+ {
+ ex.printStackTrace();
+ fail("Parse failed: " + ex.getLocalizedMessage());
+ }
+ }
+
+ public void testTreeNodeExtent() throws Exception
+ {
+ final String RESOURCE = "/test/res";
+
+ { // Create CDO resource
+ TreeNode root = createNode("root");
+ TreeNode a = createNode("a", root);
+ TreeNode b = createNode("b", root);
+ TreeNode c = createNode("c", root);
+ createNode("a1", a);
+ createNode("b1", b);
+ createNode("c1", c);
+ createExtended("a2", a);
+ createExtended("b2", b);
+ createExtended("c2", c);
+ saveRoot(root, RESOURCE);
+ }
+
+ TreeNode root = (TreeNode) loadRoot(RESOURCE);
+ // CDOResource resource = root.cdoGetResource();
+ IOCLHelper helper = CDOHelperUtil.createOCLHelper();
+ helper.setContext(root);
+
+ try
+ {
+ Set result = (Set) helper.evaluate(root, "TreeNode.allInstances()");
+ assertEquals(10, result.size());
+ }
+ catch (OCLParsingException ex)
+ {
+ ex.printStackTrace();
+ fail("Parse failed: " + ex.getLocalizedMessage());
+ }
+ }
+
+ public void testExtentTwoResources() throws Exception
+ {
+ final String RESOURCE1 = "/test/res1";
+ final String RESOURCE2 = "/test/res2";
+
+ { // Create first CDO resource
+ TreeNode root = createNode("root");
+ TreeNode a = createNode("a", root);
+ TreeNode b = createNode("b", root);
+ TreeNode c = createNode("c", root);
+ createNode("a1", a);
+ createNode("b1", b);
+ createNode("c1", c);
+ createExtended("a2", a);
+ createExtended("b2", b);
+ createExtended("c2", c);
+ saveRoot(root, RESOURCE1);
+ }
+
+ { // Create second CDO resource
+ TreeNode root = createNode("root");
+ TreeNode a = createNode("a", root);
+ TreeNode b = createNode("b", root);
+ TreeNode c = createNode("c", root);
+ createNode("a1", a);
+ createNode("b1", b);
+ createNode("c1", c);
+ createExtended("a2", a);
+ createExtended("b2", b);
+ createExtended("c2", c);
+ saveRoot(root, RESOURCE2);
+ }
+
+ TreeNode root = (TreeNode) loadRoot(RESOURCE1);
+ // CDOResource resource = root.cdoGetResource();
+ IOCLHelper helper = CDOHelperUtil.createOCLHelper();
+ helper.setContext(root);
+
+ try
+ {
+ Set result = (Set) helper.evaluate(root, "ExtendedNode.allInstances()");
+ assertEquals(3, result.size());
+ }
+ catch (OCLParsingException ex)
+ {
+ ex.printStackTrace();
+ fail("Parse failed: " + ex.getLocalizedMessage());
+ }
+ }
public void testGlobalExtent() throws Exception
{
@@ -241,7 +243,7 @@ public class OCLTest extends AbstractModel1Test
Set result = (Set) helper.evaluate(root, "ExtendedNode.allInstances()");
assertEquals(6, result.size());
}
- catch (Exception ex)
+ catch (OCLParsingException ex)
{
ex.printStackTrace();
fail("Parse failed: " + ex.getLocalizedMessage());
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/SerializationTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/SerializationTest.java
index 0889766..aaf1a3a 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/SerializationTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/SerializationTest.java
@@ -49,9 +49,11 @@ public class SerializationTest extends AbstractModel1Test
final File FILE = new File("testExport.testmodel1");
final String CONTENT = "<?xml version=\"1.0\" encoding=\"ASCII\"?>\r\n"
- + "<testmodel1:TreeNode xmi:version=\"2.0\" xmlns:xmi=\"http://www.omg.org/XMI\" xmlns:testmodel1=\"http://www.eclipse.org/emf/cdo/2006/TestModel1\" stringFeature=\"root\">\r\n"
- + " <children stringFeature=\"a\"/>\r\n" + " <children stringFeature=\"b\"/>\r\n"
- + " <children stringFeature=\"c\"/>\r\n" + "</testmodel1:TreeNode>\r\n";
+ + "<testmodel1:TreeNode xmi:version=\"2.0\" xmlns:xmi=\"http://www.omg.org/XMI\" xmlns:testmodel1=\"http://www.eclipse.org/emf/cdo/2006/TestModel1\" stringFeature=\"root\">\r\n" //
+ + " <children stringFeature=\"a\"/>\r\n" //
+ + " <children stringFeature=\"b\"/>\r\n" //
+ + " <children stringFeature=\"c\"/>\r\n" //
+ + "</testmodel1:TreeNode>\r\n";
try
{
@@ -82,6 +84,63 @@ public class SerializationTest extends AbstractModel1Test
}
}
+ public void testExportThreeLevels() throws Exception
+ {
+ final String RESOURCE = "/test/res";
+ final String ROOT = "root";
+ final String[] CHILDREN = { "a", "b", "c"};
+
+ final File FILE = new File("testExport.testmodel1");
+ final String CONTENT = "<?xml version=\"1.0\" encoding=\"ASCII\"?>\r\n"
+ + "<testmodel1:TreeNode xmi:version=\"2.0\" xmlns:xmi=\"http://www.omg.org/XMI\" xmlns:testmodel1=\"http://www.eclipse.org/emf/cdo/2006/TestModel1\" stringFeature=\"root\">\r\n" //
+ + " <children stringFeature=\"a\">\r\n" //
+ + " <children stringFeature=\"a\"/>\r\n" //
+ + " <children stringFeature=\"b\"/>\r\n" //
+ + " <children stringFeature=\"c\"/>\r\n" //
+ + " </children>\r\n" //
+ + " <children stringFeature=\"b\">\r\n" //
+ + " <children stringFeature=\"a\"/>\r\n" //
+ + " <children stringFeature=\"b\"/>\r\n" //
+ + " <children stringFeature=\"c\"/>\r\n" //
+ + " </children>\r\n" //
+ + " <children stringFeature=\"c\">\r\n" //
+ + " <children stringFeature=\"a\"/>\r\n" //
+ + " <children stringFeature=\"b\"/>\r\n" //
+ + " <children stringFeature=\"c\"/>\r\n" //
+ + " </children>\r\n" //
+ + "</testmodel1:TreeNode>\r\n";
+
+ try
+ {
+ { // Execution
+ TreeNode root = createNode(ROOT);
+ TreeNode[] children = createChildren(CHILDREN, root);
+ for (int i = 0; i < children.length; i++)
+ createChildren(CHILDREN, children[i]);
+ saveRoot(root, RESOURCE);
+
+ TreeNode loaded = (TreeNode) loadRoot(RESOURCE);
+ preLoadResource((CDOResource) loaded.eResource());
+ EObject copied = EcoreUtil.copy(loaded);
+
+ ResourceSet resourceSet = createXMIResourceSet();
+ URI uri = URI.createFileURI(FILE.getAbsolutePath());
+ Resource xmiResource = resourceSet.createResource(uri);
+ xmiResource.getContents().add(copied);
+ xmiResource.save(new HashMap());
+ }
+
+ { // Verification
+ String content = IOHelper.readFully(FILE);
+ assertEquals(CONTENT, content);
+ }
+ }
+ finally
+ {
+ FILE.delete();
+ }
+ }
+
public void testImport() throws Exception
{
final String RESOURCE = "/test/res";