當前位置: 首頁>>代碼示例>>Java>>正文


Java TestTransaction.start方法代碼示例

本文整理匯總了Java中org.springframework.test.context.transaction.TestTransaction.start方法的典型用法代碼示例。如果您正苦於以下問題:Java TestTransaction.start方法的具體用法?Java TestTransaction.start怎麽用?Java TestTransaction.start使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.test.context.transaction.TestTransaction的用法示例。


在下文中一共展示了TestTransaction.start方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: commitTxAndStartNewTx

import org.springframework.test.context.transaction.TestTransaction; //導入方法依賴的package包/類
@Test
public void commitTxAndStartNewTx() {
	assertInTransaction(true);
	assertTrue(TestTransaction.isActive());
	assertUsers("Dilbert");
	deleteFromTables("user");
	assertUsers();

	// Commit
	TestTransaction.flagForCommit();
	assertFalse(TestTransaction.isFlaggedForRollback());
	TestTransaction.end();
	assertInTransaction(false);
	assertFalse(TestTransaction.isActive());
	assertUsers();

	executeSqlScript("classpath:/org/springframework/test/context/jdbc/data-add-dogbert.sql", false);
	assertUsers("Dogbert");

	TestTransaction.start();
	assertInTransaction(true);
	assertTrue(TestTransaction.isActive());
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:24,代碼來源:ProgrammaticTxMgmtTests.java

示例2: rollbackTxAndStartNewTx

import org.springframework.test.context.transaction.TestTransaction; //導入方法依賴的package包/類
@Test
public void rollbackTxAndStartNewTx() {
	assertInTransaction(true);
	assertTrue(TestTransaction.isActive());
	assertUsers("Dilbert");
	deleteFromTables("user");
	assertUsers();

	// Rollback (automatically)
	assertTrue(TestTransaction.isFlaggedForRollback());
	TestTransaction.end();
	assertFalse(TestTransaction.isActive());
	assertInTransaction(false);
	assertUsers("Dilbert");

	// Start new transaction with default rollback semantics
	TestTransaction.start();
	assertInTransaction(true);
	assertTrue(TestTransaction.isFlaggedForRollback());
	assertTrue(TestTransaction.isActive());

	executeSqlScript("classpath:/org/springframework/test/context/jdbc/data-add-dogbert.sql", false);
	assertUsers("Dilbert", "Dogbert");
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:25,代碼來源:ProgrammaticTxMgmtTests.java

示例3: rollbackTxAndStartNewTxWithDefaultCommitSemantics

import org.springframework.test.context.transaction.TestTransaction; //導入方法依賴的package包/類
@Test
@Commit
public void rollbackTxAndStartNewTxWithDefaultCommitSemantics() {
	assertInTransaction(true);
	assertTrue(TestTransaction.isActive());
	assertUsers("Dilbert");
	deleteFromTables("user");
	assertUsers();

	// Rollback
	TestTransaction.flagForRollback();
	assertTrue(TestTransaction.isFlaggedForRollback());
	TestTransaction.end();
	assertFalse(TestTransaction.isActive());
	assertInTransaction(false);
	assertUsers("Dilbert");

	// Start new transaction with default commit semantics
	TestTransaction.start();
	assertInTransaction(true);
	assertFalse(TestTransaction.isFlaggedForRollback());
	assertTrue(TestTransaction.isActive());

	executeSqlScript("classpath:/org/springframework/test/context/jdbc/data-add-dogbert.sql", false);
	assertUsers("Dilbert", "Dogbert");
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:27,代碼來源:ProgrammaticTxMgmtTests.java

示例4: testTransactional

import org.springframework.test.context.transaction.TestTransaction; //導入方法依賴的package包/類
@Test
public void testTransactional() throws Exception {
    User user = newUser().address("address").firstName("firstname").lastName("lastname").build();
    user = userRepository.save(user);

    TestTransaction.end();
    Assert.assertEquals(0 , userRepository.findAll().size());


    TestTransaction.start();
    TestTransaction.flagForCommit();
    user = newUser().address("address").firstName("firstname").lastName("lastname").build();
    user = userRepository.save(user);
    TestTransaction.end();

    Assert.assertEquals(user, userRepository.findAll().get(0));
}
 
開發者ID:victorbuckservices,項目名稱:workshop-spring-4.0-to-4.2,代碼行數:18,代碼來源:TransactionalTest.java

示例5: startTxWithNonExistentTransactionContext

import org.springframework.test.context.transaction.TestTransaction; //導入方法依賴的package包/類
@Test(expected = IllegalStateException.class)
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public void startTxWithNonExistentTransactionContext() {
	TestTransaction.start();
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:6,代碼來源:ProgrammaticTxMgmtTests.java

示例6: startTxWithExistingTransaction

import org.springframework.test.context.transaction.TestTransaction; //導入方法依賴的package包/類
@Test(expected = IllegalStateException.class)
public void startTxWithExistingTransaction() {
	TestTransaction.start();
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:5,代碼來源:ProgrammaticTxMgmtTests.java

示例7: startTxWithNonExistentTransactionContext

import org.springframework.test.context.transaction.TestTransaction; //導入方法依賴的package包/類
@Test(expectedExceptions = IllegalStateException.class)
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public void startTxWithNonExistentTransactionContext() {
	TestTransaction.start();
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:6,代碼來源:ProgrammaticTxMgmtTestNGTests.java

示例8: startTxWithExistingTransaction

import org.springframework.test.context.transaction.TestTransaction; //導入方法依賴的package包/類
@Test(expectedExceptions = IllegalStateException.class)
public void startTxWithExistingTransaction() {
	TestTransaction.start();
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:5,代碼來源:ProgrammaticTxMgmtTestNGTests.java


注:本文中的org.springframework.test.context.transaction.TestTransaction.start方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。