use of org.apache.geode.cache.TransactionEvent in project geode by apache.
the class TXOrderDUnitTest method testFarSideOrder.
/**
* make sure listeners get invoked in correct order on far side of tx
*/
@Test
public void testFarSideOrder() throws CacheException {
initOtherId();
AttributesFactory af = new AttributesFactory();
af.setDataPolicy(DataPolicy.REPLICATE);
af.setScope(Scope.DISTRIBUTED_ACK);
CacheListener cl1 = new CacheListenerAdapter() {
public void afterCreate(EntryEvent e) {
assertEquals(getCurrentExpectedKey(), e.getKey());
}
};
af.addCacheListener(cl1);
Region r1 = createRootRegion("r1", af.create());
Region r2 = r1.createSubregion("r2", af.create());
r2.createSubregion("r3", af.create());
TransactionListener tl1 = new TransactionListenerAdapter() {
public void afterCommit(TransactionEvent e) {
assertEquals(6, e.getEvents().size());
ArrayList keys = new ArrayList();
Iterator it = e.getEvents().iterator();
while (it.hasNext()) {
EntryEvent ee = (EntryEvent) it.next();
keys.add(ee.getKey());
assertEquals(null, ee.getCallbackArgument());
assertEquals(true, ee.isCallbackArgumentAvailable());
}
assertEquals(TXOrderDUnitTest.this.expectedKeys, keys);
TXOrderDUnitTest.this.invokeCount = 1;
}
};
CacheTransactionManager ctm = getCache().getCacheTransactionManager();
ctm.addListener(tl1);
this.invokeCount = 0;
this.clCount = 0;
this.expectedKeys = Arrays.asList(new String[] { "b", "c", "a", "a2", "c2", "b2" });
doCommitOtherVm();
assertEquals(1, this.invokeCount);
assertEquals(6, this.clCount);
}
Aggregations