public abstract class

AbstractTransactionalJUnit38SpringContextTests

extends AbstractJUnit38SpringContextTests
java.lang.Object
   ↳ junit.framework.Assert
     ↳ junit.framework.TestCase
       ↳ org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests
         ↳ org.springframework.test.context.junit38.AbstractTransactionalJUnit38SpringContextTests

Summary

Fields
protected SimpleJdbcTemplate simpleJdbcTemplate The SimpleJdbcTemplate that this base class manages, available to subclasses.
[Expand]
Inherited Fields
From class org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests
Public Constructors
AbstractTransactionalJUnit38SpringContextTests()
Constructs a new AbstractTransactionalJUnit38SpringContextTests instance.
AbstractTransactionalJUnit38SpringContextTests(String name)
Constructs a new AbstractTransactionalJUnit38SpringContextTests instance with the supplied name.
Public Methods
void setDataSource(DataSource dataSource)
Set the DataSource, typically provided via Dependency Injection.
void setSqlScriptEncoding(String sqlScriptEncoding)
Specify the encoding for SQL scripts, if different from the platform encoding.
Protected Methods
int countRowsInTable(String tableName)
Count the rows in the given table.
int deleteFromTables(String... names)
Convenience method for deleting all rows from the specified tables.
void executeSqlScript(String sqlResourcePath, boolean continueOnError)
Execute the given SQL script.
[Expand]
Inherited Methods
From class org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests
From class junit.framework.TestCase
From class junit.framework.Assert
From class java.lang.Object
From interface junit.framework.Test
From interface org.springframework.context.ApplicationContextAware

Fields

protected SimpleJdbcTemplate simpleJdbcTemplate

The SimpleJdbcTemplate that this base class manages, available to subclasses.

Public Constructors

public AbstractTransactionalJUnit38SpringContextTests ()

Constructs a new AbstractTransactionalJUnit38SpringContextTests instance.

public AbstractTransactionalJUnit38SpringContextTests (String name)

Constructs a new AbstractTransactionalJUnit38SpringContextTests instance with the supplied name.

Parameters
name the name of the current test to execute

Public Methods

public void setDataSource (DataSource dataSource)

Set the DataSource, typically provided via Dependency Injection.

Parameters
dataSource The DataSource to inject

public void setSqlScriptEncoding (String sqlScriptEncoding)

Specify the encoding for SQL scripts, if different from the platform encoding.

Protected Methods

protected int countRowsInTable (String tableName)

Count the rows in the given table.

Parameters
tableName table name to count rows in
Returns
  • the number of rows in the table

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

protected void executeSqlScript (String sqlResourcePath, boolean continueOnError)

Execute the given SQL script. Use with caution outside of a transaction!

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.

Parameters
sqlResourcePath the Spring resource path for the SQL script
continueOnError whether or not to continue without throwing an exception in the event of an error
Throws
DataAccessException if there is an error executing a statement and continueOnError was false