Java Code Examples for org.springframework.test.context.jdbc.SqlConfig

The following examples show how to use org.springframework.test.context.jdbc.SqlConfig. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Spring   Source File: UserServiceTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@SqlGroup({
        @Sql(
                value = "classpath:db/extra-data.sql",
                config = @SqlConfig(encoding = "utf-8", separator = ";", commentPrefix = "--")
        ),
        @Sql(
                scripts = "classpath:db/delete-test-data.sql",
                config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED),
                executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD
        )
})
public void testCount() {
    int count = userService.countUsers();
    assertEquals(8, count);
}
 
Example 2
Source Project: spring-analysis-note   Source File: SqlConfigInterfaceTests.java    License: MIT License 5 votes vote down vote up
@Test
@Sql(scripts = "/org/springframework/test/context/jdbc/schema.sql", //
		config = @SqlConfig(separator = ";"))
@Sql("/org/springframework/test/context/jdbc/data-add-users-with-custom-script-syntax.sql")
public void methodLevelScripts() {
	assertNumUsers(3);
}
 
Example 3
Source Project: java-technology-stack   Source File: SqlConfigInterfaceTests.java    License: MIT License 5 votes vote down vote up
@Test
@Sql(scripts = "/org/springframework/test/context/jdbc/schema.sql", //
		config = @SqlConfig(separator = ";"))
@Sql("/org/springframework/test/context/jdbc/data-add-users-with-custom-script-syntax.sql")
public void methodLevelScripts() {
	assertNumUsers(3);
}
 
Example 4
Source Project: Spring   Source File: UserServiceTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
@SqlGroup({
        @Sql(value = "classpath:db/extra-data.sql", config = @SqlConfig(encoding = "utf-8", separator = ";", commentPrefix = "--")),
        @Sql(
                scripts = "classpath:db/delete-test-data.sql",
                config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED),
                executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD
        )
})
public void testCount() {
    int count = userService.countUsers();
    assertEquals(8, count);
}
 
Example 5
Source Project: tutorials   Source File: SpringBootInitialLoadIntegrationTest.java    License: MIT License 4 votes vote down vote up
@Test
@Sql(scripts = {"/import_senior_employees.sql"}, config = @SqlConfig(encoding = "utf-8", transactionMode = TransactionMode.ISOLATED))
public void testLoadDataForTestCase() {
    assertEquals(5, employeeRepository.findAll()
        .size());
}