Class ApplicationEventsTestExecutionListener
java.lang.Object
org.springframework.test.context.support.AbstractTestExecutionListener
org.springframework.test.context.event.ApplicationEventsTestExecutionListener
- All Implemented Interfaces:
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
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
afterTestMethod
(TestContext testContext) The default implementation is empty.void
beforeTestMethod
(TestContext testContext) The default implementation is empty.final int
getOrder()
Returns1800
.void
prepareTestInstance
(TestContext testContext) The default implementation is empty.Methods inherited from class org.springframework.test.context.support.AbstractTestExecutionListener
afterTestClass, afterTestExecution, beforeTestClass, beforeTestExecution
-
Constructor Details
-
ApplicationEventsTestExecutionListener
public ApplicationEventsTestExecutionListener()
-
-
Method Details
-
getOrder
public final int getOrder()Returns1800
.- Specified by:
getOrder
in interfaceOrdered
- Overrides:
getOrder
in classAbstractTestExecutionListener
- Returns:
- the order value
- See Also:
-
prepareTestInstance
Description copied from class:AbstractTestExecutionListener
The default implementation is empty. Can be overridden by subclasses as necessary.- Specified by:
prepareTestInstance
in interfaceTestExecutionListener
- Overrides:
prepareTestInstance
in classAbstractTestExecutionListener
- Parameters:
testContext
- the test context for the test; nevernull
- Throws:
Exception
- allows any exception to propagate
-
beforeTestMethod
Description copied from class:AbstractTestExecutionListener
The default implementation is empty. Can be overridden by subclasses as necessary.- Specified by:
beforeTestMethod
in interfaceTestExecutionListener
- Overrides:
beforeTestMethod
in 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:AbstractTestExecutionListener
The default implementation is empty. Can be overridden by subclasses as necessary.- Specified by:
afterTestMethod
in interfaceTestExecutionListener
- Overrides:
afterTestMethod
in classAbstractTestExecutionListener
- Parameters:
testContext
- the test context in which the test method was executed; nevernull
- Throws:
Exception
- allows any exception to propagate- See Also:
-