java.lang.Object | ||||
↳ | junit.framework.Assert | |||
↳ | junit.framework.TestCase | |||
↳ | org.springframework.test.ConditionalTestCase | |||
↳ | org.springframework.test.AbstractSpringContextTests |
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
)
Superclass for JUnit 3.8 test cases using Spring
ApplicationContexts
.
Maintains a static cache of contexts by key. This has significant performance benefit if initializing the context would take time. While initializing a Spring context itself is very quick, some beans in a context, such as a LocalSessionFactoryBean for working with Hibernate, may take some time to initialize. Hence it often makes sense to do that initializing once.
Any ApplicationContext created by this class will be asked to register a JVM shutdown hook for itself. Unless the context gets closed early, all context instances will be automatically closed on JVM shutdown. This allows for freeing external resources held by beans within the context, e.g. temporary files.
Normally you won't extend this class directly but rather one of its subclasses.
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.test.ConditionalTestCase
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Default constructor for AbstractSpringContextTests.
| |||||||||||
Constructor for AbstractSpringContextTests with a JUnit name.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Explicitly add an ApplicationContext instance under a given key.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Subclasses can override this to return a String representation of their
context key for use in caching and logging.
| |||||||||||
Obtain an ApplicationContext for the given key, potentially cached.
| |||||||||||
Return whether there is a cached context for the given key.
| |||||||||||
Determine if the supplied context
key is empty. | |||||||||||
Load a new ApplicationContext for the given key.
| |||||||||||
Mark the context with the given key as dirty.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
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
|
Default constructor for AbstractSpringContextTests.
Constructor for AbstractSpringContextTests with a JUnit name.
Explicitly add an ApplicationContext instance under a given key.
This is not meant to be used by subclasses. It is rather exposed for special test suite environments.
key | the context key |
---|---|
context | the ApplicationContext instance |
Subclasses can override this to return a String representation of their context key for use in caching and logging.
contextKey | the context key |
---|
Obtain an ApplicationContext for the given key, potentially cached.
key | the context key; may be null . |
---|
null
if the provided key
is empty
Exception |
---|
Return whether there is a cached context for the given key.
key | the context key |
---|
Determine if the supplied context key
is empty.
By default, null
values, empty strings, and zero-length
arrays are considered empty.
key | the context key to check |
---|
true
if the supplied context key is empty
Load a new ApplicationContext for the given key.
To be implemented by subclasses.
key | the context key |
---|
Exception |
---|
Mark the context with the given key as dirty. This will cause the cached context to be reloaded before the next test case is executed.
Call this method only if you change the state of a singleton bean, potentially affecting future tests.