AbstractTransactionalJUnit4SpringContextTests
@Deprecated @TestExecutionListeners(value=TransactionalTestExecutionListener.class) @Transactional public abstract class AbstractTransactionalJUnit38SpringContextTests extends AbstractJUnit38SpringContextTests
Abstract transactional
extension of
AbstractJUnit38SpringContextTests
which adds convenience
functionality for JDBC access. Expects a DataSource
bean
and a PlatformTransactionManager
bean to be defined in the Spring
application context
.
This class exposes a SimpleJdbcTemplate
and provides an easy way to
count the number of rows in a table
,
delete from the database
, and
execute SQL scripts
within a
transaction.
Concrete subclasses must fulfill the same requirements outlined in
AbstractJUnit38SpringContextTests
.
AbstractJUnit38SpringContextTests
,
ContextConfiguration
,
TestExecutionListeners
,
TransactionalTestExecutionListener
,
TransactionConfiguration
,
Transactional
,
NotTransactional
,
Rollback
,
BeforeTransaction
,
AfterTransaction
,
SimpleJdbcTestUtils
,
AbstractTransactionalJUnit4SpringContextTests
,
AbstractTransactionalTestNGSpringContextTests
Modifier and Type | Field and Description |
---|---|
protected SimpleJdbcTemplate |
simpleJdbcTemplate
Deprecated.
The SimpleJdbcTemplate that this base class manages, available to subclasses.
|
applicationContext, logger, profileValueSource
Constructor and Description |
---|
AbstractTransactionalJUnit38SpringContextTests()
Deprecated.
Constructs a new AbstractTransactionalJUnit38SpringContextTests instance.
|
AbstractTransactionalJUnit38SpringContextTests(String name)
Deprecated.
Constructs a new AbstractTransactionalJUnit38SpringContextTests instance
with the supplied
name . |
Modifier and Type | Method and Description |
---|---|
protected int |
countRowsInTable(String tableName)
Deprecated.
Count the rows in the given table.
|
protected int |
deleteFromTables(String... names)
Deprecated.
Convenience method for deleting all rows from the specified tables.
|
protected void |
executeSqlScript(String sqlResourcePath,
boolean continueOnError)
Deprecated.
Execute the given SQL script.
|
void |
setDataSource(DataSource dataSource)
Deprecated.
Set the DataSource, typically provided via Dependency Injection.
|
void |
setSqlScriptEncoding(String sqlScriptEncoding)
Deprecated.
Specify the encoding for SQL scripts, if different from the platform encoding.
|
getDisabledTestCount, recordDisabled, runBare, setApplicationContext
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runTest, setName, setUp, tearDown, toString
protected SimpleJdbcTemplate simpleJdbcTemplate
public AbstractTransactionalJUnit38SpringContextTests()
public AbstractTransactionalJUnit38SpringContextTests(String name)
name
.name
- the name of the current test to execute@Autowired public void setDataSource(DataSource dataSource)
dataSource
- The DataSource to injectpublic void setSqlScriptEncoding(String sqlScriptEncoding)
protected int countRowsInTable(String tableName)
tableName
- table name to count rows inprotected int deleteFromTables(String... names)
names
- the names of the tables from which to deleteprotected void executeSqlScript(String sqlResourcePath, boolean continueOnError) throws DataAccessException
The script will normally be loaded by classpath. There should be one statement per line. Any semicolons will be removed. Do not use this method to execute DDL if you expect rollback.
sqlResourcePath
- the Spring resource path for the SQL scriptcontinueOnError
- whether or not to continue without throwing an
exception in the event of an errorDataAccessException
- if there is an error executing a statement
and continueOnError was false