summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2006-08-21 08:34:49 (EDT)
committerEike Stepper2006-08-21 08:34:49 (EDT)
commitb8caced330cd9ba5fd47c1daa4885b0387d12f73 (patch)
treedacdedeb4b9082e4c55bb37ad16b6345c47e59a2
parentadf73ce1a0f3461bcbab8229dd2277941ec84f9c (diff)
downloadcdo-b8caced330cd9ba5fd47c1daa4885b0387d12f73.zip
cdo-b8caced330cd9ba5fd47c1daa4885b0387d12f73.tar.gz
cdo-b8caced330cd9ba5fd47c1daa4885b0387d12f73.tar.bz2
[154522] Copy from CDO resource to XMI resource does not work
https://bugs.eclipse.org/bugs/show_bug.cgi?id=154389
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/launches/CDO Serialization Test.launch38
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/SerializationTest.java90
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/topology/ClientTopology.java17
3 files changed, 145 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/launches/CDO Serialization Test.launch b/plugins/org.eclipse.emf.cdo.tests/launches/CDO Serialization Test.launch
new file mode 100644
index 0000000..267840b
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/launches/CDO Serialization 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="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="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.cdo.tests,org.eclipse.emf.cdo.mapping,org.eclipse.emf.cdo.core,org.eclipse.emf.cdo.client,org.eclipse.net4j.util,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="location" value="${workspace_loc}/../junit-workspace"/>
+<stringAttribute key="application" value="org.eclipse.pde.junit.runtime.coretestapplication"/>
+<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
+<booleanAttribute key="clearws" value="true"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.model1.SerializationTest"/>
+<stringAttribute key="pde.version" value="3.2a"/>
+<stringAttribute key="templateConfig" value="${target_home}\configuration\config.ini"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dcdo.test.mode=client-separated-server"/>
+<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/SerializationTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/SerializationTest.java
new file mode 100644
index 0000000..9860c3d
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/SerializationTest.java
@@ -0,0 +1,90 @@
+/***************************************************************************
+ * 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.CDOPersistable;
+import org.eclipse.emf.cdo.client.CDOResource;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
+
+import org.eclipse.net4j.util.IOHelper;
+
+import testmodel1.TreeNode;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import java.io.File;
+
+
+public class SerializationTest extends AbstractModel1Test
+{
+ public void testExport() 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=\"b\"/>\r\n"
+ + " <children stringFeature=\"c\"/>\r\n" + "</testmodel1:TreeNode>\r\n";
+
+ try
+ {
+ { // Execution
+ TreeNode root = createNode(ROOT);
+ createChildren(CHILDREN, root);
+ saveRoot(root, RESOURCE);
+
+ TreeNode loaded = (TreeNode) loadRoot(RESOURCE);
+ preLoadResource((CDOResource) loaded.eResource());
+ EObject copied = EcoreUtil.copy(loaded);
+
+ ResourceSet resourceSet = new ResourceSetImpl();
+ Map map = resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap();
+ map.put("testmodel1", new XMIResourceFactoryImpl());
+
+ 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();
+ }
+ }
+
+ protected void preLoadResource(CDOResource cdoResource)
+ {
+ for (Iterator it = EcoreUtil.getAllContents(cdoResource, true); it.hasNext();)
+ {
+ CDOPersistable persistable = (CDOPersistable) it.next();
+ persistable.cdoLoad();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/topology/ClientTopology.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/topology/ClientTopology.java
index 26c4be4..3aad3b7 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/topology/ClientTopology.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/topology/ClientTopology.java
@@ -11,21 +11,38 @@
package org.eclipse.emf.cdo.tests.topology;
+import org.eclipse.net4j.spring.Container;
+
import javax.sql.DataSource;
public class ClientTopology extends AbstractTopology
{
+ private Container net4j;
+
+ private Container net4jClient;
+
public ClientTopology()
{
}
public void start() throws Exception
{
+ super.start();
+
+ // Start client
+ net4j = createContainer("net4j", NET4J_LOCATION, null);
+ net4jClient = createContainer("client", NET4J_CLIENT_LOCATION, net4j);
+ createCDOClient("cdo", net4jClient);
}
public void stop() throws Exception
{
+ super.stop();
+
+ //Stop client
+ net4jClient.stop();
+ net4j.stop();
}
public DataSource getDataSource()