|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object junit.framework.Assert junit.framework.TestCase org.springframework.test.ConditionalTestCase org.springframework.test.AbstractSpringContextTests
AbstractJUnit4SpringContextTests
)
@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 |
---|
Fields inherited from class org.springframework.test.ConditionalTestCase |
---|
logger |
Constructor Summary | |
---|---|
AbstractSpringContextTests()
Deprecated. Default constructor for AbstractSpringContextTests. |
|
AbstractSpringContextTests(String name)
Deprecated. Constructor for AbstractSpringContextTests with a JUnit name. |
Method Summary | |
---|---|
void |
addContext(Object key,
ConfigurableApplicationContext context)
Deprecated. Explicitly add an ApplicationContext instance under a given key. |
protected String |
contextKeyString(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(Object key)
Deprecated. Obtain an ApplicationContext for the given key, potentially cached. |
protected boolean |
hasCachedContext(Object key)
Deprecated. Return whether there is a cached context for the given key. |
protected boolean |
isContextKeyEmpty(Object key)
Deprecated. Determine if the supplied context key is empty. |
protected abstract ConfigurableApplicationContext |
loadContext(Object key)
Deprecated. Load a new ApplicationContext for the given key. |
protected void |
setDirty(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 junit.framework.TestCase |
---|
countTestCases, createResult, getName, run, run, runTest, setName, setUp, tearDown, 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 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public AbstractSpringContextTests()
public AbstractSpringContextTests(String name)
Method Detail |
---|
public final void addContext(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(Object key)
key
- the context keyprotected boolean isContextKeyEmpty(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(Object key) throws Exception
key
- the context key; may be null
.
null
if the provided key
is empty
Exception
protected final void setDirty(Object contextKey)
Call this method only if you change the state of a singleton bean, potentially affecting future tests.
protected String contextKeyString(Object contextKey)
contextKey
- the context keyprotected abstract ConfigurableApplicationContext loadContext(Object key) throws Exception
To be implemented by subclasses.
key
- the context key
Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |