ut2.commit();
ut2Control.setVoidCallable(1);
ut2Control.replay();
JtaTransactionManager ptm = new JtaTransactionManager();
ptm.setJndiTemplate(new ExpectedLookupTemplate("java:comp/UserTransaction", ut));
ptm.setCacheUserTransaction(false);
ptm.afterPropertiesSet();
assertEquals(ut, ptm.getUserTransaction());
TransactionTemplate tt = new TransactionTemplate(ptm);
assertEquals(JtaTransactionManager.SYNCHRONIZATION_ALWAYS, ptm.getTransactionSynchronization());
assertTrue(!TransactionSynchronizationManager.isSynchronizationActive());
assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly());
tt.execute(new TransactionCallbackWithoutResult() {
protected void doInTransactionWithoutResult(TransactionStatus status) {
// something transactional
assertTrue(TransactionSynchronizationManager.isSynchronizationActive());
assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly());
}
});
ptm.setJndiTemplate(new ExpectedLookupTemplate("java:comp/UserTransaction", ut2));
tt.execute(new TransactionCallbackWithoutResult() {
protected void doInTransactionWithoutResult(TransactionStatus status) {
// something transactional
assertTrue(TransactionSynchronizationManager.isSynchronizationActive());
assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly());