org.springframework.test
Class AbstractTransactionalDataSourceSpringContextTests

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.springframework.test.AbstractSpringContextTests
              extended by org.springframework.test.AbstractDependencyInjectionSpringContextTests
                  extended by org.springframework.test.AbstractTransactionalSpringContextTests
                      extended by org.springframework.test.AbstractTransactionalDataSourceSpringContextTests
All Implemented Interfaces:
Test

public abstract class AbstractTransactionalDataSourceSpringContextTests
extends AbstractTransactionalSpringContextTests

Subclass of AbstractTransactionalSpringContextTests that adds some convenience functionality. Expects a DataSource 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

Field Summary
protected  JdbcTemplate jdbcTemplate
           
 
Fields inherited from class org.springframework.test.AbstractTransactionalSpringContextTests
transactionManager, transactionStatus
 
Fields inherited from class org.springframework.test.AbstractDependencyInjectionSpringContextTests
applicationContext, AUTOWIRE_BY_NAME, AUTOWIRE_BY_TYPE, AUTOWIRE_NO, managedVariableNames
 
Fields inherited from class org.springframework.test.AbstractSpringContextTests
logger
 
Constructor Summary
AbstractTransactionalDataSourceSpringContextTests()
          Default constructor for AbstractTransactionalDataSourceSpringContextTests.
AbstractTransactionalDataSourceSpringContextTests(String name)
          Constructor for AbstractTransactionalDataSourceSpringContextTests with a JUnit name.
 
Method Summary
protected  void deleteFromTables(String[] names)
          Convenient method to delete all rows from these tables.
protected  void setComplete()
          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)
          Setter: DataSource is provided by Dependency Injection.
 
Methods inherited from class org.springframework.test.AbstractTransactionalSpringContextTests
endTransaction, onSetUp, onSetUpBeforeTransaction, onSetUpInTransaction, onTearDown, onTearDownAfterTransaction, onTearDownInTransaction, setDefaultRollback, setTransactionManager, startNewTransaction
 
Methods inherited from class org.springframework.test.AbstractDependencyInjectionSpringContextTests
contextKey, getAutowireMode, getConfigLocations, getLoadCount, initManagedVariableNames, isDependencyCheck, isPopulateProtectedVariables, loadContextLocations, populateProtectedVariables, setAutowireMode, setDependencyCheck, setDirty, setPopulateProtectedVariables, setUp, tearDown
 
Methods inherited from class org.springframework.test.AbstractSpringContextTests
contextKeyString, getContext, hasCachedContext, loadContext, setDirty
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

jdbcTemplate

protected JdbcTemplate jdbcTemplate
Constructor Detail

AbstractTransactionalDataSourceSpringContextTests

public AbstractTransactionalDataSourceSpringContextTests()
Default constructor for AbstractTransactionalDataSourceSpringContextTests.


AbstractTransactionalDataSourceSpringContextTests

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

Method Detail

setDataSource

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

Parameters:
dataSource -

deleteFromTables

protected void deleteFromTables(String[] names)
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()
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()


Copyright (c) 2002-2006 The Spring Framework Project.