org.springframework.test.context.junit4
Class AbstractJUnit4SpringContextTests

java.lang.Object
  extended by org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests
All Implemented Interfaces:
ApplicationContextAware
Direct Known Subclasses:
AbstractTransactionalJUnit4SpringContextTests

@TestExecutionListeners(value={DependencyInjectionTestExecutionListener.class,DirtiesContextTestExecutionListener.class})
public abstract class AbstractJUnit4SpringContextTests
extends Object
implements ApplicationContextAware

Abstract base test class which integrates the Spring TestContext Framework with explicit ApplicationContext testing support in a JUnit 4.5+ environment.

Concrete subclasses should typically declare a class-level @ContextConfiguration annotation to configure the application context resource locations. If your test does not need to load an application context, you may choose to omit the @ContextConfiguration declaration and to configure the appropriate TestExecutionListeners manually.

Note: this class serves only as a convenience for extension. If you do not wish for your test classes to be tied to a Spring-specific class hierarchy, you may configure your own custom test classes by using SpringJUnit4ClassRunner, @ContextConfiguration, @TestExecutionListeners, etc.

Since:
2.5
Author:
Sam Brannen
See Also:
ContextConfiguration, TestContext, TestContextManager, AbstractTransactionalJUnit4SpringContextTests, AbstractJUnit38SpringContextTests, AbstractTestNGSpringContextTests

Field Summary
protected  ApplicationContext applicationContext
          The ApplicationContext that was injected into this test instance via setApplicationContext(ApplicationContext).
protected  Log logger
          Logger available to subclasses.
 
Constructor Summary
AbstractJUnit4SpringContextTests()
           
 
Method Summary
 void setApplicationContext(ApplicationContext applicationContext)
          Set the ApplicationContext to be used by this test instance, provided via ApplicationContextAware semantics.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final Log logger
Logger available to subclasses.


applicationContext

protected ApplicationContext applicationContext
The ApplicationContext that was injected into this test instance via setApplicationContext(ApplicationContext).

Constructor Detail

AbstractJUnit4SpringContextTests

public AbstractJUnit4SpringContextTests()
Method Detail

setApplicationContext

public final void setApplicationContext(ApplicationContext applicationContext)
Set the ApplicationContext to be used by this test instance, provided via ApplicationContextAware semantics.

Specified by:
setApplicationContext in interface ApplicationContextAware
Parameters:
applicationContext - the ApplicationContext object to be used by this object
See Also:
BeanInitializationException