Map<String, Object> m = new HashMap<String, Object>();
m.put("db1", db1);
m.put("db2", db2);
m.put("latch1", new CountDownLatch(2));
m.put("flag1", new AtomicBoolean(false));
new ConcurrentTestRunner(new TestStep[][] { new TestStep[] { new TestStep() {
public void runStep(Map<String, Object> mp) throws Exception
{
CountDownLatch l1 = (CountDownLatch) mp.get("latch1");
try
{
TransactionalDatabase<?, ?> tdb1 = (TransactionalDatabase<?, ?>) mp.get("db1");
TransactionalDatabase<?, ?> tdb2 = (TransactionalDatabase<?, ?>) mp.get("db2");
// Start a transaction and count down the latch
Transaction txn = Transaction.startTransaction(false);
try
{
// Let the databases join the transaction
tdb1.joinTransaction(false);
tdb2.joinTransaction(false);
l1.countDown();
l1.await();
l1 = null;
// Sleep awhile to give the other thread plenty
// of time to set the flag
Thread.sleep(1000);
// Still not set
assertFalse(((AtomicBoolean) mp.get("flag1")).get());
}
finally
{
txn.rollback();
}
}
finally
{
if (l1 != null)
{
l1.countDown();
}
}
}
} }, new TestStep[] { new TestStep() {
public void runStep(Map<String, Object> mp) throws Exception
{
CountDownLatch l1 = (CountDownLatch) mp.get("latch1");
try
{