summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-09-13 04:52:10 (EDT)
committerEike Stepper2007-09-13 04:52:10 (EDT)
commit0d120401b7c42c311a3f47f37fec4e699ff820ec (patch)
tree407bf56313a0c48622df703de00646d4322aa968
parent28ba1a2743954c71571b88c5aa4495af0ce99646 (diff)
downloadcdo-0d120401b7c42c311a3f47f37fec4e699ff820ec.zip
cdo-0d120401b7c42c311a3f47f37fec4e699ff820ec.tar.gz
cdo-0d120401b7c42c311a3f47f37fec4e699ff820ec.tar.bz2
[203165] eResource not set properly for objects
https://bugs.eclipse.org/bugs/show_bug.cgi?id=203165
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceTest.java38
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java8
3 files changed, 46 insertions, 1 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java
index 9d4892b..91e475a 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java
@@ -24,6 +24,7 @@ public class AllTests
// $JUnit-BEGIN$
suite.addTestSuite(InitialTest.class);
+ suite.addTestSuite(ResourceTest.class);
suite.addTestSuite(ContainmentTest.class);
suite.addTestSuite(InvalidationTest.class);
suite.addTestSuite(CrossReferenceTest.class);
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceTest.java
new file mode 100644
index 0000000..0ccca6e
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceTest.java
@@ -0,0 +1,38 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, 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:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ **************************************************************************/
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.tests.model1.Model1Factory;
+import org.eclipse.emf.cdo.tests.model1.Supplier;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.impl.ResourceImpl;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Eike Stepper
+ */
+public class ResourceTest extends TestCase
+{
+ public void testNonCDOResource() throws Exception
+ {
+ Supplier supplier = Model1Factory.eINSTANCE.createSupplier();
+
+ Resource resource = new ResourceImpl();
+ resource.setURI(URI.createFileURI("/res1"));
+ resource.getContents().add(supplier);
+
+ assertEquals(resource, supplier.eResource());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
index a2bcb51..d711afd 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
@@ -397,7 +397,13 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
@Override
public Resource eResource()
{
- return cdoResource();
+ Resource resource = cdoResource();
+ if (resource == null && FSMUtil.isTransient(this))
+ {
+ resource = super.eResource();
+ }
+
+ return resource;
}
@Override