use of com.arjuna.ats.internal.jts.interposition.resources.arjuna.InterpositionCreator in project narayana by jbosstm.
the class ArjunaInterpositionUnitTest method test.
@Test
public void test() throws Exception {
InterpositionCreator creator = new InterpositionCreator();
OTSImpleManager.current().begin();
OTSImpleManager.current().begin();
PropagationContext ctx = OTSImpleManager.current().get_control().get_coordinator().get_txcontext();
assertTrue(creator.recreateLocal(ctx) != null);
assertTrue(creator.recreate(ctx) != null);
OTSImpleManager.current().rollback();
OTSImpleManager.current().rollback();
}
use of com.arjuna.ats.internal.jts.interposition.resources.arjuna.InterpositionCreator in project narayana by jbosstm.
the class JTSInterpositionSynchronizationTest method test.
@Test
public void test() throws Exception {
InterpositionCreator creator = new InterpositionCreator();
jtaPropertyManager.getJTAEnvironmentBean().setTransactionManagerClassName(com.arjuna.ats.internal.jta.transaction.jts.TransactionManagerImple.class.getName());
jtaPropertyManager.getJTAEnvironmentBean().setUserTransactionClassName(com.arjuna.ats.internal.jta.transaction.jts.UserTransactionImple.class.getName());
jtsPropertyManager.getJTSEnvironmentBean().setSupportInterposedSynchronization(true);
javax.transaction.TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
tm.setTransactionTimeout(1000000);
tm.begin();
TransactionImple transaction = (TransactionImple) tm.getTransaction();
transaction.enlistResource(new XAResource() {
@Override
public int prepare(Xid arg0) throws XAException {
prepareCalled = true;
beforeCompletionCalledFirst = beforeCompletionCalled;
return 0;
}
@Override
public void commit(Xid arg0, boolean arg1) throws XAException {
}
@Override
public void end(Xid arg0, int arg1) throws XAException {
}
@Override
public void forget(Xid arg0) throws XAException {
}
@Override
public int getTransactionTimeout() throws XAException {
return 0;
}
@Override
public boolean isSameRM(XAResource arg0) throws XAException {
return false;
}
@Override
public Xid[] recover(int arg0) throws XAException {
return null;
}
@Override
public void rollback(Xid arg0) throws XAException {
}
@Override
public boolean setTransactionTimeout(int arg0) throws XAException {
return false;
}
@Override
public void start(Xid arg0, int arg1) throws XAException {
}
});
ControlWrapper controlWrapper = transaction.getControlWrapper();
Uid get_uid = transaction.get_uid();
ControlImple cont = controlWrapper.getImple();
ArjunaTransactionImple tx = cont.getImplHandle();
CurrentImple current = OTSImpleManager.current();
Control get_control = current.get_control();
PropagationContext ctx = cont.get_coordinator().get_txcontext();
ControlImple recreateLocal = creator.recreateLocal(ctx);
assertTrue(recreateLocal != null);
Control recreate = creator.recreate(ctx);
assertTrue(recreate != null);
Object remove = ControlImple.allControls.remove(get_uid);
ServerControl sc = new ServerControl(get_uid, get_control, null, cont.get_coordinator(), cont.get_terminator());
ControlImple.allControls.put(get_uid, remove);
ServerTopLevelAction serverTopLevelAction = new ServerTopLevelAction(sc);
sc.getImplHandle().register_synchronization(new ManagedSynchronizationImple(new Synchronization() {
@Override
public void beforeCompletion() {
beforeCompletionCalled = true;
}
@Override
public void afterCompletion(int status) {
afterCompletionCalled = true;
}
}).getSynchronization());
transaction.commit();
assertTrue(prepareCalled == true);
assertTrue(beforeCompletionCalled);
assertTrue(afterCompletionCalled);
assertTrue(beforeCompletionCalledFirst == jtsPropertyManager.getJTSEnvironmentBean().isSupportInterposedSynchronization());
}
Aggregations