From c2f8d4803f25f04df3a2739562aa2ff59b834bad Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Sun, 30 Jun 2024 20:36:55 +0200 Subject: [PATCH] =?UTF-8?q?Update=20Javadoc=20for=20@=E2=81=A0TestBean?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bean/override/convention/TestBean.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 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 ec5f92679af..a94ee7a9bcc 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 @@ -29,17 +29,20 @@ import org.springframework.test.context.bean.override.BeanOverride; * Mark a field to override a bean definition in the {@code BeanFactory}. * *
By default, the bean to override is inferred from the type of the - * annotated field. This requires that exactly one matching definition is + * annotated field. This requires that exactly one matching bean definition is * present in the application context. A {@code @Qualifier} annotation can be - * used to help disambiguate. Alternatively, you can explicitly specify a bean - * name to replace by setting the {@link #value()} or {@link #name()} attribute. + * used to help disambiguate. In the absence of a {@code @Qualifier} annotation, + * the name of the annotated field will be used as a qualifier. Alternatively, + * you can explicitly specify a bean name to replace by setting the + * {@link #value()} or {@link #name()} attribute. * *
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 class, the enclosing class hierarchy is also considered. + * case of a nested test class, the enclosing class hierarchy is also searched. * 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 + * interfaces, the entire type hierarchy is searched. The method is deduced as * follows. + * *
If left unspecified, the bean to override is selected according to - * the annotated field's type. + * the annotated field's type, taking qualifiers into account if necessary. + * See the {@linkplain TestBean class-level documentation} for details. * @see #value() */ @AliasFor("value") String name() default ""; /** - * Name of a static factory method to look for in the test class, which will - * be used to instantiate the bean to override. - *
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. + * Name of the static factory method that will be used to instantiate the bean + * to override. + *
A search will be performed to find the factory method in the test class, + * in one of its superclasses, or in any implemented interfaces. In the case + * of a nested test class, the enclosing class hierarchy will also be searched. *
If left unspecified, the name of the factory method will be detected * based either on the name of the annotated field or the name of the bean. */