use of com.arjuna.ats.arjuna.coordinator.CheckedAction in project narayana by jbosstm.
the class CheckedActionsUnitTest method test.
@Test
public void test() throws Exception {
CheckedAction ca = new CheckedAction();
CheckedActions.set(ca);
assertEquals(CheckedActions.get(), ca);
CheckedActions.remove();
assertEquals(CheckedActions.get(), null);
}
use of com.arjuna.ats.arjuna.coordinator.CheckedAction in project narayana by jbosstm.
the class ThreadUtilTest method testDisassociateFromDifferentThread.
@Test
public void testDisassociateFromDifferentThread() throws InterruptedException {
Thread thread = Thread.currentThread();
AtomicBoolean called = new AtomicBoolean(false);
CoordinatorEnvironmentBean coordinatorEnvironmentBean = arjPropertyManager.getCoordinatorEnvironmentBean();
coordinatorEnvironmentBean.setAllowCheckedActionFactoryOverride(true);
coordinatorEnvironmentBean.setCheckedActionFactory(new CheckedActionFactory() {
@Override
public CheckedAction getCheckedAction(Uid txId, String actionType) {
return new CheckedAction() {
public void check(boolean isCommit, Uid actUid, Hashtable list) {
called.set(true);
}
};
}
});
AtomicAction tx = new AtomicAction();
assertFalse(tx.removeChildThread(ThreadUtil.getThreadId(thread)));
tx.begin();
synchronized (tx) {
new Thread(new Runnable() {
@Override
public void run() {
assertTrue(tx.removeChildThread(ThreadUtil.getThreadId(thread)));
assertTrue(tx.end(true) == ActionStatus.COMMITTED);
synchronized (tx) {
tx.notify();
}
}
}).start();
tx.wait();
}
assertTrue(called.get() == false);
}
Aggregations