public abstract class AbstractDirtiesContextTestExecutionListener extends AbstractTestExecutionListener
TestExecutionListener implementations that
provide support for marking the ApplicationContext associated with
a test as dirty for both test classes and test methods annotated
with the @DirtiesContext annotation.
The core functionality for this class was extracted from
DirtiesContextTestExecutionListener in Spring Framework 4.2.
DirtiesContext| Constructor and Description |
|---|
AbstractDirtiesContextTestExecutionListener() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
beforeOrAfterTestClass(TestContext testContext,
DirtiesContext.ClassMode requiredClassMode)
Perform the actual work for
AbstractTestExecutionListener.beforeTestClass(org.springframework.test.context.TestContext) and AbstractTestExecutionListener.afterTestClass(org.springframework.test.context.TestContext)
by dirtying the context if appropriate (i.e., according to the required mode). |
protected void |
beforeOrAfterTestMethod(TestContext testContext,
DirtiesContext.MethodMode requiredMethodMode,
DirtiesContext.ClassMode requiredClassMode)
Perform the actual work for
AbstractTestExecutionListener.beforeTestMethod(org.springframework.test.context.TestContext) and AbstractTestExecutionListener.afterTestMethod(org.springframework.test.context.TestContext)
by dirtying the context if appropriate (i.e., according to the required modes). |
protected void |
dirtyContext(TestContext testContext,
DirtiesContext.HierarchyMode hierarchyMode)
Mark the application context of the supplied
test context as
dirty
and set
REINJECT_DEPENDENCIES_ATTRIBUTE in the test context to true. |
abstract int |
getOrder()
The default implementation returns
Ordered.LOWEST_PRECEDENCE,
thereby ensuring that custom listeners are ordered after default
listeners supplied by the framework. |
afterTestClass, afterTestMethod, beforeTestClass, beforeTestMethod, prepareTestInstancepublic AbstractDirtiesContextTestExecutionListener()
public abstract int getOrder()
AbstractTestExecutionListenerOrdered.LOWEST_PRECEDENCE,
thereby ensuring that custom listeners are ordered after default
listeners supplied by the framework. Can be overridden by subclasses
as necessary.getOrder in interface org.springframework.core.OrderedgetOrder in class AbstractTestExecutionListenerprotected void dirtyContext(TestContext testContext, DirtiesContext.HierarchyMode hierarchyMode)
REINJECT_DEPENDENCIES_ATTRIBUTE in the test context to true.testContext - the test context whose application context should
be marked as dirtyhierarchyMode - the context cache clearing mode to be applied if the
context is part of a hierarchy; may be nullprotected void beforeOrAfterTestMethod(TestContext testContext, DirtiesContext.MethodMode requiredMethodMode, DirtiesContext.ClassMode requiredClassMode) throws Exception
AbstractTestExecutionListener.beforeTestMethod(org.springframework.test.context.TestContext) and AbstractTestExecutionListener.afterTestMethod(org.springframework.test.context.TestContext)
by dirtying the context if appropriate (i.e., according to the required modes).testContext - the test context whose application context should
potentially be marked as dirty; never nullrequiredMethodMode - the method mode required for a context to
be marked dirty in the current phase; never nullrequiredClassMode - the class mode required for a context to
be marked dirty in the current phase; never nullException - allows any exception to propagatedirtyContext(org.springframework.test.context.TestContext, org.springframework.test.annotation.DirtiesContext.HierarchyMode)protected void beforeOrAfterTestClass(TestContext testContext, DirtiesContext.ClassMode requiredClassMode) throws Exception
AbstractTestExecutionListener.beforeTestClass(org.springframework.test.context.TestContext) and AbstractTestExecutionListener.afterTestClass(org.springframework.test.context.TestContext)
by dirtying the context if appropriate (i.e., according to the required mode).testContext - the test context whose application context should
potentially be marked as dirty; never nullrequiredClassMode - the class mode required for a context to
be marked dirty in the current phase; never nullException - allows any exception to propagatedirtyContext(org.springframework.test.context.TestContext, org.springframework.test.annotation.DirtiesContext.HierarchyMode)