Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Fluegge2011-08-31 09:03:57 -0400
committerMartin Fluegge2011-08-31 09:03:57 -0400
commit1837d87cc1f72263d0ab4223ab6c96b455936028 (patch)
tree6ca347471376157fd56e02e220af4a3e3b4e8b58
parent900ef951fadcbff547149e6d6e03b5ba506c7e9f (diff)
downloadcdo-1837d87cc1f72263d0ab4223ab6c96b455936028.tar.gz
cdo-1837d87cc1f72263d0ab4223ab6c96b455936028.tar.xz
cdo-1837d87cc1f72263d0ab4223ab6c96b455936028.zip
https://bugs.eclipse.org/bugs/show_bug.cgi?id=355923
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_355915_Test.java184
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDODeltaNotificationImpl.java155
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOInvalidationNotificationImpl.java3
4 files changed, 201 insertions, 142 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 42bfd49ed6..c564ab4eea 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
@@ -238,5 +238,6 @@ public abstract class AllConfigs extends ConfigTestSuite
testClasses.add(Bugzilla_351393_Test.class);
testClasses.add(Bugzilla_352303_Test.class);
testClasses.add(Bugzilla_354395_Test.class);
+ testClasses.add(Bugzilla_355915_Test.class);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_355915_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_355915_Test.java
new file mode 100644
index 0000000000..669c1a13c0
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_355915_Test.java
@@ -0,0 +1,184 @@
+/**
+ * Copyright (c) 2004 - 2011 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:
+ * Eike Stepper - 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.model1.Customer;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.resource.Resource;
+
+import java.util.Collections;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author Martin Fluegge
+ */
+public class Bugzilla_355915_Test extends AbstractCDOTest
+{
+ private static final String RESOURCE_PATH = "/test1";
+
+ private CountDownLatch latch;
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ super.doSetUp();
+ latch = new CountDownLatch(1);
+ }
+
+ @CleanRepositoriesBefore
+ public void testInvalidationNotification() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOUtil.setLegacyModeDefault(true);
+
+ CDOTransaction transaction1 = session.openTransaction();
+ transaction1.options().setInvalidationNotificationEnabled(true);
+
+ CDOResource resource1 = transaction1.createResource(getResourcePath(RESOURCE_PATH));
+
+ // 1. Create a example model
+ Customer customer1 = getModel1Factory().createCustomer();
+ customer1.setName("Martin Fluegge");
+ customer1.setStreet("ABC Street 7");
+ customer1.setCity("Berlin");
+
+ TestAdapter adapter = new TestAdapter();
+ customer1.eAdapters().add(adapter);
+
+ resource1.getContents().add(customer1);
+ resource1.save(Collections.emptyMap());
+
+ Thread thread = new Thread(new Runnable()
+ {
+ public void run()
+ {
+ CDOSession session = openSession();
+ CDOUtil.setLegacyModeDefault(true);
+
+ CDOTransaction transaction2 = session.openTransaction();
+
+ Resource resource2 = transaction2.getResource(getResourcePath(RESOURCE_PATH));
+ Customer customer2 = (Customer)resource2.getContents().get(0);
+ customer2.setName("newName");
+
+ try
+ {
+ transaction2.commit();
+ }
+ catch (CommitException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ });
+
+ thread.start();
+ thread.join();
+
+ latch.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
+ assertEquals(true, adapter.notified());
+ assertEquals(true, adapter.assertCorrectNotification());
+ }
+
+ @CleanRepositoriesBefore
+ public void testDeltaNotification() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOUtil.setLegacyModeDefault(true);
+
+ CDOTransaction transaction1 = session.openTransaction();
+ transaction1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+
+ CDOResource resource1 = transaction1.createResource(getResourcePath(RESOURCE_PATH));
+
+ // 1. Create a example model
+ Customer customer1 = getModel1Factory().createCustomer();
+ customer1.setName("Martin Fluegge");
+ customer1.setStreet("ABC Street 7");
+ customer1.setCity("Berlin");
+
+ TestAdapter adapter = new TestAdapter();
+ customer1.eAdapters().add(adapter);
+
+ resource1.getContents().add(customer1);
+ resource1.save(Collections.emptyMap());
+
+ Thread thread = new Thread(new Runnable()
+ {
+ public void run()
+ {
+ CDOSession session = openSession();
+ CDOUtil.setLegacyModeDefault(true);
+
+ CDOTransaction transaction2 = session.openTransaction();
+
+ Resource resource2 = transaction2.getResource(getResourcePath(RESOURCE_PATH));
+ Customer customer2 = (Customer)resource2.getContents().get(0);
+ customer2.setName("newName");
+
+ try
+ {
+ transaction2.commit();
+ }
+ catch (CommitException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ });
+
+ thread.start();
+ thread.join();
+
+ latch.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
+ assertEquals(true, adapter.notified());
+ assertEquals(true, adapter.assertCorrectNotification());
+ }
+
+ /**
+ * @author Martin Fluegge
+ */
+ class TestAdapter extends AdapterImpl
+ {
+ private boolean assertCorrectNotification;
+
+ private boolean notified;
+
+ @Override
+ public void notifyChanged(Notification notification)
+ {
+ notified = true;
+ Object notifier = notification.getNotifier();
+ assertCorrectNotification = notifier instanceof Customer;
+ latch.countDown();
+ }
+
+ public boolean notified()
+ {
+ return notified;
+ }
+
+ public boolean assertCorrectNotification()
+ {
+ return assertCorrectNotification;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDODeltaNotificationImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDODeltaNotificationImpl.java
index 15dbd44a7e..87f9be731c 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDODeltaNotificationImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDODeltaNotificationImpl.java
@@ -14,10 +14,12 @@ package org.eclipse.emf.internal.cdo.object;
import org.eclipse.emf.cdo.CDODeltaNotification;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
+import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.util.ObjectNotFoundException;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.ECollections;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
@@ -33,152 +35,21 @@ public class CDODeltaNotificationImpl extends ENotificationImpl implements CDODe
private CDORevisionDelta revisionDelta;
public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, EStructuralFeature feature, Object oldValue,
- Object newValue, boolean isSetChange)
- {
- super(notifier, eventType, feature, oldValue, newValue, isSetChange);
- }
-
- public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, EStructuralFeature feature, Object oldValue,
- Object newValue, int position, boolean wasSet)
- {
- super(notifier, eventType, feature, oldValue, newValue, position, wasSet);
- }
-
- public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, EStructuralFeature feature, Object oldValue,
- Object newValue, int position)
- {
- super(notifier, eventType, feature, oldValue, newValue, position);
- }
-
- public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, EStructuralFeature feature, Object oldValue,
Object newValue)
{
- super(notifier, eventType, feature, oldValue, newValue);
- }
-
- public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, boolean oldBooleanValue,
- boolean newBooleanValue, boolean isSetChange)
- {
- super(notifier, eventType, featureID, oldBooleanValue, newBooleanValue, isSetChange);
- }
-
- public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, boolean oldBooleanValue,
- boolean newBooleanValue)
- {
- super(notifier, eventType, featureID, oldBooleanValue, newBooleanValue);
- }
-
- public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, byte oldByteValue,
- byte newByteValue, boolean isSetChange)
- {
- super(notifier, eventType, featureID, oldByteValue, newByteValue, isSetChange);
- }
-
- public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, byte oldByteValue,
- byte newByteValue)
- {
- super(notifier, eventType, featureID, oldByteValue, newByteValue);
- }
-
- public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, char oldCharValue,
- char newCharValue, boolean isSetChange)
- {
- super(notifier, eventType, featureID, oldCharValue, newCharValue, isSetChange);
- }
-
- public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, char oldCharValue,
- char newCharValue)
- {
- super(notifier, eventType, featureID, oldCharValue, newCharValue);
- }
-
- public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, double oldDoubleValue,
- double newDoubleValue, boolean isSetChange)
- {
- super(notifier, eventType, featureID, oldDoubleValue, newDoubleValue, isSetChange);
- }
-
- public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, double oldDoubleValue,
- double newDoubleValue)
- {
- super(notifier, eventType, featureID, oldDoubleValue, newDoubleValue);
- }
-
- public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, float oldFloatValue,
- float newFloatValue, boolean isSetChange)
- {
- super(notifier, eventType, featureID, oldFloatValue, newFloatValue, isSetChange);
- }
-
- public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, float oldFloatValue,
- float newFloatValue)
- {
- super(notifier, eventType, featureID, oldFloatValue, newFloatValue);
- }
-
- public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, int oldIntValue,
- int newIntValue, boolean isSetChange)
- {
- super(notifier, eventType, featureID, oldIntValue, newIntValue, isSetChange);
- }
-
- public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, int oldIntValue,
- int newIntValue)
- {
- super(notifier, eventType, featureID, oldIntValue, newIntValue);
- }
-
- public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, long oldLongValue,
- long newLongValue, boolean isSetChange)
- {
- super(notifier, eventType, featureID, oldLongValue, newLongValue, isSetChange);
- }
-
- public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, long oldLongValue,
- long newLongValue)
- {
- super(notifier, eventType, featureID, oldLongValue, newLongValue);
- }
-
- public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, Object oldValue,
- Object newValue, boolean isSetChange)
- {
- super(notifier, eventType, featureID, oldValue, newValue, isSetChange);
- }
-
- public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, Object oldValue,
- Object newValue, int position, boolean wasSet)
- {
- super(notifier, eventType, featureID, oldValue, newValue, position, wasSet);
+ super(getEObject(notifier), eventType, feature, oldValue, newValue);
}
public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, Object oldValue,
Object newValue, int position)
{
- super(notifier, eventType, featureID, oldValue, newValue, position);
+ super(getEObject(notifier), eventType, featureID, oldValue, newValue, position);
}
public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, Object oldValue,
Object newValue)
{
- super(notifier, eventType, featureID, oldValue, newValue);
- }
-
- public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, short oldShortValue,
- short newShortValue, boolean isSetChange)
- {
- super(notifier, eventType, featureID, oldShortValue, newShortValue, isSetChange);
- }
-
- public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, short oldShortValue,
- short newShortValue)
- {
- super(notifier, eventType, featureID, oldShortValue, newShortValue);
- }
-
- private InternalCDOObject getCDOObject()
- {
- return (InternalCDOObject)getNotifier();
+ super(getEObject(notifier), eventType, featureID, oldValue, newValue);
}
@Override
@@ -248,13 +119,15 @@ public class CDODeltaNotificationImpl extends ENotificationImpl implements CDODe
{
// Do not merge at all. See bug 317144.
return false;
+ }
- // if (eventType == REMOVE_MANY && newValue == null)
- // {
- // // Means that clear all was executed and no merging can appear
- // return false;
- // }
- //
- // return super.merge(notification);
+ private InternalCDOObject getCDOObject()
+ {
+ return (InternalCDOObject)CDOUtil.getCDOObject((EObject)getNotifier());
+ }
+
+ private static InternalEObject getEObject(InternalEObject notifier)
+ {
+ return (InternalEObject)CDOUtil.getEObject(notifier);
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOInvalidationNotificationImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOInvalidationNotificationImpl.java
index 274121376f..6677cd406b 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOInvalidationNotificationImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOInvalidationNotificationImpl.java
@@ -12,6 +12,7 @@
package org.eclipse.emf.internal.cdo.object;
import org.eclipse.emf.cdo.CDOInvalidationNotification;
+import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EObject;
@@ -25,7 +26,7 @@ public class CDOInvalidationNotificationImpl implements CDOInvalidationNotificat
public CDOInvalidationNotificationImpl(EObject eObject)
{
- this.eObject = eObject;
+ this.eObject = CDOUtil.getEObject(eObject);
}
public Object getNotifier()

Back to the top