}
/** Tests running the action in a new transaction while shutting down. */
void testShuttingDownNewTxn(final Action action) throws Exception {
action.setUp();
DummyTransaction originalTxn = txn;
ShutdownAction shutdownAction = new ShutdownAction();
shutdownAction.assertBlocked();
final AtomicReference<Throwable> exceptionHolder =
new AtomicReference<Throwable>();
Thread t = new Thread() {
public void run() {
txn = createTransaction(UsePrepareAndCommit.ARBITRARY);
try {
action.run();
} catch (Throwable t) {
exceptionHolder.set(t);
}
txn.abort(new RuntimeException("abort"));
txn = null;
}
};
t.start();
t.join(1000);
Throwable exception = exceptionHolder.get();
assertTrue("Expected IllegalStateException: " + exception,
exception instanceof IllegalStateException);
originalTxn.abort(new RuntimeException("abort"));
assertTrue(shutdownAction.waitForDone());
store = null;
}