org.springframework.test.annotation
Class AbstractAnnotationAwareTransactionalTests
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
- All Implemented Interfaces:
- junit.framework.Test
- Direct Known Subclasses:
- AbstractJpaTests
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
| 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.AbstractSingleSpringContextTests |
contextKey, createApplicationContext, createBeanDefinitionReader, customizeBeanFactory, getApplicationContext, getConfigLocations, getConfigPath, getConfigPaths, getLoadCount, loadContext, loadContextLocations, prepareApplicationContext, setDirty, setUp, tearDown |
| 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, format |
simpleJdbcTemplate
protected SimpleJdbcTemplate simpleJdbcTemplate
profileValueSource
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.
AbstractAnnotationAwareTransactionalTests
public AbstractAnnotationAwareTransactionalTests()
- Default constructor for AbstractAnnotationAwareTransactionalTests, which
delegates to
AbstractAnnotationAwareTransactionalTests(String).
AbstractAnnotationAwareTransactionalTests
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- See Also:
ProfileValueUtils.retrieveProfileValueSource(Class)
setDataSource
public void setDataSource(DataSource dataSource)
- 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 Throwable
- Overridden to populate transaction definition from annotations.
- Overrides:
runBare in class ConditionalTestCase
- Throws:
Throwable
isDisabledInThisEnvironment
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- See Also:
ProfileValueUtils.isTestEnabledInThisEnvironment(org.springframework.test.annotation.ProfileValueSource, java.lang.reflect.Method, java.lang.Class>)
getTestMethod
protected Method getTestMethod()
- Get the current test method.
isRollback
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.
- Overrides:
isRollback in class AbstractTransactionalSpringContextTests
- Returns:
- the rollback flag for the current test