Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2013-01-15 06:21:55 -0500
committerEike Stepper2013-01-15 06:21:55 -0500
commit135773083b63ff40e0df608ce59ef58cf5761563 (patch)
tree197566d2f252ed67e1a30886aa530d07880bb2b2
parentd3697c431c736e1a4357b9ec160910704cf04655 (diff)
downloadcdo-135773083b63ff40e0df608ce59ef58cf5761563.tar.gz
cdo-135773083b63ff40e0df608ce59ef58cf5761563.tar.xz
cdo-135773083b63ff40e0df608ce59ef58cf5761563.zip
[397629] [Legacy] Objects not attached to their resources when resolving
cross-resource references https://bugs.eclipse.org/bugs/show_bug.cgi?id=397629
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.model5/src/org/eclipse/emf/cdo/tests/model5/legacy/impl/ChildImpl.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.model5/src/org/eclipse/emf/cdo/tests/model5/legacy/impl/ParentImpl.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceTest.java60
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java4
4 files changed, 76 insertions, 4 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests.model5/src/org/eclipse/emf/cdo/tests/model5/legacy/impl/ChildImpl.java b/plugins/org.eclipse.emf.cdo.tests.model5/src/org/eclipse/emf/cdo/tests/model5/legacy/impl/ChildImpl.java
index 2b550e7206..97ee894f31 100644
--- a/plugins/org.eclipse.emf.cdo.tests.model5/src/org/eclipse/emf/cdo/tests/model5/legacy/impl/ChildImpl.java
+++ b/plugins/org.eclipse.emf.cdo.tests.model5/src/org/eclipse/emf/cdo/tests/model5/legacy/impl/ChildImpl.java
@@ -203,7 +203,7 @@ public class ChildImpl extends EObjectImpl implements Child
* <!-- end-user-doc -->
* @generated
*/
- public void setPreferredBy(Parent newPreferredBy)
+ public void setPreferredByGen(Parent newPreferredBy)
{
if (newPreferredBy != preferredBy)
{
@@ -221,6 +221,12 @@ public class ChildImpl extends EObjectImpl implements Child
newPreferredBy));
}
+ public void setPreferredBy(Parent newPreferredBy)
+ {
+ IsLoadingTestFixture.reportLoading(eResource(), this);
+ setPreferredByGen(newPreferredBy);
+ }
+
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
diff --git a/plugins/org.eclipse.emf.cdo.tests.model5/src/org/eclipse/emf/cdo/tests/model5/legacy/impl/ParentImpl.java b/plugins/org.eclipse.emf.cdo.tests.model5/src/org/eclipse/emf/cdo/tests/model5/legacy/impl/ParentImpl.java
index 04ac655d06..2979c531a9 100644
--- a/plugins/org.eclipse.emf.cdo.tests.model5/src/org/eclipse/emf/cdo/tests/model5/legacy/impl/ParentImpl.java
+++ b/plugins/org.eclipse.emf.cdo.tests.model5/src/org/eclipse/emf/cdo/tests/model5/legacy/impl/ParentImpl.java
@@ -184,7 +184,7 @@ public class ParentImpl extends EObjectImpl implements Parent
* <!-- end-user-doc -->
* @generated
*/
- public void setFavourite(Child newFavourite)
+ public void setFavouriteGen(Child newFavourite)
{
if (newFavourite != favourite)
{
@@ -201,6 +201,12 @@ public class ParentImpl extends EObjectImpl implements Parent
eNotify(new ENotificationImpl(this, Notification.SET, Model5Package.PARENT__FAVOURITE, newFavourite, newFavourite));
}
+ public void setFavourite(Child newFavourite)
+ {
+ IsLoadingTestFixture.reportLoading(eResource(), this);
+ setFavouriteGen(newFavourite);
+ }
+
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
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
index 6c0e4c252d..c0623f558c 100644
--- 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
@@ -1854,6 +1854,66 @@ public class ResourceTest extends AbstractCDOTest
}
/**
+ * Bug 397629: Test the {@link org.eclipse.emf.ecore.resource.Resource.Internal#isLoading()}
+ * behaviour in {@link CDOResource}s for legacy models when resolving cross-document references
+ * (bottom-up resource loading).
+ */
+ @Requires(ModelConfig.CAPABILITY_LEGACY)
+ public void testResourceIsLoading_crossResourceRef() throws Exception
+ {
+ final IsLoadingTestFixture fixture = IsLoadingTestFixture.newInstance();
+
+ try
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource1 = transaction.createResource(getResourcePath("/my/resource1"));
+ CDOResource resource2 = transaction.createResource(getResourcePath("/my/resource2"));
+
+ Parent parent = getModel5Factory().createParent();
+ resource1.getContents().add(parent);
+ parent.setName("parent");
+
+ Parent container = getModel5Factory().createParent();
+ resource2.getContents().add(container);
+ container.setName("Fake parent container");
+
+ Child child = getModel5Factory().createChild();
+ container.getChildren().add(child);
+ child.setName("child");
+
+ // cross-resource reference
+ parent.setFavourite(child);
+
+ fixture.assertNotReportedLoading(resource1, parent);
+ fixture.assertNotReportedLoading(resource2, child);
+
+ transaction.commit();
+ session.close();
+
+ session = openSession();
+ transaction = session.openTransaction();
+ resource1 = transaction.getResource(getResourcePath("/my/resource1"));
+ resource2 = transaction.getResource(getResourcePath("/my/resource2"));
+
+ // resolve all cross-references out of resource1
+ EcoreUtil.resolveAll((Resource)resource1);
+ for (Iterator<EObject> iter = resource2.getAllContents(); iter.hasNext();)
+ {
+ // every object in the resource detected that it was being loaded
+ fixture.assertReportedLoading(resource2, iter.next());
+ }
+
+ session.close();
+ }
+ finally
+ {
+ fixture.dispose();
+ }
+ }
+
+ /**
* @author Eike Stepper
*/
private static class TestAdapter extends AdapterImpl
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java
index 40e21bd3c3..6ef309baba 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java
@@ -379,6 +379,8 @@ public abstract class CDOLegacyWrapper extends CDOObjectWrapper
view.registerObject(this);
revisionToInstanceResource();
+ revisionToInstanceContainer();
+
Resource eResource = instance.eResource();
if (eResource instanceof InternalCDOResource)
{
@@ -386,8 +388,6 @@ public abstract class CDOLegacyWrapper extends CDOObjectWrapper
resource.cdoInternalLoading(instance);
}
- revisionToInstanceContainer();
-
EClass eClass = revision.getEClass();
EStructuralFeature[] allPersistentFeatures = CDOModelUtil.getAllPersistentFeatures(eClass);
for (EStructuralFeature feature : allPersistentFeatures)

Back to the top