|
Lines 28-34
Link Here
|
| 28 |
*/ |
28 |
*/ |
| 29 |
public class Bugzilla_306710_Test extends AbstractCDOTest |
29 |
public class Bugzilla_306710_Test extends AbstractCDOTest |
| 30 |
{ |
30 |
{ |
| 31 |
public void testBugzilla_306710() throws Exception |
31 |
public void testBugzilla_306710_remove() throws Exception |
| 32 |
{ |
32 |
{ |
| 33 |
final NotifyCounter counter = new NotifyCounter(); |
33 |
final NotifyCounter counter = new NotifyCounter(); |
| 34 |
|
34 |
|
|
Lines 91-96
Link Here
|
| 91 |
assertEquals(1, counter.getRemoves()); |
91 |
assertEquals(1, counter.getRemoves()); |
| 92 |
} |
92 |
} |
| 93 |
|
93 |
|
|
|
94 |
public void testBugzilla_306710_addRemove() throws Exception |
| 95 |
{ |
| 96 |
final NotifyCounter counter = new NotifyCounter(); |
| 97 |
|
| 98 |
// setup connection1. |
| 99 |
CDOSession session1 = openSession(); |
| 100 |
CDOTransaction transaction1 = session1.openTransaction(); |
| 101 |
CDOResource resource1 = transaction1.createResource("/test1"); |
| 102 |
|
| 103 |
// add initial model. |
| 104 |
Company company1 = getModel1Factory().createCompany(); |
| 105 |
resource1.getContents().add(company1); |
| 106 |
transaction1.commit(); |
| 107 |
|
| 108 |
Thread.sleep(100); |
| 109 |
|
| 110 |
// setup connection2. |
| 111 |
CDOSession session2 = openSession(); |
| 112 |
CDOTransaction transaction2 = session2.openTransaction(); |
| 113 |
transaction2.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL); |
| 114 |
CDOResource resource2 = transaction2.getOrCreateResource("/test1"); |
| 115 |
|
| 116 |
// add adapter to company2 to have sendDeltaNotification being called. |
| 117 |
Company company2 = (Company)resource2.getContents().get(0); |
| 118 |
company2.eAdapters().add(new AdapterImpl() |
| 119 |
{ |
| 120 |
@Override |
| 121 |
public void notifyChanged(Notification msg) |
| 122 |
{ |
| 123 |
if (msg.getEventType() == Notification.ADD) |
| 124 |
{ |
| 125 |
counter.incAdds(); |
| 126 |
} |
| 127 |
else if (msg.getEventType() == Notification.REMOVE) |
| 128 |
{ |
| 129 |
counter.incRemoves(); |
| 130 |
} |
| 131 |
} |
| 132 |
}); |
| 133 |
|
| 134 |
// add and remove an object from category list of company to have the CDONotificationBuilder call remove with an |
| 135 |
// index not known to the oldRevision. |
| 136 |
Category category1a = getModel1Factory().createCategory(); |
| 137 |
company1.getCategories().add(0, category1a); |
| 138 |
company1.getCategories().remove(0); |
| 139 |
|
| 140 |
// commit the changes. |
| 141 |
transaction1.commit(); |
| 142 |
|
| 143 |
// wait for the invalidation to arrive on transaction2. |
| 144 |
Thread.sleep(1000); |
| 145 |
|
| 146 |
// cleanup. |
| 147 |
session1.close(); |
| 148 |
session2.close(); |
| 149 |
|
| 150 |
// check if the notifications arrived (which is not the case because of the exception). |
| 151 |
assertEquals(1, counter.getAdds()); |
| 152 |
assertEquals(1, counter.getRemoves()); |
| 153 |
} |
| 154 |
|
| 94 |
/** |
155 |
/** |
| 95 |
* Helper class to count the notifications. |
156 |
* Helper class to count the notifications. |
| 96 |
*/ |
157 |
*/ |