org.springframework.test.context.junit38
Class AbstractTransactionalJUnit38SpringContextTests

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests
              extended by org.springframework.test.context.junit38.AbstractTransactionalJUnit38SpringContextTests
All Implemented Interfaces:
junit.framework.Test, Aware, ApplicationContextAware

Deprecated. as of Spring 3.1, in favor of using 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.

Since:
2.5
Author:
Sam Brannen, Juergen Hoeller
See Also:
AbstractJUnit38SpringContextTests, ContextConfiguration, TestExecutionListeners, TransactionalTestExecutionListener, TransactionConfiguration, Transactional, NotTransactional, Rollback, BeforeTransaction, AfterTransaction, SimpleJdbcTestUtils, AbstractTransactionalJUnit4SpringContextTests, AbstractTransactionalTestNGSpringContextTests

Field Summary
protected  SimpleJdbcTemplate simpleJdbcTemplate
          Deprecated. The SimpleJdbcTemplate that this base class manages, available to subclasses.
 
Fields inherited from class org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests
applicationContext, logger, profileValueSource
 
Constructor Summary
AbstractTransactionalJUnit38SpringContextTests()
          Deprecated. Constructs a new AbstractTransactionalJUnit38SpringContextTests instance.
AbstractTransactionalJUnit38SpringContextTests(String name)
          Deprecated. Constructs a new AbstractTransactionalJUnit38SpringContextTests instance with the supplied name.
 
Method Summary
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.
 
Methods inherited from class org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests
getDisabledTestCount, recordDisabled, runBare, setApplicationContext
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runTest, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
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, fail, fail, failNotEquals, failNotSame, failSame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

simpleJdbcTemplate

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

Constructor Detail

AbstractTransactionalJUnit38SpringContextTests

public AbstractTransactionalJUnit38SpringContextTests()
Deprecated. 
Constructs a new AbstractTransactionalJUnit38SpringContextTests instance.


AbstractTransactionalJUnit38SpringContextTests

public AbstractTransactionalJUnit38SpringContextTests(String name)
Deprecated. 
Constructs a new AbstractTransactionalJUnit38SpringContextTests instance with the supplied name.

Parameters:
name - the name of the current test to execute
Method Detail

setDataSource

@Autowired
public void setDataSource(DataSource dataSource)
Deprecated. 
Set the DataSource, typically provided via Dependency Injection.

Parameters:
dataSource - The DataSource to inject

setSqlScriptEncoding

public void setSqlScriptEncoding(String sqlScriptEncoding)
Deprecated. 
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)
Deprecated. 
Count the rows in the given table.

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

deleteFromTables

protected int deleteFromTables(String... names)
Deprecated. 
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

executeSqlScript

protected void executeSqlScript(String sqlResourcePath,
                                boolean continueOnError)
                         throws DataAccessException
Deprecated. 
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