@TestExecutionListeners([TransactionalTestExecutionListener, SqlScriptsTestExecutionListener]) @Transactional abstract class AbstractTransactionalJUnit4SpringContextTests : AbstractJUnit4SpringContextTests
Abstract Transactional extension of AbstractJUnit4SpringContextTests which adds convenience functionality for JDBC access. Expects a DataSource bean and a PlatformTransactionManager bean to be defined in the Spring ApplicationContext.
This class exposes a JdbcTemplate and provides an easy way to count the number of rows in a table (potentially with a WHERE clause), delete from tables, drop tables, and execute SQL scripts within a transaction.
Concrete subclasses must fulfill the same requirements outlined in AbstractJUnit4SpringContextTests.
The following org.springframework.test.context.TestExecutionListener are configured by default:
This class serves only as a convenience for extension.
NOTE: As of Spring Framework 4.3, this class requires JUnit 4.12 or higher.
Author
Sam Brannen
Author
Juergen Hoeller
Since
2.5
See Also
AbstractJUnit4SpringContextTestsorg.springframework.test.context.ContextConfigurationorg.springframework.test.context.TestExecutionListenersorg.springframework.test.context.transaction.TransactionalTestExecutionListenerorg.springframework.test.context.jdbc.SqlScriptsTestExecutionListenerorg.springframework.transaction.annotation.Transactionalorg.springframework.test.annotation.Commitorg.springframework.test.annotation.Rollbackorg.springframework.test.context.transaction.BeforeTransactionorg.springframework.test.context.transaction.AfterTransactionorg.springframework.test.jdbc.JdbcTestUtilsorg.springframework.test.context.testng.AbstractTransactionalTestNGSpringContextTests
AbstractTransactionalJUnit4SpringContextTests()
Abstract Transactional extension of AbstractJUnit4SpringContextTests which adds convenience functionality for JDBC access. Expects a DataSource bean and a PlatformTransactionManager bean to be defined in the Spring ApplicationContext. This class exposes a JdbcTemplate and provides an easy way to count the number of rows in a table (potentially with a WHERE clause), delete from tables, drop tables, and execute SQL scripts within a transaction. Concrete subclasses must fulfill the same requirements outlined in AbstractJUnit4SpringContextTests. The following org.springframework.test.context.TestExecutionListener are configured by default:
This class serves only as a convenience for extension.
NOTE: As of Spring Framework 4.3, this class requires JUnit 4.12 or higher. |
open fun setDataSource(dataSource: DataSource): Unit
Set the This method also instantiates the |
|
open fun setSqlScriptEncoding(sqlScriptEncoding: String): Unit
Specify the encoding for SQL scripts, if different from the platform encoding. |
fun setApplicationContext(applicationContext: ApplicationContext): Unit
Set the ApplicationContext to be used by this test instance, provided via ApplicationContextAware semantics. |