Class AbstractJUnit4SpringContextTests
java.lang.Object
org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests
- All Implemented Interfaces:
 Aware,ApplicationContextAware
- Direct Known Subclasses:
 AbstractTransactionalJUnit4SpringContextTests
@TestExecutionListeners({ServletTestExecutionListener.class,DirtiesContextBeforeModesTestExecutionListener.class,ApplicationEventsTestExecutionListener.class,DependencyInjectionTestExecutionListener.class,DirtiesContextTestExecutionListener.class,EventPublishingTestExecutionListener.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 environment.
 Concrete subclasses should typically declare a class-level
 @ContextConfiguration annotation to
 configure the application context resource locations or component classes. 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.
 
The following TestExecutionListeners are configured by default:
 
ServletTestExecutionListenerDirtiesContextBeforeModesTestExecutionListenerApplicationEventsTestExecutionListenerDependencyInjectionTestExecutionListenerDirtiesContextTestExecutionListenerEventPublishingTestExecutionListener
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
 
SpringRunner,@ContextConfiguration,@TestExecutionListeners, etc. - If you wish to extend this class and use a runner other than the
 
SpringRunner, you can useSpringClassRuleandSpringMethodRuleand specify your runner of choice via@RunWith(...). 
NOTE: This class requires JUnit 4.12 or higher.
- Since:
 - 2.5
 - Author:
 - Sam Brannen
 - See Also:
 - 
ContextConfigurationTestContextTestContextManagerTestExecutionListenersServletTestExecutionListenerDirtiesContextBeforeModesTestExecutionListenerApplicationEventsTestExecutionListenerDependencyInjectionTestExecutionListenerDirtiesContextTestExecutionListenerEventPublishingTestExecutionListenerAbstractTransactionalJUnit4SpringContextTestsAbstractTestNGSpringContextTests
 
- 
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ApplicationContextTheApplicationContextthat was injected into this test instance viasetApplicationContext(ApplicationContext).protected final LogLogger available to subclasses. - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionfinal voidsetApplicationContext(ApplicationContext applicationContext) Set theApplicationContextto be used by this test instance, provided viaApplicationContextAwaresemantics. 
- 
Field Details
- 
logger
Logger available to subclasses. - 
applicationContext
TheApplicationContextthat was injected into this test instance viasetApplicationContext(ApplicationContext). 
 - 
 - 
Constructor Details
- 
AbstractJUnit4SpringContextTests
public AbstractJUnit4SpringContextTests() 
 - 
 - 
Method Details
- 
setApplicationContext
Set theApplicationContextto be used by this test instance, provided viaApplicationContextAwaresemantics.- Specified by:
 setApplicationContextin interfaceApplicationContextAware- Parameters:
 applicationContext- the ApplicationContext that this test runs in- See Also:
 
 
 -