Class ApplicationEventsTestExecutionListener
java.lang.Object
org.springframework.test.context.support.AbstractTestExecutionListener
org.springframework.test.context.event.ApplicationEventsTestExecutionListener
- All Implemented Interfaces:
org.springframework.core.Ordered,TestExecutionListener
TestExecutionListener which provides support for ApplicationEvents.
This listener manages the registration of ApplicationEvents for the
current thread at various points within the test execution lifecycle and makes
the current instance of ApplicationEvents available to tests via an
@Autowired
field in the test class.
If the test class is not annotated or meta-annotated with
@RecordApplicationEvents, this listener
effectively does nothing.
- Since:
- 5.3.3
- Author:
- Sam Brannen
- See Also:
-
Field Summary
FieldsFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidafterTestMethod(TestContext testContext) The default implementation is empty.voidbeforeTestMethod(TestContext testContext) The default implementation is empty.final intgetOrder()Returns 1800, which ensures that theApplicationEventsTestExecutionListeneris ordered after theDirtiesContextBeforeModesTestExecutionListenerand before theBeanOverrideTestExecutionListenerand theDependencyInjectionTestExecutionListener.voidprepareTestInstance(TestContext testContext) The default implementation is empty.Methods inherited from class org.springframework.test.context.support.AbstractTestExecutionListener
afterTestClass, afterTestExecution, beforeTestClass, beforeTestExecution
-
Field Details
-
ORDER
public static final int ORDERTheordervalue for this listener: 1800.- Since:
- 6.2.3
- See Also:
-
-
Constructor Details
-
ApplicationEventsTestExecutionListener
public ApplicationEventsTestExecutionListener()
-
-
Method Details
-
getOrder
public final int getOrder()Returns 1800, which ensures that theApplicationEventsTestExecutionListeneris ordered after theDirtiesContextBeforeModesTestExecutionListenerand before theBeanOverrideTestExecutionListenerand theDependencyInjectionTestExecutionListener.- Specified by:
getOrderin interfaceorg.springframework.core.Ordered- Overrides:
getOrderin classAbstractTestExecutionListener
-
prepareTestInstance
Description copied from class:AbstractTestExecutionListenerThe default implementation is empty. Can be overridden by subclasses as necessary.- Specified by:
prepareTestInstancein interfaceTestExecutionListener- Overrides:
prepareTestInstancein classAbstractTestExecutionListener- Parameters:
testContext- the test context for the test; nevernull- Throws:
Exception- allows any exception to propagate
-
beforeTestMethod
Description copied from class:AbstractTestExecutionListenerThe default implementation is empty. Can be overridden by subclasses as necessary.- Specified by:
beforeTestMethodin interfaceTestExecutionListener- Overrides:
beforeTestMethodin classAbstractTestExecutionListener- Parameters:
testContext- the test context in which the test method will be executed; nevernull- Throws:
Exception- allows any exception to propagate- See Also:
-
afterTestMethod
Description copied from class:AbstractTestExecutionListenerThe default implementation is empty. Can be overridden by subclasses as necessary.- Specified by:
afterTestMethodin interfaceTestExecutionListener- Overrides:
afterTestMethodin classAbstractTestExecutionListener- Parameters:
testContext- the test context in which the test method was executed; nevernull- Throws:
Exception- allows any exception to propagate- See Also:
-