From f68130d2e55d6d531c56d82bbacf8730c0b60588 Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Mon, 3 Jun 2024 17:17:51 +0200 Subject: [PATCH] =?UTF-8?q?Update=20Javadoc=20for=20@=E2=81=A0TestBean=20s?= =?UTF-8?q?upport?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See gh-32943 --- .../bean/override/convention/TestBean.java | 6 +++--- .../convention/TestBeanOverrideProcessor.java | 19 ++++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/context/bean/override/convention/TestBean.java b/spring-test/src/main/java/org/springframework/test/context/bean/override/convention/TestBean.java index d1d988ac7a5..edb843bde75 100644 --- a/spring-test/src/main/java/org/springframework/test/context/bean/override/convention/TestBean.java +++ b/spring-test/src/main/java/org/springframework/test/context/bean/override/convention/TestBean.java @@ -36,9 +36,9 @@ import org.springframework.test.context.bean.override.BeanOverride; * *
The instance is created from a zero-argument static factory method in the * test class whose return type is compatible with the annotated field. In the - * case of a nested test, any enclosing class it might have is also considered. - * Similarly, in case the test class inherits from a base class the whole class - * hierarchy is considered. The method is deduced as follows. + * case of a nested test class, the enclosing class is also considered. Similarly, + * if the test class extends from a base class or implements any interfaces, the + * entire type hierarchy is considered. The method is deduced as follows. *
Delegates to {@link #findTestBeanFactoryMethod(Class, Class, List)}. */ static Method findTestBeanFactoryMethod(Class> clazz, Class> methodReturnType, String... methodNames) { @@ -62,19 +61,21 @@ class TestBeanOverrideProcessor implements BeanOverrideProcessor { } /** - * Find a test bean factory {@link Method} in the given {@link Class} or one - * of its parent classes, which meets the following criteria. + * Find a test bean factory {@link Method} for the given {@link Class}, which + * meets the following criteria. *
If the test class inherits from another class, the class hierarchy is - * searched for factory methods. Matching factory methods are prioritized - * from closest to farthest from the test class in the class hierarchy, - * provided they have the same name. However, if multiple methods are found - * that match distinct candidate names, an exception is thrown. + *
This method traverses up the type hierarchy of the given class in search + * of the factory method, beginning with the class itself and then searching + * implemented interfaces and superclasses. If a factory method is not found + * in the type hierarchy, this method will also search on the enclosing class + * if the class is a nested class. + *
If multiple factory methods are found that match the search criteria, + * an exception is thrown. * @param clazz the class in which to search for the factory method * @param methodReturnType the return type for the factory method * @param methodNames a set of supported names for the factory method