summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaspar De Groot2010-10-31 22:44:11 (EDT)
committerCaspar De Groot2010-10-31 22:44:11 (EDT)
commitbe6553d44a93167530ca5afd389c62518cd23542 (patch)
tree2c175f5443e49f510382d7e62f375b7e537a5c9d
parentbf7e2e045b1ae160afa5faa2ce4420fe58ad0dee (diff)
downloadcdo-be6553d44a93167530ca5afd389c62518cd23542.zip
cdo-be6553d44a93167530ca5afd389c62518cd23542.tar.gz
cdo-be6553d44a93167530ca5afd389c62518cd23542.tar.bz2
[328790] CDOResource.isLoaded returns false after adding/clearing contents of new resource
https://bugs.eclipse.org/bugs/show_bug.cgi?id=328790
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_328790_Test.java89
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java37
3 files changed, 122 insertions, 6 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java
index b003a05..736a570 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java
@@ -99,6 +99,7 @@ import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_325603_Test;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_325866_Test;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_326518_Test;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_326743_Test;
+import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_328790_Test;
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite;
@@ -265,6 +266,7 @@ public abstract class AllConfigs extends ConfigTestSuite
testClasses.add(Bugzilla_325866_Test.class);
testClasses.add(Bugzilla_326518_Test.class);
testClasses.add(Bugzilla_326743_Test.class);
+ testClasses.add(Bugzilla_328790_Test.class);
// TODO testClasses.add(NonCDOResourceTest.class);
// TODO testClasses.add(GeneratedEcoreTest.class);
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_328790_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_328790_Test.java
new file mode 100644
index 0000000..4435f2d
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_328790_Test.java
@@ -0,0 +1,89 @@
+/**
+ * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.legacy.model1.Model1Factory;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+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;
+
+/**
+ * Bug 328790 - CDOResource.isLoaded returns false after adding/clearing contents of new resource
+ *
+ * @author Caspar De Groot
+ */
+public class Bugzilla_328790_Test extends AbstractCDOTest
+{
+ public void test_newThenAdd1() throws CommitException
+ {
+ CDOSession session = openSession();
+ ResourceSet resourceSet = new ResourceSetImpl();
+ CDOTransaction tx = session.openTransaction(resourceSet);
+
+ Resource resource = resourceSet.createResource(URI.createURI("cdo://myUri"));
+ EObject object = Model1Factory.eINSTANCE.createAddress();
+ resource.getContents().add(object);
+
+ assertTrue(resource.isLoaded());
+
+ tx.commit();
+
+ assertTrue(resource.isLoaded());
+
+ tx.close();
+ session.close();
+ }
+
+ public void test_newThenAdd2() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+
+ CDOResource resource = tx.createResource("/myUri");
+ EObject object = Model1Factory.eINSTANCE.createAddress();
+ resource.getContents().add(object);
+
+ assertTrue(resource.isLoaded());
+
+ tx.commit();
+
+ assertTrue(resource.isLoaded());
+
+ tx.close();
+ session.close();
+ }
+
+ public void test_newThenClear() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+
+ CDOResource resource = tx.createResource("/myUri");
+ resource.getContents().clear();
+
+ assertTrue(resource.isLoaded());
+
+ tx.commit();
+
+ assertTrue(resource.isLoaded());
+
+ tx.close();
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java
index e7cba0a..a1893fc 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java
@@ -1425,13 +1425,10 @@ public class CDOResourceImpl extends CDOResourceNodeImpl implements CDOResource,
*/
protected void loaded()
{
- if (!isLoaded())
+ Notification notification = setLoaded(true);
+ if (notification != null)
{
- Notification notification = setLoaded(true);
- if (notification != null)
- {
- eNotify(notification);
- }
+ eNotify(notification);
}
}
@@ -1472,5 +1469,33 @@ public class CDOResourceImpl extends CDOResourceNodeImpl implements CDOResource,
{
return true;
}
+
+ /**
+ * @since 4.0
+ */
+ @Override
+ protected void didAdd(int index, Object newObject)
+ {
+ super.didAdd(index, newObject);
+
+ if (!isExisting() && !isLoaded())
+ {
+ loaded();
+ }
+ }
+
+ /**
+ * @since 4.0
+ */
+ @Override
+ protected void didClear(int size, Object[] oldObjects)
+ {
+ super.didClear(size, oldObjects);
+
+ if (!isExisting() && !isLoaded())
+ {
+ loaded();
+ }
+ }
}
} // CDOResourceImpl