Package org.springframework.test.context.support

# Class CommonCachesTestExecutionListener

java.lang.Object
org.springframework.test.context.support.AbstractTestExecutionListener
org.springframework.test.context.support.CommonCachesTestExecutionListener

All Implemented Interfaces:
  `org.springframework.core.Ordered`, `TestExecutionListener`

public class CommonCachesTestExecutionListener extends AbstractTestExecutionListener
`TestExecutionListener` which makes sure that common caches are cleared once they are no longer required.

Clears the resource caches of the `ApplicationContext` since they are only required during the bean initialization phase. Runs after `DirtiesContextTestExecutionListener` since dirtying the context will close it and remove it from the context cache, making it unnecessary to clear the associated resource caches.

Since:
  6.2
Author:
  Stephane Nicoll

## Field Summary

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

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

`HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE`

## Constructor Summary

Constructors
Constructor
Description
`CommonCachesTestExecutionListener()`

## Method Summary

Modifier and Type
Method
Description
`void`
`afterTestClass(TestContext testContext)`
The default implementation is empty.
`final int`
`getOrder()`
Returns 3005, which ensures that the `CommonCachesTestExecutionListener` is ordered after the `DirtiesContextTestExecutionListener` and before the `TransactionalTestExecutionListener`.

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

`afterTestExecution, afterTestMethod, beforeTestClass, beforeTestExecution, beforeTestMethod, prepareTestInstance`

### 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: 3005.

Since:
  6.2.3
See Also:
  - Constant Field Values

## Constructor Details

### CommonCachesTestExecutionListener

public CommonCachesTestExecutionListener()

## Method Details

### getOrder

public final int getOrder()
Returns 3005, which ensures that the `CommonCachesTestExecutionListener` is ordered after the `DirtiesContextTestExecutionListener` and before the `TransactionalTestExecutionListener`.

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

### afterTestClass

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

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