Spring Framework AbstractTransactionalJUnit4SpringContextTests - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework AbstractTransactionalJUnit4SpringContextTests class.

This code example shows how to use the following methods:
 * @since 4.1 
 */ 
@ContextConfiguration(classes = EmptyDatabaseConfig.class) 
@DirtiesContext 
@SqlConfig(commentPrefix = "`", blockCommentStartDelimiter = "#$", blockCommentEndDelimiter = "$#", separator = "@@") 
public class GlobalCustomScriptSyntaxSqlScriptsTests extends AbstractTransactionalJUnit4SpringContextTests {
 
	@Test
	@Sql(scripts = "schema.sql", config = @SqlConfig(separator = ";")) 
	@Sql("data-add-users-with-custom-script-syntax.sql") 
	public void methodLevelScripts() { 
		assertNumUsers(3); 
	} 
 
	protected void assertNumUsers(int expected) {
		assertEquals("Number of rows in the 'user' table.", expected, countRowsInTable("user"));
	} 
 
} 
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:assertEquals, assertNotNull, countRowsInTable
	@Autowired 
	private SessionFactory sessionFactory;
 
 
	protected int countRowsInPersonTable() { 
		return countRowsInTable("person"); 
	} 
 
	protected void assertPersonCount(int expectedCount) {
		assertEquals("Verifying number of rows in the 'person' table.", expectedCount, countRowsInPersonTable());
	} 
 
	@Before 
	public void setUp() { 
		assertInTransaction(true); 
		assertNotNull("PersonService should have been autowired.", personService);
		assertNotNull("SessionFactory should have been autowired.", sessionFactory);
	} 
 
	@Test

8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:assertEquals, countRowsInTable, fail
	@AfterTransaction 
	public void afterTransaction() { 
		if ("test01".equals(testName.getMethodName())) { 
			try { 
				assertNumUsers(99); 
				fail("Should throw a BadSqlGrammarException after test01, assuming 'drop-schema.sql' was executed"); 
			} 
			catch (BadSqlGrammarException e) { 
				/* expected */ 
			} 
		} 
	} 
 
	@Test 
	@SqlGroup({// 
	@Sql({ "schema.sql", "data.sql" }),// 
		@Sql(scripts = "drop-schema.sql", executionPhase = AFTER_TEST_METHOD) // 
	}) 
	// test## is required for @FixMethodOrder. 
	public void test01() { 

7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
 * @author Sam Brannen 
 * @since 4.1 
 */ 
@ContextConfiguration(classes = EmptyDatabaseConfig.class) 
@DirtiesContext 
public class CustomScriptSyntaxSqlScriptsTests extends AbstractTransactionalJUnit4SpringContextTests {
 
	@Test
	@Sql("schema.sql") 
	@Sql(scripts = "data-add-users-with-custom-script-syntax.sql",// 
	config = @SqlConfig(commentPrefix = "`", blockCommentStartDelimiter = "#$", blockCommentEndDelimiter = "$#", separator = "@@")) 
	public void methodLevelScripts() { 
		assertNumUsers(3); 
	} 
 
	protected void assertNumUsers(int expected) {
		assertEquals("Number of rows in the 'user' table.", expected, countRowsInTable("user"));
	} 
 
} 
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
 * @since 4.1 
 */ 
@ContextConfiguration(classes = EmptyDatabaseConfig.class) 
@Sql 
@DirtiesContext 
public class DefaultScriptDetectionSqlScriptsTests extends AbstractTransactionalJUnit4SpringContextTests {
 
	@Test
	public void classLevel() { 
		assertNumUsers(2); 
	} 
 
	@Test
	@Sql 
	public void methodLevel() { 
		assertNumUsers(3); 
	} 
 
	protected void assertNumUsers(int expected) {
		assertEquals("Number of rows in the 'user' table.", expected, countRowsInTable("user"));
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
 * @author Sam Brannen 
 * @since 4.1 
 */ 
@ContextConfiguration(classes = PopulatedSchemaDatabaseConfig.class) 
@DirtiesContext 
public class PopulatedSchemaTransactionalSqlScriptsTests extends AbstractTransactionalJUnit4SpringContextTests {
 
	@BeforeTransaction 
	@AfterTransaction 
	public void verifyPreAndPostTransactionDatabaseState() { 
		assertNumUsers(0); 
	} 
 
	@Test
	@SqlGroup(@Sql("data-add-dogbert.sql")) 
	public void methodLevelScripts() { 
		assertNumUsers(1); 
	} 
 
	protected void assertNumUsers(int expected) {
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:AbstractTransactionalJUnit4SpringContextTests.assertNotNull, assertEquals, assertNotNull
 
		// call the 'rewardNetwork' to test its rewardAccountFor(Dining) method 
		RewardConfirmation confirmation = rewardNetwork.rewardAccountFor(dining); 
 
		// assert the expected reward confirmation results 
		assertNotNull(confirmation); 
		assertNotNull(confirmation.getConfirmationNumber()); 
 
		// assert an account contribution was made 
		AccountContribution contribution = confirmation.getAccountContribution(); 
		assertNotNull(contribution); 
 
		// the account number should be '123456789' 
		assertEquals("123456789", contribution.getAccountNumber()); 
 
		// the total contribution amount should be 8.00 (8% of 100.00) 
		assertEquals(MonetaryAmount.valueOf("8.00"), contribution.getAmount()); 
 
		// the total contribution amount should have been split into 2 distributions 
		assertEquals(2, contribution.getDistributions().size()); 

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
 * @author Sam Brannen 
 * @since 4.1 
 */ 
@ContextConfiguration(classes = PopulatedSchemaDatabaseConfig.class) 
@DirtiesContext 
public class RequiresNewTransactionSqlScriptsTests extends AbstractTransactionalJUnit4SpringContextTests {
 
	@BeforeTransaction 
	public void beforeTransaction() { 
		assertNumUsers(0); 
	} 
 
	@Test
	@SqlGroup(@Sql(scripts = "data-add-dogbert.sql", config = @SqlConfig(transactionMode = TransactionMode.ISOLATED)))
	public void methodLevelScripts() { 
		assertNumUsers(1); 
	} 
 
	@AfterTransaction 
	public void afterTransaction() { 
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:assertEquals
	 * expected that the previous increment has been persisted in the database. 
	 */ 
	@Test 
	public void test3IncrementCount2() { 
		int count = dao.getCount(TEST_NAME); 
		assertEquals("Expected count=1 after test2IncrementCount1().", 1, count); 
 
		count = dao.incrementCount(TEST_NAME); 
		assertEquals("Expected count=2 now.", 2, count); 
	} 
 
	@After 
	public void synchronizePersistenceContext() { 
		em.flush(); 
	} 
 
} 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:AbstractTransactionalJUnit4SpringContextTests.assertNotNull, assertEquals, assertNotNull
 
		// Hessian client proxy 
		RewardConfirmation confirmation = rewardNetwork.rewardAccountFor(dining); 
 
		// assert the expected reward confirmation results 
		assertNotNull(confirmation); 
		assertNotNull(confirmation.getConfirmationNumber()); 
 
		// assert an account contribution was made 
		AccountContribution contribution = confirmation.getAccountContribution(); 
		assertNotNull(contribution); 
 
		// the contribution account number should be '123456789' 
		assertEquals("123456789", contribution.getAccountNumber()); 
 
		// the total contribution amount should be 8.00 (8% of 100.00) 
		assertEquals(MonetaryAmount.valueOf("8.00"), contribution.getAmount()); 
 
		// the total contribution amount should have been split into 2 distributions 
		assertEquals(2, contribution.getDistributions().size()); 

6
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Spring Framework AbstractTransactionalJUnit4SpringContextTests Methods: