MockControl ut2Mock = MockControl.createControl(UserTransaction.class);
UserTransaction ut2 = (UserTransaction) ut2Mock.getMock();
MockControl tmMock = MockControl.createControl(TransactionManager.class);
TransactionManager tm = (TransactionManager) tmMock.getMock();
JtaTransactionManager jtam = new JtaTransactionManager();
jtam.setUserTransaction(ut);
jtam.setTransactionManager(tm);
jtam.setRollbackOnCommitFailure(true);
jtam.afterPropertiesSet();
SimpleNamingContextBuilder jndiEnv = SimpleNamingContextBuilder.emptyActivatedContextBuilder();
jndiEnv.bind(JtaTransactionManager.DEFAULT_USER_TRANSACTION_NAME, ut2);
JtaTransactionManager serializedJtatm =
(JtaTransactionManager) SerializationTestUtils.serializeAndDeserialize(jtam);
// should do client-side lookup
assertNotNull("Logger must survive serialization", serializedJtatm.logger);
assertTrue("UserTransaction looked up on client", serializedJtatm.getUserTransaction() == ut2);
assertNull("TransactionManager didn't survive", serializedJtatm.getTransactionManager());
assertEquals(true, serializedJtatm.isRollbackOnCommitFailure());
}