Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2010-05-04 10:00:12 +0000
committerEike Stepper2010-05-04 10:00:12 +0000
commit8bc74403990574c4d92b8bc0d5be05aa7c817619 (patch)
tree13bc8d400818f5051cfe5fff13566f92355337fc /plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/OldValueNotificationTest.java
parentc22713f193ebc115e63f0fb51b10aca9ea4940c7 (diff)
downloadcdo-8bc74403990574c4d92b8bc0d5be05aa7c817619.tar.gz
cdo-8bc74403990574c4d92b8bc0d5be05aa7c817619.tar.xz
cdo-8bc74403990574c4d92b8bc0d5be05aa7c817619.zip
M7 prep
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/OldValueNotificationTest.java')
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/OldValueNotificationTest.java87
1 files changed, 87 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/OldValueNotificationTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/OldValueNotificationTest.java
new file mode 100644
index 0000000000..17548713d9
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/OldValueNotificationTest.java
@@ -0,0 +1,87 @@
+/**
+ * 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:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.model1.Address;
+import org.eclipse.emf.cdo.tests.model2.SpecialPurchaseOrder;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.common.notify.Notification;
+
+import java.util.Date;
+
+/**
+ *
+ */
+public class OldValueNotificationTest extends AbstractCDOTest
+{
+ public void testSameSession() throws Exception
+ {
+ final CDOSession session = openSession();
+ final CDOTransaction transaction = session.openTransaction();
+ transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+
+ Address address1 = getModel1Factory().createAddress();
+ address1.setCity("Basel");
+ address1.setStreet("Turnerstrasse 39");
+ address1.setName("Michael Szediwy");
+
+ SpecialPurchaseOrder order = getModel2Factory().createSpecialPurchaseOrder();
+ order.setDate(new Date());
+ order.setShippingAddress(address1);
+
+ final CDOResource resourceA = transaction.createResource("/test1");
+ resourceA.getContents().add(order);
+ transaction.commit();
+
+ final TestAdapter adapter = new TestAdapter()
+ {
+ @Override
+ public void notifyChanged(Notification notification)
+ {
+ super.notifyChanged(notification);
+ }
+ };
+
+ final CDOView view = session.openView();
+ SpecialPurchaseOrder roOrder = view.getObject(order);
+ System.out.println(CDOUtil.getCDOObject(roOrder).cdoState());
+ roOrder.eAdapters().add(adapter);
+
+ Address address2 = getModel1Factory().createAddress();
+ address2.setCity("Basel2");
+ address2.setStreet("Turnerstrasse 392");
+ address2.setName("Michael Szediwy2");
+
+ order.setShippingAddress(address2);
+
+ transaction.commit();
+
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ // Commit notifications from the same session always have full deltas
+ Notification[] notifications = adapter.getNotifications();
+ return notifications.length == 1;
+ }
+ }.assertNoTimeOut();
+
+ Notification[] notifications = adapter.getNotifications();
+ notifications[0].getOldValue();
+ }
+}

Back to the top