Package org.springframework.test.context.event

# 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`

public class ApplicationEventsTestExecutionListener extends AbstractTestExecutionListener
`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:
  - `ApplicationEvents`
  - `ApplicationEventsHolder`

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`ORDER`
The `order` value for this listener: 1800.

### Fields inherited from interface org.springframework.core.Ordered

`HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE`

## Constructor Summary

Constructors
Constructor
Description
`ApplicationEventsTestExecutionListener()`

## Method Summary

Modifier and Type
Method
Description
`void`
`afterTestMethod(TestContext testContext)`
The default implementation is empty.
`void`
`beforeTestMethod(TestContext testContext)`
The default implementation is empty.
`final int`
`getOrder()`
Returns 1800, which ensures that the `ApplicationEventsTestExecutionListener` is ordered after the `DirtiesContextBeforeModesTestExecutionListener` and before the `BeanOverrideTestExecutionListener` and the `DependencyInjectionTestExecutionListener`.
`void`
`prepareTestInstance(TestContext testContext)`
The default implementation is empty.

### Methods inherited from class org.springframework.test.context.support.AbstractTestExecutionListener

`afterTestClass, afterTestExecution, beforeTestClass, beforeTestExecution`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### ORDER

public static final int ORDER
The `order` value for this listener: 1800.

Since:
  6.2.3
See Also:
  - Constant Field Values

## Constructor Details

### ApplicationEventsTestExecutionListener

public ApplicationEventsTestExecutionListener()

## Method Details

### getOrder

public final int getOrder()
Returns 1800, which ensures that the `ApplicationEventsTestExecutionListener` is ordered after the `DirtiesContextBeforeModesTestExecutionListener` and before the `BeanOverrideTestExecutionListener` and the `DependencyInjectionTestExecutionListener`.

Specified by:
  `getOrder` in interface `org.springframework.core.Ordered`
Overrides:
  `getOrder` in class `AbstractTestExecutionListener`

### prepareTestInstance

public void prepareTestInstance(TestContext testContext) throws Exception
Description copied from class: `AbstractTestExecutionListener`
The default implementation is empty. Can be overridden by subclasses as necessary.

Specified by:
  `prepareTestInstance` in interface `TestExecutionListener`
Overrides:
  `prepareTestInstance` in class `AbstractTestExecutionListener`
Parameters:
  `testContext` - the test context for the test; never `null`
Throws:
  `Exception` - allows any exception to propagate

### beforeTestMethod

public void beforeTestMethod(TestContext testContext) throws Exception
Description copied from class: `AbstractTestExecutionListener`
The default implementation is empty. Can be overridden by subclasses as necessary.

Specified by:
  `beforeTestMethod` in interface `TestExecutionListener`
Overrides:
  `beforeTestMethod` in class `AbstractTestExecutionListener`
Parameters:
  `testContext` - the test context in which the test method will be executed; never `null`
Throws:
  `Exception` - allows any exception to propagate
See Also:
  - `TestExecutionListener.afterTestMethod(org.springframework.test.context.TestContext)`
  - `TestExecutionListener.beforeTestExecution(org.springframework.test.context.TestContext)`
  - `TestExecutionListener.afterTestExecution(org.springframework.test.context.TestContext)`

### afterTestMethod

public void afterTestMethod(TestContext testContext) throws Exception
Description copied from class: `AbstractTestExecutionListener`
The default implementation is empty. Can be overridden by subclasses as necessary.

Specified by:
  `afterTestMethod` in interface `TestExecutionListener`
Overrides:
  `afterTestMethod` in class `AbstractTestExecutionListener`
Parameters:
  `testContext` - the test context in which the test method was executed; never `null`
Throws:
  `Exception` - allows any exception to propagate
See Also:
  - `TestExecutionListener.beforeTestMethod(org.springframework.test.context.TestContext)`
  - `TestExecutionListener.beforeTestExecution(org.springframework.test.context.TestContext)`
  - `TestExecutionListener.afterTestExecution(org.springframework.test.context.TestContext)`