本文整理汇总了Java中org.springframework.transaction.jta.JtaTransactionManager.setRollbackOnCommitFailure方法的典型用法代码示例。如果您正苦于以下问题:Java JtaTransactionManager.setRollbackOnCommitFailure方法的具体用法?Java JtaTransactionManager.setRollbackOnCommitFailure怎么用?Java JtaTransactionManager.setRollbackOnCommitFailure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.transaction.jta.JtaTransactionManager
的用法示例。
在下文中一共展示了JtaTransactionManager.setRollbackOnCommitFailure方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSerializable
import org.springframework.transaction.jta.JtaTransactionManager; //导入方法依赖的package包/类
public void testSerializable() throws Exception {
UserTransaction ut1 = mock(UserTransaction.class);
UserTransaction ut2 = mock(UserTransaction.class);
TransactionManager tm = mock(TransactionManager.class);
JtaTransactionManager jtam = new JtaTransactionManager();
jtam.setUserTransaction(ut1);
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());
}
示例2: serializable
import org.springframework.transaction.jta.JtaTransactionManager; //导入方法依赖的package包/类
@Test
public void serializable() throws Exception {
UserTransaction ut1 = mock(UserTransaction.class);
UserTransaction ut2 = mock(UserTransaction.class);
TransactionManager tm = mock(TransactionManager.class);
JtaTransactionManager jtam = new JtaTransactionManager();
jtam.setUserTransaction(ut1);
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());
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:28,代码来源:JtaTransactionManagerSerializationTests.java