listener.assertCalled(false, CalledAfter.NO);
}
@Test
public void testRegisterListenerBeforeCompletion() throws Exception {
final DummyTransactionListener lateListener =
new DummyTransactionListener();
DummyTransactionListener[] listeners = {
new DummyTransactionListener(),
new DummyTransactionListener() {
public void beforeCompletion() {
super.beforeCompletion();
txn.registerListener(lateListener);
}
},
new DummyTransactionListener()
};
for (DummyTransactionListener listener : listeners) {
txn.registerListener(listener);
}
handle.commit();
for (DummyTransactionListener listener : listeners) {
listener.assertCalled(true, CalledAfter.COMMIT);
}
/*
* Since there is no guarantee of listener order, don't check if the
* late-added listener's beforeCompletion method was called.
*/
lateListener.assertCalledAfter(CalledAfter.COMMIT);
}