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 d9afaab178..4a712c60e9 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 @@ -28,7 +28,7 @@ import org.springframework.test.context.bean.override.BeanOverride; /** * Mark a field to override a bean instance in the {@code BeanFactory}. * - *
The instance is created from a no-arg static factory method in the test + *
The instance is created from a zero-argument static factory method in the test * class whose return type is compatible with the annotated field. The method * is deduced as follows. *
By default, the name of the bean to override is inferred from the name of - * the annotated field. To use a different bean name, set the {@link #name()} - * attribute. + * the annotated field. To use a different bean name, set the {@link #value()} or + * {@link #name()} attribute. * * @author Simon Baslé * @author Stephane Nicoll @@ -93,22 +93,27 @@ import org.springframework.test.context.bean.override.BeanOverride; public @interface TestBean { /** - * Required suffix for a factory method that overrides a bean instance that - * is detected by convention. + * Required suffix for the name of a factory method that overrides a bean + * instance when the factory method is detected by convention. + * @see #methodName() */ String CONVENTION_SUFFIX = "TestOverride"; /** * Alias for {@link #name()}. + *
Intended to be used when no other attributes are needed — for + * example, {@code @TestBean("customBeanName")}. + * @see #name() */ @AliasFor("name") String value() default ""; /** * Name of the bean to override. - *
Defaults to {@code ""} (the empty String) to signal that the name of - * the annotated field should be used as the bean name. + *
If left unspecified, the name of the bean to override is the name of + * the annotated field. If specified, the field name is ignored. + * @see #value() */ @AliasFor("value") String name() default ""; @@ -116,8 +121,9 @@ public @interface TestBean { /** * Name of a static factory method to look for in the test class, which will * be used to instantiate the bean to override. - *
Defaults to {@code ""} (the empty String) to signal that the factory - * method should be detected based on convention. + *
If left unspecified, the name of the factory method will be detected + * based on convention. + * @see #CONVENTION_SUFFIX */ String methodName() default ""; diff --git a/spring-test/src/main/java/org/springframework/test/context/bean/override/convention/TestBeanOverrideProcessor.java b/spring-test/src/main/java/org/springframework/test/context/bean/override/convention/TestBeanOverrideProcessor.java index 0ee2c171f8..e31239daf8 100644 --- a/spring-test/src/main/java/org/springframework/test/context/bean/override/convention/TestBeanOverrideProcessor.java +++ b/spring-test/src/main/java/org/springframework/test/context/bean/override/convention/TestBeanOverrideProcessor.java @@ -53,10 +53,10 @@ public class TestBeanOverrideProcessor implements BeanOverrideProcessor { * Find a test bean factory {@link Method} in the given {@link Class} which * meets the following criteria. *