public abstract class

AbstractAnnotationAwareTransactionalTests

extends AbstractTransactionalDataSourceSpringContextTests
java.lang.Object
   ↳ junit.framework.Assert
     ↳ junit.framework.TestCase
       ↳ org.springframework.test.ConditionalTestCase
         ↳ org.springframework.test.AbstractSpringContextTests
           ↳ org.springframework.test.AbstractSingleSpringContextTests
             ↳ org.springframework.test.AbstractDependencyInjectionSpringContextTests
               ↳ org.springframework.test.AbstractTransactionalSpringContextTests
                 ↳ org.springframework.test.AbstractTransactionalDataSourceSpringContextTests
                   ↳ org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests
Known Direct Subclasses
Known Indirect Subclasses

This class is deprecated.
as of Spring 3.0, in favor of using the listener-based test context framework (AbstractJUnit38SpringContextTests)

Class Overview

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:

Summary

[Expand]
Inherited Constants
From class org.springframework.test.AbstractDependencyInjectionSpringContextTests
Fields
protected ProfileValueSource profileValueSource ProfileValueSource available to subclasses but primarily intended for use in isDisabledInThisEnvironment(Method).
protected SimpleJdbcTemplate simpleJdbcTemplate
[Expand]
Inherited Fields
From class org.springframework.test.AbstractTransactionalDataSourceSpringContextTests
From class org.springframework.test.AbstractTransactionalSpringContextTests
From class org.springframework.test.AbstractSingleSpringContextTests
From class org.springframework.test.ConditionalTestCase
Public Constructors
AbstractAnnotationAwareTransactionalTests()
Default constructor for AbstractAnnotationAwareTransactionalTests, which delegates to AbstractAnnotationAwareTransactionalTests(String).
AbstractAnnotationAwareTransactionalTests(String name)
Constructs a new AbstractAnnotationAwareTransactionalTests instance with the specified JUnit name and retrieves the configured (or default) ProfileValueSource.
Public Methods
void runBare()
Overridden to populate transaction definition from annotations.
void setDataSource(DataSource dataSource)
Setter: DataSource is provided by Dependency Injection.
Protected Methods
void findUniqueProfileValueSourceFromContext(ApplicationContext applicationContext)
This method is deprecated. Use @ProfileValueSourceConfiguration instead.
Method getTestMethod()
Get the current test method.
boolean isDisabledInThisEnvironment(Method testMethod)
Determine if the test for the supplied testMethod should run in the current environment.
boolean isRollback()
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.
[Expand]
Inherited Methods
From class org.springframework.test.AbstractTransactionalDataSourceSpringContextTests
From class org.springframework.test.AbstractTransactionalSpringContextTests
From class org.springframework.test.AbstractDependencyInjectionSpringContextTests
From class org.springframework.test.AbstractSingleSpringContextTests
From class org.springframework.test.AbstractSpringContextTests
From class org.springframework.test.ConditionalTestCase
From class junit.framework.TestCase
From class junit.framework.Assert
From class java.lang.Object
From interface junit.framework.Test

Fields

protected ProfileValueSource profileValueSource

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.

protected SimpleJdbcTemplate simpleJdbcTemplate

Public Constructors

public AbstractAnnotationAwareTransactionalTests ()

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

public AbstractAnnotationAwareTransactionalTests (String name)

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

Public Methods

public void runBare ()

Overridden to populate transaction definition from annotations.

Throws
Throwable

public void setDataSource (DataSource dataSource)

Setter: DataSource is provided by Dependency Injection.

Protected Methods

protected void findUniqueProfileValueSourceFromContext (ApplicationContext applicationContext)

This method is 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

protected Method getTestMethod ()

Get the current test method.

protected boolean isDisabledInThisEnvironment (Method testMethod)

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

protected boolean isRollback ()

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.

Returns
  • the rollback flag for the current test