org.springframework.test
Class AbstractTransactionalDataSourceSpringContextTests

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.springframework.test.ConditionalTestCase
              extended by org.springframework.test.AbstractSpringContextTests
                  extended by org.springframework.test.AbstractSingleSpringContextTests
                      extended by org.springframework.test.AbstractDependencyInjectionSpringContextTests
                          extended by org.springframework.test.AbstractTransactionalSpringContextTests
                              extended by org.springframework.test.AbstractTransactionalDataSourceSpringContextTests
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
AbstractAnnotationAwareTransactionalTests

Deprecated. as of Spring 3.0, in favor of using the listener-based test context framework (AbstractTransactionalJUnit4SpringContextTests)

@Deprecated
public abstract class AbstractTransactionalDataSourceSpringContextTests
extends AbstractTransactionalSpringContextTests

Subclass of AbstractTransactionalSpringContextTests that adds some convenience functionality for JDBC access. Expects a DataSource bean to be defined in the Spring application context.

This class exposes a JdbcTemplate and provides an easy way to delete from the database in a new transaction.

Since:
1.1.1
Author:
Rod Johnson, Juergen Hoeller, Thomas Risberg
See Also:
setDataSource(javax.sql.DataSource), getJdbcTemplate()

Field Summary
protected  JdbcTemplate jdbcTemplate
          Deprecated.  
 
Fields inherited from class org.springframework.test.AbstractTransactionalSpringContextTests
transactionDefinition, transactionManager, transactionStatus
 
Fields inherited from class org.springframework.test.AbstractDependencyInjectionSpringContextTests
AUTOWIRE_BY_NAME, AUTOWIRE_BY_TYPE, AUTOWIRE_NO
 
Fields inherited from class org.springframework.test.AbstractSingleSpringContextTests
applicationContext
 
Fields inherited from class org.springframework.test.ConditionalTestCase
logger
 
Constructor Summary
AbstractTransactionalDataSourceSpringContextTests()
          Deprecated. Default constructor for AbstractTransactionalDataSourceSpringContextTests.
AbstractTransactionalDataSourceSpringContextTests(String name)
          Deprecated. Constructor for AbstractTransactionalDataSourceSpringContextTests with a JUnit name.
 
Method Summary
protected  int countRowsInTable(String tableName)
          Deprecated. Count the rows in the given table
protected  void deleteFromTables(String[] names)
          Deprecated. Convenient method to delete all rows from these tables.
protected  void executeSqlScript(String sqlResourcePath, boolean continueOnError)
          Deprecated. Execute the given SQL script.
 JdbcTemplate getJdbcTemplate()
          Deprecated. Return the JdbcTemplate that this base class manages.
protected  void setComplete()
          Deprecated. Overridden to prevent the transaction committing if a number of tables have been cleared, as a defensive measure against accidental permanent wiping of a database.
 void setDataSource(DataSource dataSource)
          Deprecated. Setter: DataSource is provided by 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.AbstractTransactionalSpringContextTests
endTransaction, isDefaultRollback, isRollback, onSetUp, onSetUpBeforeTransaction, onSetUpInTransaction, onTearDown, onTearDownAfterTransaction, onTearDownInTransaction, preventTransaction, setDefaultRollback, setTransactionDefinition, setTransactionManager, startNewTransaction
 
Methods inherited from class org.springframework.test.AbstractDependencyInjectionSpringContextTests
getAutowireMode, injectDependencies, isDependencyCheck, isPopulateProtectedVariables, prepareTestInstance, setAutowireMode, setDependencyCheck, setPopulateProtectedVariables
 
Methods inherited from class org.springframework.test.AbstractSingleSpringContextTests
contextKey, createApplicationContext, createBeanDefinitionReader, customizeBeanFactory, getApplicationContext, getConfigLocations, getConfigPath, getConfigPaths, getLoadCount, loadContext, loadContextLocations, prepareApplicationContext, setDirty, setUp, tearDown
 
Methods inherited from class org.springframework.test.AbstractSpringContextTests
addContext, contextKeyString, getContext, hasCachedContext, isContextKeyEmpty, setDirty
 
Methods inherited from class org.springframework.test.ConditionalTestCase
getDisabledTestCount, isDisabledInThisEnvironment, recordDisabled, runBare
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runTest, setName, 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

jdbcTemplate

protected JdbcTemplate jdbcTemplate
Deprecated. 
Constructor Detail

AbstractTransactionalDataSourceSpringContextTests

public AbstractTransactionalDataSourceSpringContextTests()
Deprecated. 
Default constructor for AbstractTransactionalDataSourceSpringContextTests.


AbstractTransactionalDataSourceSpringContextTests

public AbstractTransactionalDataSourceSpringContextTests(String name)
Deprecated. 
Constructor for AbstractTransactionalDataSourceSpringContextTests with a JUnit name.

Method Detail

setDataSource

public void setDataSource(DataSource dataSource)
Deprecated. 
Setter: DataSource is provided by Dependency Injection.


getJdbcTemplate

public final JdbcTemplate getJdbcTemplate()
Deprecated. 
Return the JdbcTemplate that this base class manages.


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)

deleteFromTables

protected void deleteFromTables(String[] names)
Deprecated. 
Convenient method to delete all rows from these tables. Calling this method will make avoidance of rollback by calling setComplete() impossible.

See Also:
setComplete()

setComplete

protected final void setComplete()
Deprecated. 
Overridden to prevent the transaction committing if a number of tables have been cleared, as a defensive measure against accidental permanent wiping of a database.

Overrides:
setComplete in class AbstractTransactionalSpringContextTests
See Also:
AbstractTransactionalSpringContextTests.setComplete()

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

executeSqlScript

protected void executeSqlScript(String sqlResourcePath,
                                boolean continueOnError)
                         throws DataAccessException
Deprecated. 
Execute the given SQL script. Will be rolled back by default, according to the fate of the current transaction.

Parameters:
sqlResourcePath - Spring resource path for the SQL script. Should normally be loaded by classpath.

Statements should be delimited with a semicolon. If statements are not delimited with a semicolon then there should be one statement per line. Statements are allowed to span lines only if they are delimited with a semicolon.

Do not use this method to execute DDL if you expect rollback.

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