Skip to content

Commit 01a15cf

Browse files
committed
Merge branch '6.2.x'
2 parents 0ebbe02 + ea8b18f commit 01a15cf

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

spring-test/src/main/java/org/springframework/test/context/bean/override/BeanOverrideContextCustomizerFactory.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,16 @@ public BeanOverrideContextCustomizer createContextCustomizer(Class<?> testClass,
4444
List<ContextConfigurationAttributes> configAttributes) {
4545

4646
Set<BeanOverrideHandler> handlers = new LinkedHashSet<>();
47-
findBeanOverrideHandler(testClass, handlers);
47+
findBeanOverrideHandlers(testClass, handlers);
4848
if (handlers.isEmpty()) {
4949
return null;
5050
}
5151
return new BeanOverrideContextCustomizer(handlers);
5252
}
5353

54-
private void findBeanOverrideHandler(Class<?> testClass, Set<BeanOverrideHandler> handlers) {
54+
private void findBeanOverrideHandlers(Class<?> testClass, Set<BeanOverrideHandler> handlers) {
5555
if (TestContextAnnotationUtils.searchEnclosingClass(testClass)) {
56-
findBeanOverrideHandler(testClass.getEnclosingClass(), handlers);
56+
findBeanOverrideHandlers(testClass.getEnclosingClass(), handlers);
5757
}
5858
BeanOverrideHandler.forTestClass(testClass).forEach(handler ->
5959
Assert.state(handlers.add(handler), () ->

spring-test/src/main/java/org/springframework/test/context/bean/override/BeanOverrideHandler.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@
5151
* unique set of metadata used to identify the bean to override. Overridden
5252
* {@code equals()} and {@code hashCode()} methods should also delegate to the
5353
* {@code super} implementations in this class in order to support the basic
54-
* metadata used by all bean overrides.
54+
* metadata used by all bean overrides. In addition, it is recommended that
55+
* implementations override {@code toString()} to include all relevant metadata
56+
* in order to enhance diagnostics.
5557
*
5658
* <p>Concrete implementations of {@code BeanOverrideHandler} can store additional
5759
* metadata to use during override {@linkplain #createOverrideInstance instance
@@ -93,9 +95,11 @@ protected BeanOverrideHandler(Field field, ResolvableType beanType, @Nullable St
9395
/**
9496
* Process the given {@code testClass} and build the corresponding
9597
* {@code BeanOverrideHandler} list derived from {@link BeanOverride @BeanOverride}
96-
* fields in the test class, its type hierarchy, and its enclosing class hierarchy.
98+
* fields in the test class and its type hierarchy.
99+
* <p>This method does not search the enclosing class hierarchy.
97100
* @param testClass the test class to process
98101
* @return a list of bean override handlers
102+
* @see org.springframework.test.context.TestContextAnnotationUtils#searchEnclosingClass(Class)
99103
*/
100104
public static List<BeanOverrideHandler> forTestClass(Class<?> testClass) {
101105
List<BeanOverrideHandler> handlers = new LinkedList<>();

0 commit comments

Comments
 (0)