org.springframework.test.annotation
Class AbstractAnnotationAwareTransactionalTests

java.lang.Object
  extended by 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
                              extended by org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests
Direct Known Subclasses:
AbstractJpaTests

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

@Deprecated
public abstract class AbstractAnnotationAwareTransactionalTests
extends AbstractTransactionalDataSourceSpringContextTests

Java 5 specific subclass of AbstractTransactionalDataSourceSpringContextTests, exposing a SimpleJdbcTemplate and obeying annotations for transaction control.

For example, test methods can be annotated with the regular Spring @Transactional annotation (e.g., to force execution in a read-only transaction) or with the @NotTransactional annotation to prevent any transaction being created at all. In addition, individual test methods can be annotated with @Rollback to override the default rollback settings.

The following list constitutes all annotations currently supported by AbstractAnnotationAwareTransactionalTests:

Since:
2.0
Author:
Rod Johnson, Sam Brannen, Juergen Hoeller

Nested Class Summary
private static interface AbstractAnnotationAwareTransactionalTests.TestExecutionCallback
          Deprecated.  
 
Field Summary
protected  ProfileValueSource profileValueSource
          Deprecated. ProfileValueSource available to subclasses but primarily intended for use in isDisabledInThisEnvironment(Method).
protected  SimpleJdbcTemplate simpleJdbcTemplate
          Deprecated.  
private  TransactionAttributeSource transactionAttributeSource
          Deprecated.  
 
Fields inherited from class org.springframework.test.AbstractTransactionalDataSourceSpringContextTests
jdbcTemplate
 
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
AbstractAnnotationAwareTransactionalTests()
          Deprecated. Default constructor for AbstractAnnotationAwareTransactionalTests, which delegates to AbstractAnnotationAwareTransactionalTests(String).
AbstractAnnotationAwareTransactionalTests(java.lang.String name)
          Deprecated. Constructs a new AbstractAnnotationAwareTransactionalTests instance with the specified JUnit name and retrieves the configured (or default) ProfileValueSource.
 
Method Summary
protected  void findUniqueProfileValueSourceFromContext(ApplicationContext applicationContext)
          Deprecated. Use @ProfileValueSourceConfiguration instead.
protected  java.lang.reflect.Method getTestMethod()
          Deprecated. Get the current test method.
protected  boolean isDisabledInThisEnvironment(java.lang.reflect.Method testMethod)
          Deprecated. Determine if the test for the supplied testMethod should run in the current environment.
protected  boolean isRollback()
          Deprecated. Determine whether or not to rollback transactions for the current test by taking into consideration the default rollback flag and a possible method-level override via the @Rollback annotation.
 void runBare()
          Deprecated. Overridden to populate transaction definition from annotations.
private  void runTest(AbstractAnnotationAwareTransactionalTests.TestExecutionCallback tec, java.lang.reflect.Method testMethod)
          Deprecated.  
private  void runTestTimed(AbstractAnnotationAwareTransactionalTests.TestExecutionCallback tec, java.lang.reflect.Method testMethod)
          Deprecated.  
 void setDataSource(javax.sql.DataSource dataSource)
          Deprecated. Setter: DataSource is provided by Dependency Injection.
 
Methods inherited from class org.springframework.test.AbstractTransactionalDataSourceSpringContextTests
countRowsInTable, deleteFromTables, executeSqlScript, getJdbcTemplate, setComplete, setSqlScriptEncoding
 
Methods inherited from class org.springframework.test.AbstractTransactionalSpringContextTests
endTransaction, isDefaultRollback, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

simpleJdbcTemplate

protected SimpleJdbcTemplate simpleJdbcTemplate
Deprecated. 

transactionAttributeSource

private final TransactionAttributeSource transactionAttributeSource
Deprecated. 

profileValueSource

protected ProfileValueSource profileValueSource
Deprecated. 
ProfileValueSource available to subclasses but primarily intended for use in isDisabledInThisEnvironment(Method).

Set to SystemProfileValueSource by default for backwards compatibility; however, the value may be changed in the AbstractAnnotationAwareTransactionalTests(String) constructor.

Constructor Detail

AbstractAnnotationAwareTransactionalTests

public AbstractAnnotationAwareTransactionalTests()
Deprecated. 
Default constructor for AbstractAnnotationAwareTransactionalTests, which delegates to AbstractAnnotationAwareTransactionalTests(String).


AbstractAnnotationAwareTransactionalTests

public AbstractAnnotationAwareTransactionalTests(java.lang.String name)
Deprecated. 
Constructs a new AbstractAnnotationAwareTransactionalTests instance with the specified JUnit name and retrieves the configured (or default) ProfileValueSource.

Parameters:
name - the name of the current test
See Also:
ProfileValueUtils.retrieveProfileValueSource(Class)
Method Detail

setDataSource

public void setDataSource(javax.sql.DataSource dataSource)
Deprecated. 
Description copied from class: AbstractTransactionalDataSourceSpringContextTests
Setter: DataSource is provided by Dependency Injection.

Overrides:
setDataSource in class AbstractTransactionalDataSourceSpringContextTests

findUniqueProfileValueSourceFromContext

@Deprecated
protected void findUniqueProfileValueSourceFromContext(ApplicationContext applicationContext)
Deprecated. Use @ProfileValueSourceConfiguration instead.

Search for a unique ProfileValueSource in the supplied ApplicationContext. If found, the profileValueSource for this test will be set to the unique ProfileValueSource.

Parameters:
applicationContext - the ApplicationContext in which to search for the ProfileValueSource; may not be null

runBare

public void runBare()
             throws java.lang.Throwable
Deprecated. 
Overridden to populate transaction definition from annotations.

Overrides:
runBare in class ConditionalTestCase
Throws:
java.lang.Throwable

isDisabledInThisEnvironment

protected boolean isDisabledInThisEnvironment(java.lang.reflect.Method testMethod)
Deprecated. 
Determine if the test for the supplied testMethod should run in the current environment.

The default implementation is based on @IfProfileValue semantics.

Parameters:
testMethod - the test method
Returns:
true if the test is disabled in the current environment
See Also:
ProfileValueUtils.isTestEnabledInThisEnvironment(java.lang.Class)

getTestMethod

protected java.lang.reflect.Method getTestMethod()
Deprecated. 
Get the current test method.


isRollback

protected boolean isRollback()
Deprecated. 
Determine whether or not to rollback transactions for the current test by taking into consideration the default rollback flag and a possible method-level override via the @Rollback annotation.

Overrides:
isRollback in class AbstractTransactionalSpringContextTests
Returns:
the rollback flag for the current test

runTestTimed

private void runTestTimed(AbstractAnnotationAwareTransactionalTests.TestExecutionCallback tec,
                          java.lang.reflect.Method testMethod)
                   throws java.lang.Throwable
Deprecated. 
Throws:
java.lang.Throwable

runTest

private void runTest(AbstractAnnotationAwareTransactionalTests.TestExecutionCallback tec,
                     java.lang.reflect.Method testMethod)
              throws java.lang.Throwable
Deprecated. 
Throws:
java.lang.Throwable