Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2019-11-04 10:43:30 +0000
committerEike Stepper2019-11-04 10:43:30 +0000
commited1936308a9bda32a089da21fc2a9a5c4cdfffaa (patch)
tree0e3ee46d713bd8982e7a53f6467d3a193165415e /plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo
parentb6750513924f56b0207f5de6094aafa473ddee93 (diff)
downloadcdo-ed1936308a9bda32a089da21fc2a9a5c4cdfffaa.tar.gz
cdo-ed1936308a9bda32a089da21fc2a9a5c4cdfffaa.tar.xz
cdo-ed1936308a9bda32a089da21fc2a9a5c4cdfffaa.zip
[Releng] Enhance TestAdapter.java
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo')
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AdapterManagerTest.java27
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ChangeSubscriptionTest.java163
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InvalidationTest.java36
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/OldValueNotificationTest.java29
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceModificationTrackingTest.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SavePointTest.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TransactionTest.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_250036_Test.java16
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_251087_Test.java16
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_254489_Test.java15
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_260764_Test.java20
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_266857_Test.java15
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_283131_Test.java18
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_363287_Test.java17
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_367738_Test.java23
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_384496_Test.java11
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_443281_Test.java16
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_450880_Test.java18
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_486458_Test.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_503564_Test.java14
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_503573_Test.java18
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestAdapter.java32
22 files changed, 157 insertions, 368 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AdapterManagerTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AdapterManagerTest.java
index e7a99adc55..e5084dcf8e 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AdapterManagerTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AdapterManagerTest.java
@@ -21,8 +21,6 @@ import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
import org.eclipse.net4j.util.ref.ReferenceType;
-import org.eclipse.emf.common.notify.Notification;
-
import java.lang.ref.WeakReference;
/**
@@ -38,7 +36,6 @@ public class AdapterManagerTest extends AbstractCDOTest
// ************************************************************* //
Company companyA = getModel1Factory().createCompany();
- TestAdapter testAdapter = new TestAdapter();
final CDOTransaction transaction = session.openTransaction();
transaction.options().setCacheReferenceType(ReferenceType.WEAK);
@@ -48,15 +45,14 @@ public class AdapterManagerTest extends AbstractCDOTest
transaction.commit();
final CDOID id = CDOUtil.getCDOObject(companyA).cdoID();
- companyA.eAdapters().add(testAdapter);
+ TestAdapter testAdapter = new TestAdapter(companyA);
companyA = null;
companyA = (Company)CDOUtil.getEObject(transaction.getObject(id));
- assertEquals(0, testAdapter.getNotifications().length);
+ testAdapter.assertNotifications(0);
companyA.setCity("Ottawa");
- Notification[] notifications = testAdapter.getNotifications();
- assertEquals(1, notifications.length); // One EMF notification
+ testAdapter.assertNotifications(1);
}
public void testStrongReferencePolicy_ALL() throws Exception
@@ -76,8 +72,7 @@ public class AdapterManagerTest extends AbstractCDOTest
transaction.commit();
CDOID id = CDOUtil.getCDOObject(companyA).cdoID();
- TestAdapter testAdapter = new TestAdapter();
- companyA.eAdapters().add(testAdapter);
+ TestAdapter testAdapter = new TestAdapter(companyA);
companyA = null;
testAdapter.clearNotifications();
@@ -86,10 +81,10 @@ public class AdapterManagerTest extends AbstractCDOTest
assertEquals(true, transaction.isObjectRegistered(id));
companyA = (Company)CDOUtil.getEObject(transaction.getObject(id));
- assertEquals(0, testAdapter.getNotifications().length);
+ testAdapter.assertNotifications(0);
companyA.setCity("Ottawa");
- assertEquals(1, testAdapter.getNotifications().length);
+ testAdapter.assertNotifications(1);
}
public void testStrongReferencePolicy_ALL_AttachObject() throws Exception
@@ -100,8 +95,7 @@ public class AdapterManagerTest extends AbstractCDOTest
// ************************************************************* //
Company companyA = getModel1Factory().createCompany();
- TestAdapter testAdapter = new TestAdapter();
- companyA.eAdapters().add(testAdapter);
+ TestAdapter testAdapter = new TestAdapter(companyA);
CDOTransaction transaction = session.openTransaction();
transaction.options().setCacheReferenceType(ReferenceType.WEAK);
@@ -120,9 +114,9 @@ public class AdapterManagerTest extends AbstractCDOTest
companyA = (Company)CDOUtil.getEObject(transaction.getObject(id));
- assertEquals(0, testAdapter.getNotifications().length);
+ testAdapter.assertNotifications(0);
companyA.setCity("Ottawa");
- assertEquals(1, testAdapter.getNotifications().length);
+ testAdapter.assertNotifications(1);
}
public void testStrongReferencePolicy_ALL_DetachObject() throws Exception
@@ -135,8 +129,7 @@ public class AdapterManagerTest extends AbstractCDOTest
Company companyA = getModel1Factory().createCompany();
WeakReference<Company> weakCompanyA = new WeakReference<Company>(companyA);
- TestAdapter testAdapter = new TestAdapter();
- companyA.eAdapters().add(testAdapter);
+ TestAdapter testAdapter = new TestAdapter(companyA);
CDOTransaction transaction = session.openTransaction();
transaction.options().setCacheReferenceType(ReferenceType.WEAK);
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ChangeSubscriptionTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ChangeSubscriptionTest.java
index 3927778b08..515b0894fd 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ChangeSubscriptionTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ChangeSubscriptionTest.java
@@ -63,8 +63,7 @@ public class ChangeSubscriptionTest extends AbstractCDOTest
resourceA.getContents().add(companyA);
transaction.commit();
- final TestAdapter adapter = new TestAdapter();
- category1A.eAdapters().add(adapter);
+ final TestAdapter adapter = new TestAdapter(category1A);
// ************************************************************* //
@@ -72,40 +71,20 @@ public class ChangeSubscriptionTest extends AbstractCDOTest
final Category category1B = (Category)CDOUtil.getEObject(transaction2.getObject(CDOUtil.getCDOObject(category1A).cdoID(), true));
category1B.setName("CHANGED NAME");
- assertEquals(0, adapter.getNotifications().length);
+ adapter.assertNotifications(0);
transaction2.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();
+ adapter.assertNoTimeout(1);
// Removing policy
transaction.options().removeChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
adapter.clearNotifications();
category1B.setName("CHANGED NAME_VERSION 2");
- assertEquals(0, adapter.getNotifications().length);
+ adapter.assertNotifications(0);
transaction2.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();
+ adapter.assertNoTimeout(1);
}
public void testSameSession_WithoutPolicy() throws Exception
@@ -126,8 +105,7 @@ public class ChangeSubscriptionTest extends AbstractCDOTest
resourceA.getContents().add(companyA);
transaction.commit();
- final TestAdapter adapter = new TestAdapter();
- category1A.eAdapters().add(adapter);
+ final TestAdapter adapter = new TestAdapter(category1A);
// ************************************************************* //
@@ -135,40 +113,20 @@ public class ChangeSubscriptionTest extends AbstractCDOTest
final Category category1B = (Category)CDOUtil.getEObject(transaction2.getObject(CDOUtil.getCDOObject(category1A).cdoID(), true));
category1B.setName("CHANGED NAME");
- assertEquals(0, adapter.getNotifications().length);
+ adapter.assertNotifications(0);
transaction2.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();
+ adapter.assertNoTimeout(1);
// Adding policy
transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
adapter.clearNotifications();
category1B.setName("CHANGED NAME_VERSION 2");
- assertEquals(0, adapter.getNotifications().length);
+ adapter.assertNotifications(0);
transaction2.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();
+ adapter.assertNoTimeout(1);
}
public void testSeparateSession() throws Exception
@@ -187,8 +145,7 @@ public class ChangeSubscriptionTest extends AbstractCDOTest
resourceA.getContents().add(companyA);
transaction.commit();
- final TestAdapter adapter = new TestAdapter();
- category1A.eAdapters().add(adapter);
+ final TestAdapter adapter = new TestAdapter(category1A);
// ************************************************************* //
@@ -197,27 +154,17 @@ public class ChangeSubscriptionTest extends AbstractCDOTest
Category category1B = (Category)CDOUtil.getEObject(transaction2.getObject(CDOUtil.getCDOObject(category1A).cdoID(), true));
category1B.setName("CHANGED NAME");
- assertEquals(0, adapter.getNotifications().length);
+ adapter.assertNotifications(0);
transaction2.commit();
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- // Change subscription leads to delta nnotification
- Notification[] notifications = adapter.getNotifications();
- return notifications.length == 1;
- }
- }.assertNoTimeOut();
+ adapter.assertNoTimeout(1);
// Removing policy
transaction.options().removeChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
adapter.clearNotifications();
category1B.setName("CHANGED NAME_VERSION 2");
- assertEquals(0, adapter.getNotifications().length);
+ adapter.assertNotifications(0);
transaction2.commit();
@@ -248,8 +195,7 @@ public class ChangeSubscriptionTest extends AbstractCDOTest
resourceA.getContents().add(companyA);
transaction.commit();
- final TestAdapter adapter = new TestAdapter();
- category1A.eAdapters().add(adapter);
+ final TestAdapter adapter = new TestAdapter(category1A);
// ************************************************************* //
@@ -258,7 +204,7 @@ public class ChangeSubscriptionTest extends AbstractCDOTest
Category category1B = (Category)CDOUtil.getEObject(transaction2.getObject(CDOUtil.getCDOObject(category1A).cdoID(), true));
category1B.setName("CHANGED NAME");
- assertEquals(0, adapter.getNotifications().length);
+ adapter.assertNotifications(0);
transaction2.commit();
@@ -278,20 +224,10 @@ public class ChangeSubscriptionTest extends AbstractCDOTest
adapter.clearNotifications();
category1B.setName("CHANGED NAME_VERSION 2");
- assertEquals(0, adapter.getNotifications().length);
+ adapter.assertNotifications(0);
transaction2.commit();
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- // Change subscription leads to delta nnotification
- Notification[] notifications = adapter.getNotifications();
- return notifications.length == 1;
- }
- }.assertNoTimeOut();
+ adapter.assertNoTimeout(1);
}
public void testTemporaryObject() throws Exception
@@ -322,8 +258,7 @@ public class ChangeSubscriptionTest extends AbstractCDOTest
msg("Committing");
- final TestAdapter adapter = new TestAdapter();
- category1A.eAdapters().add(adapter);
+ final TestAdapter adapter = new TestAdapter(category1A);
transaction.commit();
@@ -339,7 +274,7 @@ public class ChangeSubscriptionTest extends AbstractCDOTest
msg("Changing name");
category1B.setName("CHANGED NAME");
- assertEquals(0, adapter.getNotifications().length);
+ adapter.assertNotifications(0);
msg("Committing");
transaction2.commit();
@@ -388,12 +323,9 @@ public class ChangeSubscriptionTest extends AbstractCDOTest
msg("Committing");
transaction.commit();
- final TestAdapter adapter = new TestAdapter();
-
customPolicy.getCdoIDs().add(CDOUtil.getCDOObject(category1A).cdoID());
- category1A.eAdapters().add(adapter);
- companyA.eAdapters().add(adapter);
+ final TestAdapter adapter = new TestAdapter(category1A, companyA);
// ************************************************************* //
@@ -408,20 +340,13 @@ public class ChangeSubscriptionTest extends AbstractCDOTest
category1B.setName("CHANGED NAME");
company1B.setName("TEST1");
- assertEquals(0, adapter.getNotifications().length);
+ adapter.assertNotifications(0);
msg("Committing");
transaction2.commit();
msg("Checking after commit");
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return adapter.getNotifications().length == 1;
- }
- }.assertNoTimeOut();
+ adapter.assertNoTimeout(1);
// Switching policy to the other
transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
@@ -432,20 +357,13 @@ public class ChangeSubscriptionTest extends AbstractCDOTest
category1B.setName("CHANGED NAME_VERSION 2");
company1B.setName("TEST2");
- assertEquals(0, adapter.getNotifications().length);
+ adapter.assertNotifications(0);
msg("Committing");
transaction2.commit();
msg("Checking after commit");
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return adapter.getNotifications().length == 2;
- }
- }.assertNoTimeOut();
+ adapter.assertNoTimeout(2);
}
public void testNotificationChain() throws Exception
@@ -479,9 +397,7 @@ public class ChangeSubscriptionTest extends AbstractCDOTest
msg("Committing");
transaction.commit();
- final TestAdapter adapter = new TestAdapter();
-
- companyA.eAdapters().add(adapter);
+ final TestAdapter adapter = new TestAdapter(companyA);
// ************************************************************* //
@@ -498,26 +414,19 @@ public class ChangeSubscriptionTest extends AbstractCDOTest
final Category category2B = getModel1Factory().createCategory();
company1B.getCategories().add(category2B);
- assertEquals(0, adapter.getNotifications().length);
+ adapter.assertNotifications(0);
msg("Committing");
transaction2.commit();
msg("Checking after commit");
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return adapter.getNotifications().length == 3;
- }
- }.assertNoTimeOut();
+ Notification[] notifications = adapter.assertNoTimeout(3);
int count = 0;
- for (Notification notification : adapter.getNotifications())
+ for (Notification notification : notifications)
{
CDODeltaNotification cdoNotification = (CDODeltaNotification)notification;
- if (adapter.getNotifications().length - 1 == count)
+ if (notifications.length - 1 == count)
{
assertEquals(false, cdoNotification.hasNext());
}
@@ -581,8 +490,7 @@ public class ChangeSubscriptionTest extends AbstractCDOTest
Object[] strongRefs = company2.getCategories().toArray(); // Keep those in memory
msg(strongRefs);
- final TestAdapter adapter = new TestAdapter();
- company2.eAdapters().add(adapter);
+ final TestAdapter adapter = new TestAdapter(company2);
company.getCategories().removeAll(categories);
transaction.commit();
@@ -642,8 +550,7 @@ public class ChangeSubscriptionTest extends AbstractCDOTest
Object[] strongRefs = company2.getCategories().toArray(); // Keep those in memory
msg(strongRefs);
- final TestAdapter adapter = new TestAdapter();
- company2.eAdapters().add(adapter);
+ final TestAdapter adapter = new TestAdapter(company2);
company.getCategories().removeAll(categories);
transaction.commit();
@@ -710,8 +617,7 @@ public class ChangeSubscriptionTest extends AbstractCDOTest
Object[] strongRefs = product2.getOrderDetails().toArray(); // Keep those in memory
msg(strongRefs);
- final TestAdapter adapter = new TestAdapter();
- product2.eAdapters().add(adapter);
+ final TestAdapter adapter = new TestAdapter(product2);
details.remove(0);
details.remove(0);
@@ -779,8 +685,7 @@ public class ChangeSubscriptionTest extends AbstractCDOTest
Object[] strongRefs = product2.getOrderDetails().toArray(); // Keep those in memory
msg(strongRefs);
- final TestAdapter adapter = new TestAdapter();
- product2.eAdapters().add(adapter);
+ final TestAdapter adapter = new TestAdapter(product2);
details.remove(0);
details.remove(0);
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InvalidationTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InvalidationTest.java
index 6689e62673..7e0bf96fd9 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InvalidationTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InvalidationTest.java
@@ -730,13 +730,12 @@ public class InvalidationTest extends AbstractCDOTest
EList<EObject> contents = resourceB.getContents();
final Category categoryB = (Category)contents.get(0);
- final TestAdapter testAdapter = new TestAdapter();
- categoryB.eAdapters().add(testAdapter);
+ final TestAdapter testAdapter = new TestAdapter(categoryB);
// ************************************************************* //
resourceA.getContents().remove(categoryA);
- assertEquals(0, testAdapter.getNotifications().length);
+ testAdapter.assertNotifications(0);
transaction.commit();
@@ -749,14 +748,7 @@ public class InvalidationTest extends AbstractCDOTest
}
}.assertNoTimeOut();
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return testAdapter.getNotifications().length == 1;
- }
- }.assertNoTimeOut();
+ testAdapter.assertNoTimeout(1);
}
public void testDetachAndPassiveUpdate() throws Exception
@@ -807,13 +799,12 @@ public class InvalidationTest extends AbstractCDOTest
EList<EObject> contents = resourceB.getContents();
final Category categoryB = (Category)contents.get(0);
- final TestAdapter testAdapter = new TestAdapter();
- categoryB.eAdapters().add(testAdapter);
+ final TestAdapter testAdapter = new TestAdapter(categoryB);
// ************************************************************* //
resourceA.getContents().remove(categoryA);
- assertEquals(0, testAdapter.getNotifications().length);
+ testAdapter.assertNotifications(0);
transaction.commit();
@@ -829,7 +820,7 @@ public class InvalidationTest extends AbstractCDOTest
getRepository().getRevisionManager().getCache().removeRevision(resourceA.cdoID(), resourceA.cdoRevision().getBranch().getVersion(2));
}
- assertEquals(0, testAdapter.getNotifications().length);
+ testAdapter.assertNotifications(0);
sessionB.refresh();
new PollingTimeOuter()
@@ -841,14 +832,7 @@ public class InvalidationTest extends AbstractCDOTest
}
}.assertNoTimeOut();
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return testAdapter.getNotifications().length == 1;
- }
- }.assertNoTimeOut();
+ testAdapter.assertNoTimeout(1);
}
public void testPassiveUpdateMode_CHANGES() throws Exception
@@ -873,13 +857,13 @@ public class InvalidationTest extends AbstractCDOTest
Category categoryB = (Category)resourceB.getContents().get(0);
- final TestAdapter testAdapter = new TestAdapter();
- categoryB.eAdapters().add(testAdapter);
+ final TestAdapter testAdapter = new TestAdapter(categoryB);
// ************************************************************* //
categoryA.setName("CHANGED");
- assertEquals(0, testAdapter.getNotifications().length);
+ testAdapter.assertNotifications(0);
+
transaction.commit();
new PollingTimeOuter()
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
index 90cbb7c821..ae90d463b9 100644
--- 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
@@ -25,7 +25,7 @@ import org.eclipse.emf.common.notify.Notification;
import java.util.Date;
/**
- *
+ * @author Eike Stepper
*/
public class OldValueNotificationTest extends AbstractCDOTest
{
@@ -48,19 +48,11 @@ public class OldValueNotificationTest extends AbstractCDOTest
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);
msg(CDOUtil.getCDOObject(roOrder).cdoState());
- roOrder.eAdapters().add(adapter);
+
+ final TestAdapter adapter = new TestAdapter(roOrder);
Address address2 = getModel1Factory().createAddress();
address2.setCity("Basel2");
@@ -71,18 +63,7 @@ public class OldValueNotificationTest extends AbstractCDOTest
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();
+ Notification notification = adapter.assertNoTimeout(1)[0];
+ notification.getOldValue();
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceModificationTrackingTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceModificationTrackingTest.java
index 4c5def830d..2bf9c138c7 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceModificationTrackingTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceModificationTrackingTest.java
@@ -226,8 +226,7 @@ public class ResourceModificationTrackingTest extends AbstractCDOTest
transaction.commit();
// Add a Listener
- TestAdapter testAdapter = new TestAdapter();
- resource.eAdapters().add(testAdapter);
+ TestAdapter testAdapter = new TestAdapter(resource);
company.setName("foobar");
assertEquals(Resource.RESOURCE__IS_MODIFIED, testAdapter.getNotifications()[0].getFeatureID(null));
transaction.commit();
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SavePointTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SavePointTest.java
index 02e3fe3287..c32c8cea75 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SavePointTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SavePointTest.java
@@ -343,11 +343,10 @@ public class SavePointTest extends AbstractCDOTest
company.setCity("CITY2");
- TestAdapter adapter = new TestAdapter();
- company.eAdapters().add(adapter);
+ TestAdapter adapter = new TestAdapter(company);
savePoint1.rollback();
assertEquals("CITY1", company.getCity());
- assertEquals(1, adapter.getNotifications().length);
+ adapter.assertNotifications(1);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TransactionTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TransactionTest.java
index 69f89b75e3..e01b9a4150 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TransactionTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TransactionTest.java
@@ -515,15 +515,11 @@ public class TransactionTest extends AbstractCDOTest
category.setName("name2");
- TestAdapter testAdapter = new TestAdapter();
- category.eAdapters().add(testAdapter);
+ TestAdapter testAdapter = new TestAdapter(category);
transaction.rollback();
- Notification[] notifications = testAdapter.getNotifications();
- assertEquals(1, notifications.length);
-
- Notification notification = notifications[0];
+ Notification notification = testAdapter.assertNotifications(1)[0];
assertEquals("name2", notification.getOldStringValue());
assertEquals("name1", notification.getNewStringValue());
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_250036_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_250036_Test.java
index 5f8e5371a7..58f96d7cb6 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_250036_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_250036_Test.java
@@ -20,7 +20,6 @@ import org.eclipse.emf.cdo.tests.util.TestAdapter;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.EMap;
import org.eclipse.emf.ecore.EObject;
@@ -73,8 +72,7 @@ public class Bugzilla_250036_Test extends AbstractCDOTest
assertEquals(CDOUtil.getCDOObject(expectedValue.get(i)).cdoID(), CDOUtil.getCDOObject(object).cdoID());
}
- final TestAdapter adapter = new TestAdapter();
- genRefMap.eAdapters().add(adapter);
+ final TestAdapter adapter = new TestAdapter(genRefMap);
transaction2.options().setInvalidationNotificationEnabled(true);
/********* transaction 1 ***************/
@@ -91,16 +89,8 @@ public class Bugzilla_250036_Test extends AbstractCDOTest
transaction.commit();
msg("Checking after commit");
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- // 10 delta notifications from local commit (same session) plus 1 invalidation notification
- Notification[] notifications = adapter.getNotifications();
- return notifications.length == 1 + counter[0];
- }
- }.assertNoTimeOut();
+ // 10 delta notifications from local commit (same session) plus 1 invalidation notification
+ adapter.assertNoTimeout(1 + counter[0]);
/********* transaction 2 ***************/
EMap<String, EObject> mapOfEObjectAfterCommit = genRefMap.getElements();
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_251087_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_251087_Test.java
index 83353c249b..be9bfb7312 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_251087_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_251087_Test.java
@@ -46,9 +46,8 @@ public class Bugzilla_251087_Test extends AbstractCDOTest
Company obj2 = getModel1Factory().createCompany();
- TestAdapter testAdapter = new TestAdapter();
+ new TestAdapter(obj2);
- obj2.eAdapters().add(testAdapter);
res.getContents().add(obj2);
transaction1.commit();
@@ -77,22 +76,15 @@ public class Bugzilla_251087_Test extends AbstractCDOTest
CDOID companyID = CDOUtil.getCDOObject(obj2).cdoID();
Company companyB = (Company)CDOUtil.getEObject(transB1.getObject(companyID));
transB1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
- final TestAdapter testAdapter = new TestAdapter();
- companyB.eAdapters().add(testAdapter);
+
+ final TestAdapter testAdapter = new TestAdapter(companyB);
assertEquals(true, ((InternalCDOTransaction)transB1).hasSubscription(companyID));
res.getContents().remove(obj2);
transaction1.commit();
msg("Checking after commit");
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return testAdapter.getNotifications().length == 1;
- }
- }.assertNoTimeOut();
+ testAdapter.assertNoTimeout(1);
assertEquals(false, ((InternalCDOTransaction)transB1).hasSubscription(companyID));
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_254489_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_254489_Test.java
index ef2fd900e8..28403a88db 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_254489_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_254489_Test.java
@@ -21,6 +21,7 @@ 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.common.notify.Notification;
import org.eclipse.emf.ecore.EObject;
/**
@@ -51,8 +52,7 @@ public class Bugzilla_254489_Test extends AbstractCDOTest
transaction2.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
CDOResource res2 = transaction2.getResource(getResourcePath("/res1"));
Company companyA2 = (Company)res2.getContents().get(0);
- final TestAdapter companyA2Adapter = new TestAdapter();
- companyA2.eAdapters().add(companyA2Adapter);
+ final TestAdapter companyA2Adapter = new TestAdapter(companyA2);
final Category category1A = getModel1Factory().createCategory();
category1A.setName("category1");
@@ -62,16 +62,9 @@ public class Bugzilla_254489_Test extends AbstractCDOTest
transaction1.commit();
msg("Checking after commit");
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return companyA2Adapter.getNotifications().length == 1;
- }
- }.assertNoTimeOut();
+ Notification[] notifications = companyA2Adapter.assertNoTimeout(1);
- Category category2 = (Category)CDOUtil.getEObject((EObject)companyA2Adapter.getNotifications()[0].getNewValue());
+ Category category2 = (Category)CDOUtil.getEObject((EObject)notifications[0].getNewValue());
assertNotSame(category2, category1A);
assertSame(transaction2, CDOUtil.getCDOObject(category2).cdoView());
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_260764_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_260764_Test.java
index 15a5ab1219..a1454b7872 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_260764_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_260764_Test.java
@@ -45,8 +45,7 @@ public class Bugzilla_260764_Test extends AbstractCDOTest
transaction.commit();
transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
- final TestAdapter adapter = new TestAdapter();
- orderAddress.eAdapters().add(adapter);
+ final TestAdapter adapter = new TestAdapter(orderAddress);
// ************************************************************* //
@@ -59,20 +58,11 @@ public class Bugzilla_260764_Test extends AbstractCDOTest
OrderDetail orderDetail = getModel1Factory().createOrderDetail();
orderAddress2.getOrderDetails().add(orderDetail);
- assertEquals(0, adapter.getNotifications().length);
+ adapter.assertNotifications(0);
transaction2.commit();
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return adapter.getNotifications().length == 1;
- }
- }.assertNoTimeOut();
-
- CDODeltaNotification cdoNotification = (CDODeltaNotification)adapter.getNotifications()[0];
- assertEquals(false, cdoNotification.hasNext());
- assertEquals(getModel1Package().getOrder_OrderDetails(), cdoNotification.getFeature());
+ CDODeltaNotification notification = (CDODeltaNotification)adapter.assertNoTimeout(1)[0];
+ assertEquals(false, notification.hasNext());
+ assertEquals(getModel1Package().getOrder_OrderDetails(), notification.getFeature());
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_266857_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_266857_Test.java
index 3c101b4d51..131e8cd0e2 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_266857_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_266857_Test.java
@@ -37,8 +37,7 @@ public class Bugzilla_266857_Test extends AbstractCDOTest
transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
CDOResource resource1 = transaction.createResource(getResourcePath("test1"));
- final TestAdapter testAdapterForResource = new TestAdapter();
- resource1.eAdapters().add(testAdapterForResource);
+ final TestAdapter testAdapterForResource = new TestAdapter(resource1);
transaction.commit();
CDOSession session2 = openSession();
@@ -46,17 +45,11 @@ public class Bugzilla_266857_Test extends AbstractCDOTest
CDOResource resource2 = transaction2.getResource(getResourcePath("test1"));
Company company2 = getModel1Factory().createCompany();
resource2.getContents().add(company2);
- assertEquals(0, testAdapterForResource.getNotifications().length);
+ testAdapterForResource.assertNotifications(0);
+
transaction2.commit();
msg("Checking after commit");
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return testAdapterForResource.getNotifications().length == 1;
- }
- }.assertNoTimeOut();
+ testAdapterForResource.assertNoTimeout(1);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_283131_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_283131_Test.java
index 66718efa75..d040033f55 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_283131_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_283131_Test.java
@@ -46,8 +46,7 @@ public class Bugzilla_283131_Test extends AbstractCDOTest
company.setName("company2");
// add adapter.
- final TestAdapter testAdapter = new TestAdapter();
- company.eAdapters().add(testAdapter);
+ final TestAdapter testAdapter = new TestAdapter(company);
// rollback.
transaction.rollback();
@@ -84,8 +83,7 @@ public class Bugzilla_283131_Test extends AbstractCDOTest
company.getCustomers().add(getModel1Factory().createCustomer());
// add adapter.
- final TestAdapter testAdapter = new TestAdapter();
- company.eAdapters().add(testAdapter);
+ final TestAdapter testAdapter = new TestAdapter(company);
// rollback.
transaction.rollback();
@@ -123,8 +121,7 @@ public class Bugzilla_283131_Test extends AbstractCDOTest
company.getCustomers().remove(0);
// add adapter.
- final TestAdapter testAdapter = new TestAdapter();
- company.eAdapters().add(testAdapter);
+ final TestAdapter testAdapter = new TestAdapter(company);
// rollback.
transaction.rollback();
@@ -164,8 +161,7 @@ public class Bugzilla_283131_Test extends AbstractCDOTest
company.setStreet("street2");
// add adapter.
- final TestAdapter testAdapter = new TestAdapter();
- company.eAdapters().add(testAdapter);
+ final TestAdapter testAdapter = new TestAdapter(company);
// rollback.
transaction.rollback();
@@ -222,8 +218,7 @@ public class Bugzilla_283131_Test extends AbstractCDOTest
commitAndSync(transaction2, transaction);
// add adapter.
- final TestAdapter testAdapter = new TestAdapter();
- company.eAdapters().add(testAdapter);
+ final TestAdapter testAdapter = new TestAdapter(company);
// rollback.
transaction.rollback();
@@ -272,8 +267,7 @@ public class Bugzilla_283131_Test extends AbstractCDOTest
commitAndSync(transaction2, transaction);
// add adapter.
- final TestAdapter testAdapter = new TestAdapter();
- company.eAdapters().add(testAdapter);
+ final TestAdapter testAdapter = new TestAdapter(company);
// rollback.
transaction.rollback();
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_363287_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_363287_Test.java
index bc25410f8e..1d84fab9a5 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_363287_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_363287_Test.java
@@ -20,6 +20,8 @@ import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.emf.common.notify.Notification;
+
/**
* @author Eike Stepper
*/
@@ -44,24 +46,15 @@ public class Bugzilla_363287_Test extends AbstractCDOTest
CDOResource resource2 = view.getResource(getResourcePath("/test1"));
- final TestAdapter testAdapter = new TestAdapter();
- resource2.eAdapters().add(testAdapter);
+ final TestAdapter testAdapter = new TestAdapter(resource2);
// ************************************************************* //
resource1.getContents().remove(0);
transaction.commit();
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return testAdapter.getNotifications().length == 1;
- }
- }.assertNoTimeOut();
-
- Object oldValue = testAdapter.getNotifications()[0].getOldValue();
+ Notification notification = testAdapter.assertNoTimeout(1)[0];
+ Object oldValue = notification.getOldValue();
assertNull(oldValue);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_367738_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_367738_Test.java
index cdfe3f61fa..4827d43cc6 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_367738_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_367738_Test.java
@@ -43,8 +43,7 @@ public class Bugzilla_367738_Test extends AbstractCDOTest
resource.getContents().add(company);
transaction.commit();
- TestAdapter adapter = new TestAdapter();
- company.eAdapters().add(adapter);
+ TestAdapter adapter = new TestAdapter(company);
company.setName(null);
Notification[] notifications = adapter.getNotifications();
@@ -68,8 +67,7 @@ public class Bugzilla_367738_Test extends AbstractCDOTest
resource.getContents().add(orderDetail);
transaction.commit();
- TestAdapter adapter = new TestAdapter();
- orderDetail.eAdapters().add(adapter);
+ TestAdapter adapter = new TestAdapter(orderDetail);
orderDetail.setProduct(null);
Notification[] notifications = adapter.getNotifications();
@@ -94,8 +92,7 @@ public class Bugzilla_367738_Test extends AbstractCDOTest
resource.getContents().add(purchaseOrder2);
transaction.commit();
- TestAdapter adapter = new TestAdapter();
- purchaseOrder1.eAdapters().add(adapter);
+ TestAdapter adapter = new TestAdapter(purchaseOrder1);
purchaseOrder2.setShippingAddress(customer);
assertNull(purchaseOrder1.getShippingAddress());
@@ -118,8 +115,7 @@ public class Bugzilla_367738_Test extends AbstractCDOTest
resource.getContents().add(purchaseOrder);
transaction.commit();
- TestAdapter adapter = new TestAdapter();
- purchaseOrder.eAdapters().add(adapter);
+ TestAdapter adapter = new TestAdapter(purchaseOrder);
purchaseOrder.setShippingAddress(null);
Notification[] notifications = adapter.getNotifications();
@@ -142,12 +138,11 @@ public class Bugzilla_367738_Test extends AbstractCDOTest
resource.getContents().add(purchaseOrder);
transaction.commit();
- TestAdapter adapter = new TestAdapter();
- purchaseOrder.eAdapters().add(adapter);
+ TestAdapter adapter = new TestAdapter(purchaseOrder);
resource.getContents().add(customer);
// Adding the customer to resource.contents does NOT remove it from the containment ref!
- assertEquals(0, adapter.getNotifications().length);
+ adapter.assertNotifications(0);
}
@Skips(IModelConfig.CAPABILITY_LEGACY)
@@ -170,8 +165,7 @@ public class Bugzilla_367738_Test extends AbstractCDOTest
transaction.commit();
assertEquals(customer, purchaseOrder.getShippingAddress());
- TestAdapter adapter = new TestAdapter();
- purchaseOrder.eAdapters().add(adapter);
+ TestAdapter adapter = new TestAdapter(purchaseOrder);
purchaseOrder.setShippingAddress(null);
Notification[] notifications = adapter.getNotifications();
@@ -196,8 +190,7 @@ public class Bugzilla_367738_Test extends AbstractCDOTest
transaction.commit();
assertEquals(customer, purchaseOrder.getShippingAddress());
- TestAdapter adapter = new TestAdapter();
- purchaseOrder.eAdapters().add(adapter);
+ TestAdapter adapter = new TestAdapter(purchaseOrder);
purchaseOrder.setShippingAddress(null);
Notification[] notifications = adapter.getNotifications();
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_384496_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_384496_Test.java
index 5d12337529..c682f507ff 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_384496_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_384496_Test.java
@@ -50,17 +50,16 @@ public class Bugzilla_384496_Test extends AbstractCDOTest
view.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
EObject watchedRoot = view.getResource(getResourcePath("res")).getContents().get(0);
- final TestAdapter adapter = new TestAdapter();
- watchedRoot.eAdapters().add(adapter);
+ final TestAdapter adapter = new TestAdapter(watchedRoot);
// Now modify from another session and checkout the adapter got the right position
// Root has initially 3 children. Create an additional one and replace the one at index 1
Category replacementChild = getModel1Factory().createCategory();
- assertEquals(0, adapter.getNotifications().length);
+ adapter.assertNotifications(0);
root.getCategories().set(1, replacementChild);
- assertEquals(0, adapter.getNotifications().length);
+ adapter.assertNotifications(0);
transaction.commit();
new PollingTimeOuter()
@@ -74,11 +73,11 @@ public class Bugzilla_384496_Test extends AbstractCDOTest
if (getRepositoryConfig().listOrdering() == ListOrdering.ORDERED)
{
- assertEquals(1, adapter.getNotifications().length);
+ adapter.assertNotifications(1);
}
else
{
- assertEquals(2, adapter.getNotifications().length);
+ adapter.assertNotifications(2);
}
assertEquals(1, adapter.getNotifications()[0].getPosition());
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_443281_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_443281_Test.java
index d0186f1479..8686818901 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_443281_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_443281_Test.java
@@ -52,22 +52,22 @@ public class Bugzilla_443281_Test extends AbstractCDOTest
CDOResource resource1 = tx.createResource(getResourcePath(resourceName));
// Test
- TestAdapter testAdapter = new TestAdapter();
- resource1.eAdapters().add(testAdapter);
+ TestAdapter testAdapter = new TestAdapter(resource1);
URI uri = resource1.getURI();
String newResourceName = "resource2.model1";
URI newURI = uri.trimSegments(1).appendSegment(newResourceName);
resource1.setURI(newURI);
- assertEquals(2, testAdapter.getNotifications().length);
- Notification notification1 = testAdapter.getNotifications()[0];
+ Notification[] notifications = testAdapter.assertNotifications(2);
+
+ Notification notification1 = notifications[0];
assertEquals(resource1, notification1.getNotifier());
assertEquals(EresourcePackage.Literals.CDO_RESOURCE_NODE__NAME, notification1.getFeature());
assertEquals(Notification.SET, notification1.getEventType());
assertEquals(resourceName, notification1.getOldValue());
assertEquals(newResourceName, notification1.getNewValue());
- Notification notification2 = testAdapter.getNotifications()[1];
+ Notification notification2 = notifications[1];
assertEquals(resource1, notification2.getNotifier());
assertEquals(Resource.RESOURCE__URI, notification2.getFeatureID(null));
assertEquals(Notification.SET, notification2.getEventType());
@@ -83,13 +83,11 @@ public class Bugzilla_443281_Test extends AbstractCDOTest
Resource resource1 = resourceSet.createResource(localResourceURI);
// Test
- TestAdapter testAdapter = new TestAdapter();
- resource1.eAdapters().add(testAdapter);
+ TestAdapter testAdapter = new TestAdapter(resource1);
URI uri = resource1.getURI();
URI newURI = uri.trimSegments(1).appendSegment("resource2.model1");
resource1.setURI(newURI);
- assertEquals(1, testAdapter.getNotifications().length);
- Notification notification = testAdapter.getNotifications()[0];
+ Notification notification = testAdapter.assertNotifications(1)[0];
assertEquals(resource1, notification.getNotifier());
assertEquals(Resource.RESOURCE__URI, notification.getFeatureID(null));
assertEquals(Notification.SET, notification.getEventType());
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_450880_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_450880_Test.java
index 61841c363f..7ed6124f32 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_450880_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_450880_Test.java
@@ -50,13 +50,10 @@ public class Bugzilla_450880_Test extends AbstractCDOTest
CDOTransaction transaction2 = session2.openTransaction();
CDOResource resource1Bis = transaction2.getResource(getResourcePath(RESOURCE_NAME));
Product1 product1 = (Product1)resource1Bis.getContents().get(0);
- TestAdapter testAdapter = new TestAdapter();
- product1.eAdapters().add(testAdapter);
+ TestAdapter testAdapter = new TestAdapter(product1);
commitAndSync(transaction1, transaction2);
- Notification[] notifications = testAdapter.getNotifications();
- assertNotNull(notifications);
- assertEquals(1, notifications.length);
- Notification notification = notifications[0];
+
+ Notification notification = testAdapter.assertNotifications(1)[0];
assertEquals(getModel1Package().getProduct1_OtherVATs().getDefaultValue(), notification.getOldValue());
assertEquals(VAT.VAT0, notification.getNewValue());
}
@@ -76,14 +73,11 @@ public class Bugzilla_450880_Test extends AbstractCDOTest
Product1 product1 = getModel1Factory().createProduct1();
resource.getContents().add(product1);
resource.save(Collections.emptyMap());
- TestAdapter testAdapter = new TestAdapter();
- product1.eAdapters().add(testAdapter);
+ TestAdapter testAdapter = new TestAdapter(product1);
VAT newValue = VAT.VAT0;
product1.setVat(newValue);
- Notification[] notifications = testAdapter.getNotifications();
- assertNotNull(notifications);
- assertEquals(1, notifications.length);
- Notification notification = notifications[0];
+
+ Notification notification = testAdapter.assertNotifications(1)[0];
assertEquals(getModel1Package().getProduct1_OtherVATs().getDefaultValue(), notification.getOldValue());
assertEquals(newValue, notification.getNewValue());
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_486458_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_486458_Test.java
index 64cfae4f85..3c37ca4cbc 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_486458_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_486458_Test.java
@@ -304,10 +304,7 @@ public class Bugzilla_486458_Test extends AbstractCDOTest
CDOUnit unit = transaction.getUnitManager().createUnit(root, true, null);
- TestAdapter adapter = new TestAdapter();
- root.eAdapters().add(adapter);
- child.eAdapters().add(adapter);
- sibling.eAdapters().add(adapter);
+ new TestAdapter(root, child, sibling);
assertEquals(false, ((InternalCDOView)transaction).hasSubscription(CDOUtil.getCDOObject(root).cdoID()));
assertEquals(false, ((InternalCDOView)transaction).hasSubscription(CDOUtil.getCDOObject(child).cdoID()));
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_503564_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_503564_Test.java
index 2edd416fcf..ecbe7ea746 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_503564_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_503564_Test.java
@@ -43,15 +43,12 @@ public class Bugzilla_503564_Test extends AbstractCDOTest
Supplier controlObject = controlView.getObject(object);
assertEquals("Old Name", controlObject.getName());
- TestAdapter adapter = new TestAdapter();
- controlObject.eAdapters().add(adapter);
+ TestAdapter adapter = new TestAdapter(controlObject);
object.setName("New Name");
commitAndSync(transaction, controlView);
- Notification[] notifications = adapter.getNotifications();
- assertEquals(1, notifications.length);
-
+ Notification[] notifications = adapter.assertNotifications(1);
Object oldValue = notifications[0].getOldValue();
assertEquals("Old Name", oldValue);
}
@@ -74,17 +71,14 @@ public class Bugzilla_503564_Test extends AbstractCDOTest
Supplier controlOldSupplier = controlView.getObject(oldSupplier);
assertEquals(controlOldSupplier, controlObject.getSupplier());
- TestAdapter adapter = new TestAdapter();
- controlObject.eAdapters().add(adapter);
+ TestAdapter adapter = new TestAdapter(controlObject);
Supplier newSupplier = getModel1Factory().createSupplier();
resource.getContents().add(newSupplier);
object.setSupplier(newSupplier);
commitAndSync(transaction, controlView);
- Notification[] notifications = adapter.getNotifications();
- assertEquals(1, notifications.length);
-
+ Notification[] notifications = adapter.assertNotifications(1);
Object oldValue = notifications[0].getOldValue();
assertEquals(controlOldSupplier, oldValue);
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_503573_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_503573_Test.java
index 9b16872943..8e1e9ab6e3 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_503573_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_503573_Test.java
@@ -45,16 +45,13 @@ public class Bugzilla_503573_Test extends AbstractCDOTest
WithCustomType controlObject = controlView.getObject(object);
assertEquals(new CustomType(1234), controlObject.getValue());
- TestAdapter adapter = new TestAdapter();
- controlObject.eAdapters().add(adapter);
+ TestAdapter adapter = new TestAdapter(controlObject);
object.setValue(new CustomType(5678));
commitAndSync(transaction, controlView);
- Notification[] notifications = adapter.getNotifications();
- assertEquals(1, notifications.length);
-
- Object oldValue = notifications[0].getOldValue();
+ Notification notification = adapter.assertNotifications(1)[0];
+ Object oldValue = notification.getOldValue();
assertEquals(new CustomType(1234), oldValue);
}
@@ -78,16 +75,13 @@ public class Bugzilla_503573_Test extends AbstractCDOTest
GenListOfIntArray controlObject = controlView.getObject(object);
assertEquals(3, controlObject.getElements().size());
- TestAdapter adapter = new TestAdapter();
- controlObject.eAdapters().add(adapter);
+ TestAdapter adapter = new TestAdapter(controlObject);
object.getElements().remove(1);
commitAndSync(transaction, controlView);
- Notification[] notifications = adapter.getNotifications();
- assertEquals(1, notifications.length);
-
- Object oldValue = notifications[0].getOldValue();
+ Notification notification = adapter.assertNotifications(1)[0];
+ Object oldValue = notification.getOldValue();
assertEquals("Old Name", oldValue);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestAdapter.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestAdapter.java
index b17d428d01..5d2a3de1c3 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestAdapter.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestAdapter.java
@@ -12,6 +12,8 @@ package org.eclipse.emf.cdo.tests.util;
import static org.junit.Assert.assertEquals;
+import org.eclipse.net4j.util.tests.AbstractOMTest.PollingTimeOuter;
+
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;
@@ -28,13 +30,12 @@ public class TestAdapter implements Adapter
private Notifier notifier;
- public TestAdapter()
- {
- }
-
- public TestAdapter(Notifier notifier)
+ public TestAdapter(Notifier... notifiers)
{
- notifier.eAdapters().add(this);
+ for (Notifier notifier : notifiers)
+ {
+ notifier.eAdapters().add(this);
+ }
}
public Notifier getTarget()
@@ -76,11 +77,28 @@ public class TestAdapter implements Adapter
}
}
- public void assertNotifications(int expectedSize)
+ public Notification[] assertNotifications(int expectedSize)
{
synchronized (notifications)
{
assertEquals(expectedSize, notifications.size());
+ return notifications.toArray(new Notification[notifications.size()]);
}
}
+
+ public Notification[] assertNoTimeout(final int expectedSize) throws InterruptedException
+ {
+ final Notification[][] result = { null };
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ result[0] = getNotifications();
+ return result[0].length == expectedSize;
+ }
+ }.assertNoTimeOut();
+
+ return result[0];
+ }
}

Back to the top