diff options
author | Eike Stepper | 2010-09-17 16:21:21 +0000 |
---|---|---|
committer | Eike Stepper | 2010-09-17 16:21:21 +0000 |
commit | 8b1aaae49b089b0193fa57afa8d940b26a3813e9 (patch) | |
tree | bd6cc1bd4a97675008ef24380551feaea7c0af43 | |
parent | ce922b2bf88e51dfd1dc3cfa505c9a1855ee4526 (diff) | |
download | cdo-8b1aaae49b089b0193fa57afa8d940b26a3813e9.tar.gz cdo-8b1aaae49b089b0193fa57afa8d940b26a3813e9.tar.xz cdo-8b1aaae49b089b0193fa57afa8d940b26a3813e9.zip |
[325603] CDOResourceImpl throws IllegalStateException
https://bugs.eclipse.org/bugs/show_bug.cgi?id=325603
3 files changed, 62 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 ad86a649b5..7a908f5e8c 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 @@ -97,6 +97,7 @@ import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_324084_Test; import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_324585_Test; import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_324635_Test; import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_324756_Test; +import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_325603_Test; import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite; @@ -259,6 +260,7 @@ public abstract class AllConfigs extends ConfigTestSuite testClasses.add(Bugzilla_324585_Test.class); testClasses.add(Bugzilla_324635_Test.class); testClasses.add(Bugzilla_324756_Test.class); + testClasses.add(Bugzilla_325603_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_325603_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_325603_Test.java new file mode 100644 index 0000000000..e23271fe3f --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_325603_Test.java @@ -0,0 +1,49 @@ +/** + * 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: + * Martin Fluegge - 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.transaction.CDOTransaction; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.impl.AdapterImpl; +import org.eclipse.emf.ecore.resource.Resource; + +/** + * @author Martin Fluegge + */ +public class Bugzilla_325603_Test extends AbstractCDOTest +{ + public void testModifyResource() throws Exception + { + CDOSession session = openSession(); + CDOTransaction transaction = session.openTransaction(); + CDOResource resource = transaction.createResource("/r1"); + + resource.eAdapters().add(new AdapterImpl() + { + @Override + public void notifyChanged(Notification notification) + { + if (notification.getFeatureID(Resource.class) == Resource.RESOURCE__IS_MODIFIED) + { + assertInstanceOf(Boolean.class, notification.getOldValue()); + notification.getOldBooleanValue(); + // passed if we do not get an exception here + } + } + }); + + resource.setModified(true); + } +} 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 ceb770b4ff..436ec2501c 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 @@ -132,6 +132,11 @@ public class CDOResourceImpl extends CDOResourceNodeImpl implements CDOResource, /** * @ADDED */ + private boolean modified; + + /** + * @ADDED + */ private EList<Diagnostic> errors; /** @@ -335,11 +340,11 @@ public class CDOResourceImpl extends CDOResourceNodeImpl implements CDOResource, /** * <!-- begin-user-doc --> <!-- end-user-doc --> * - * @generated + * @generated NOT */ public boolean isModified() { - return (Boolean)eGet(EresourcePackage.Literals.CDO_RESOURCE__MODIFIED, true); + return modified; } /** @@ -349,11 +354,11 @@ public class CDOResourceImpl extends CDOResourceNodeImpl implements CDOResource, */ public void setModified(boolean newModified) { - boolean oldIsModified = isModified(); - eSet(EresourcePackage.Literals.CDO_RESOURCE__MODIFIED, Boolean.valueOf(newModified)); - if (eNotificationRequired()) + boolean oldModified = modified; + modified = newModified; + if (oldModified != newModified && eNotificationRequired()) { - Notification notification = new NotificationImpl(Notification.SET, oldIsModified, newModified) + Notification notification = new NotificationImpl(Notification.SET, oldModified, newModified) { @Override public Object getNotifier() |