summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2006-08-23 05:54:22 (EDT)
committerEike Stepper2006-08-23 05:54:22 (EDT)
commitb39800752e0296fb38a2b58e9382c6362f110be1 (patch)
tree619cb05d2bf69460475438596151e9e26b756e35
parent77a5b25e0d96d3ba47bd7c2ecddf7e288a7bf7d8 (diff)
downloadcdo-b39800752e0296fb38a2b58e9382c6362f110be1.zip
cdo-b39800752e0296fb38a2b58e9382c6362f110be1.tar.gz
cdo-b39800752e0296fb38a2b58e9382c6362f110be1.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/src/org/eclipse/emf/cdo/tests/model1/SerializationTest.java65
1 files changed, 62 insertions, 3 deletions
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";