Class AbstractTransactionalTestNGSpringContextTests
java.lang.Object
Convenience method for counting the rows in the given table.
protected int
Convenience method for counting the rows in the given table, using the
provided
WHERE
clause.
protected int
Convenience method for deleting all rows from the specified tables.
protected int
Convenience method for deleting all rows from the given table, using the
provided
WHERE
clause.
protected void
Convenience method for dropping all the specified tables.
protected void
Execute the given SQL script.
Set the
DataSource
, typically provided via Dependency Injection.
Specify the encoding for SQL scripts, if different from the platform encoding.
Methods inherited from class org.springframework.test.context.testng.
AbstractTestNGSpringContextTests
run
,
setApplicationContext
,
springTestContextAfterTestClass
,
springTestContextAfterTestMethod
,
springTestContextBeforeTestClass
,
springTestContextBeforeTestMethod
,
springTestContextPrepareTestInstance
Methods inherited from class java.lang.
Object
clone
,
equals
,
finalize
,
getClass
,
hashCode
,
notify
,
notifyAll
,
toString
,
wait
,
wait
,
wait
jdbcTemplate
The
JdbcTemplate
that this base class manages, available to subclasses.
Since:
Set the
DataSource
, typically provided via Dependency Injection.
This method also instantiates the
jdbcTemplate
instance variable.
setSqlScriptEncoding
public
void
setSqlScriptEncoding
(
String
sqlScriptEncoding)
Specify the encoding for SQL scripts, if different from the platform encoding.
See Also:
executeSqlScript(java.lang.String, boolean)
countRowsInTable
protected
int
countRowsInTable
(
String
tableName)
Convenience method for counting the rows in the given table.
Parameters:
tableName
- table name to count rows in
Returns:
the number of rows in the table
See Also:
JdbcTestUtils.countRowsInTable(org.springframework.jdbc.core.JdbcTemplate, java.lang.String)
countRowsInTableWhere
protected
int
countRowsInTableWhere
(
String
tableName,
String
whereClause)
Parameters:
tableName
- the name of the table to count rows in
whereClause
- the
WHERE
clause to append to the query
Returns:
the number of rows in the table that match the provided
WHERE
clause
Since:
See Also:
JdbcTestUtils.countRowsInTableWhere(org.springframework.jdbc.core.JdbcTemplate, java.lang.String, java.lang.String)
deleteFromTables
protected
int
deleteFromTables
(
String
... names)
Convenience method for deleting all rows from the specified tables.
Use with caution outside of a transaction!
Parameters:
names
- the names of the tables from which to delete
Returns:
the total number of rows deleted from all specified tables
See Also:
JdbcTestUtils.deleteFromTables(org.springframework.jdbc.core.JdbcTemplate, java.lang.String...)
deleteFromTableWhere
protected
int
deleteFromTableWhere
(
String
tableName,
String
whereClause,
Object
... args)
Parameters:
tableName
- the name of the table to delete rows from
whereClause
- the
WHERE
clause to append to the query
args
- arguments to bind to the query (leaving it to the
PreparedStatement
to guess the corresponding SQL type); may also contain
SqlParameterValue
objects which indicate not only the argument value but also the SQL type
and optionally the scale.
Returns:
the number of rows deleted from the table
Since:
See Also:
JdbcTestUtils.deleteFromTableWhere(org.springframework.jdbc.core.JdbcTemplate, java.lang.String, java.lang.String, java.lang.Object...)
dropTables
protected
void
dropTables
(
String
... names)
Convenience method for dropping all the specified tables.
Use with caution outside of a transaction!
Parameters:
names
- the names of the tables to drop
Since:
See Also:
JdbcTestUtils.dropTables(org.springframework.jdbc.core.JdbcTemplate, java.lang.String...)
executeSqlScript
Execute the given SQL script.
Use with caution outside of a transaction!
The script will normally be loaded by classpath.
Do not use this method to execute DDL if you expect rollback.
Parameters:
sqlResourcePath
- the Spring resource path for the SQL script
continueOnError
- whether to continue without throwing an
exception in the event of an error
Throws:
DataAccessException
- if there is an error executing a statement
See Also:
ResourceDatabasePopulator
setSqlScriptEncoding(java.lang.String)