|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object TestCase org.springframework.test.ConditionalTestCase org.springframework.test.AbstractSpringContextTests
AbstractJUnit38SpringContextTests
)
@Deprecated public abstract class AbstractSpringContextTests
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.
AbstractSingleSpringContextTests
,
AbstractDependencyInjectionSpringContextTests
,
AbstractTransactionalSpringContextTests
,
AbstractTransactionalDataSourceSpringContextTests
Field Summary | |
---|---|
private static java.util.Map<java.lang.String,ConfigurableApplicationContext> |
contextKeyToContextMap
Deprecated. Map of context keys returned by subclasses of this class, to Spring contexts. |
Fields inherited from class org.springframework.test.ConditionalTestCase |
---|
logger |
Constructor Summary | |
---|---|
AbstractSpringContextTests()
Deprecated. Default constructor for AbstractSpringContextTests. |
|
AbstractSpringContextTests(java.lang.String name)
Deprecated. Constructor for AbstractSpringContextTests with a JUnit name. |
Method Summary | |
---|---|
void |
addContext(java.lang.Object key,
ConfigurableApplicationContext context)
Deprecated. Explicitly add an ApplicationContext instance under a given key. |
protected java.lang.String |
contextKeyString(java.lang.Object contextKey)
Deprecated. Subclasses can override this to return a String representation of their context key for use in caching and logging. |
protected ConfigurableApplicationContext |
getContext(java.lang.Object key)
Deprecated. Obtain an ApplicationContext for the given key, potentially cached. |
protected boolean |
hasCachedContext(java.lang.Object key)
Deprecated. Return whether there is a cached context for the given key. |
protected boolean |
isContextKeyEmpty(java.lang.Object key)
Deprecated. Determine if the supplied context key is empty. |
protected abstract ConfigurableApplicationContext |
loadContext(java.lang.Object key)
Deprecated. Load a new ApplicationContext for the given key. |
protected void |
setDirty(java.lang.Object contextKey)
Deprecated. Mark the context with the given key as dirty. |
Methods inherited from class org.springframework.test.ConditionalTestCase |
---|
getDisabledTestCount, isDisabledInThisEnvironment, recordDisabled, runBare |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static java.util.Map<java.lang.String,ConfigurableApplicationContext> contextKeyToContextMap
Constructor Detail |
---|
public AbstractSpringContextTests()
public AbstractSpringContextTests(java.lang.String name)
Method Detail |
---|
public final void addContext(java.lang.Object key, ConfigurableApplicationContext context)
This is not meant to be used by subclasses. It is rather exposed for special test suite environments.
key
- the context keycontext
- the ApplicationContext instanceprotected final boolean hasCachedContext(java.lang.Object key)
key
- the context keyprotected boolean isContextKeyEmpty(java.lang.Object key)
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 emptyprotected final ConfigurableApplicationContext getContext(java.lang.Object key) throws java.lang.Exception
key
- the context key; may be null
.
null
if the provided key
is empty
java.lang.Exception
protected final void setDirty(java.lang.Object contextKey)
Call this method only if you change the state of a singleton bean, potentially affecting future tests.
protected java.lang.String contextKeyString(java.lang.Object contextKey)
contextKey
- the context keyprotected abstract ConfigurableApplicationContext loadContext(java.lang.Object key) throws java.lang.Exception
To be implemented by subclasses.
key
- the context key
java.lang.Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |