}
@Test
public void testRegisterListenerCommitBeforeThrows() throws Exception {
RuntimeException exception = new RuntimeException();
DummyTransactionListener listener = new DummyTransactionListener();
txn.registerListener(listener);
DummyTransactionListener failingListener =
new DummyTransactionListener(exception, null);
txn.registerListener(failingListener);
try {
handle.commit();
fail("Expected RuntimeException");
} catch (RuntimeException e) {
assertSame(exception, e);
}
/*
* Don't know which listener's beforeCompletion method was called
* first, so don't check if this one's was called.
*/
listener.assertCalledAfter(CalledAfter.ABORT);
failingListener.assertCalled(true, CalledAfter.ABORT);
}