Class BeanOverridetestExecutionListener
java.lang.Object
org.springframework.test.context.support.AbstracttestExecutionListener
org.springframework.test.context.bean.override.BeanOverridetestExecutionListener
- All Implemented Interfaces:
Ordered, testExecutionListener
testExecutionListener that enables @BeanOverride
support in tests, by injecting overridden beans in appropriate fields of the
test instance.- Since:
- 6.2
- Author:
- Simon Baslé, Sam Brannen, Phillip Webb, Andy Wilkinson, Moritz Halbritter
-
Field Summary
FieldsFields inherited from interface Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbeforetestMethod(testContext testContext) Re-inject each@BeanOverridefield in the test instance of the supplied test context with a corresponding bean override instance.intgetOrder()Returns 1950, which ensures that theBeanOverridetestExecutionListeneris ordered after theDirtiesContextBeforeModestestExecutionListenerand before theDependencyInjectiontestExecutionListener.voidpreparetestInstance(testContext testContext) Inject each@BeanOverridefield in the test instance of the supplied test context with a corresponding bean override instance.Methods inherited from class AbstracttestExecutionListener
aftertestClass, aftertestExecution, aftertestMethod, beforetestClass, beforetestExecution
-
Field Details
-
ORDER
-
-
Constructor Details
-
BeanOverridetestExecutionListener
public BeanOverridetestExecutionListener()
-
-
Method Details
-
getOrder
public int getOrder()Returns 1950, which ensures that theBeanOverridetestExecutionListeneris ordered after theDirtiesContextBeforeModestestExecutionListenerand before theDependencyInjectiontestExecutionListener.- Specified by:
getOrderin interfaceOrdered- Overrides:
getOrderin classAbstracttestExecutionListener- Returns:
- the order value
- See Also:
-
preparetestInstance
Inject each@BeanOverridefield in the test instance of the supplied test context with a corresponding bean override instance.- Specified by:
preparetestInstancein interfacetestExecutionListener- Overrides:
preparetestInstancein classAbstracttestExecutionListener- Parameters:
testContext- the test context for the test; nevernull- Throws:
Exception- allows any exception to propagate- See Also:
-
beforetestMethod
Re-inject each@BeanOverridefield in the test instance of the supplied test context with a corresponding bean override instance.This method does nothing if the
REINJECT_DEPENDENCIES_ATTRIBUTEattribute is not present in thetestContextwith a value ofBoolean.TRUE.- 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:
-