@@ -78,6 +78,7 @@ public abstract class TestConstructorUtils {
7878 private TestConstructorUtils () {
7979 }
8080
81+
8182 /**
8283 * Determine if the supplied executable for the given test class is an
8384 * autowirable constructor.
@@ -86,8 +87,11 @@ private TestConstructorUtils() {
8687 * @param executable an executable for the test class
8788 * @param testClass the test class
8889 * @return {@code true} if the executable is an autowirable constructor
89- * @see #isAutowirableConstructor(Executable, Class, PropertyProvider)
90+ * @see #isAutowirableConstructor(Executable, PropertyProvider)
91+ * @deprecated as of 6.2.13, in favor of {@link #isAutowirableConstructor(Executable, PropertyProvider)};
92+ * to be removed in Spring Framework 7.1
9093 */
94+ @ Deprecated (since = "6.2.13" , forRemoval = true )
9195 public static boolean isAutowirableConstructor (Executable executable , Class <?> testClass ) {
9296 return isAutowirableConstructor (executable , testClass , null );
9397 }
@@ -101,7 +105,10 @@ public static boolean isAutowirableConstructor(Executable executable, Class<?> t
101105 * @param testClass the test class
102106 * @return {@code true} if the constructor is autowirable
103107 * @see #isAutowirableConstructor(Constructor, Class, PropertyProvider)
108+ * @deprecated as of 6.2.13, in favor of {@link #isAutowirableConstructor(Executable, PropertyProvider)};
109+ * to be removed in Spring Framework 7.1
104110 */
111+ @ Deprecated (since = "6.2.13" , forRemoval = true )
105112 public static boolean isAutowirableConstructor (Constructor <?> constructor , Class <?> testClass ) {
106113 return isAutowirableConstructor (constructor , testClass , null );
107114 }
@@ -119,7 +126,10 @@ public static boolean isAutowirableConstructor(Constructor<?> constructor, Class
119126 * @return {@code true} if the executable is an autowirable constructor
120127 * @since 5.3
121128 * @see #isAutowirableConstructor(Constructor, Class, PropertyProvider)
129+ * @deprecated as of 6.2.13, in favor of {@link #isAutowirableConstructor(Executable, PropertyProvider)};
130+ * to be removed in Spring Framework 7.1
122131 */
132+ @ Deprecated (since = "6.2.13" , forRemoval = true )
123133 public static boolean isAutowirableConstructor (Executable executable , Class <?> testClass ,
124134 @ Nullable PropertyProvider fallbackPropertyProvider ) {
125135
@@ -148,16 +158,62 @@ public static boolean isAutowirableConstructor(Executable executable, Class<?> t
148158 * {@link TestConstructor#TEST_CONSTRUCTOR_AUTOWIRE_MODE_PROPERTY_NAME}).</li>
149159 * </ol>
150160 * @param constructor a constructor for the test class
151- * @param testClass the test class
161+ * @param testClass the test class, typically the declaring class of the constructor
152162 * @param fallbackPropertyProvider fallback property provider used to look up
153- * the value for the default <em>test constructor autowire mode</em> if no
154- * such value is found in {@link SpringProperties}
163+ * the value for {@link TestConstructor#TEST_CONSTRUCTOR_AUTOWIRE_MODE_PROPERTY_NAME}
164+ * if no such value is found in {@link SpringProperties}; may be {@code null}
165+ * if there is no fallback support
155166 * @return {@code true} if the constructor is autowirable
156167 * @since 5.3
168+ * @see #isAutowirableConstructor(Executable, PropertyProvider)
169+ * @deprecated as of 6.2.13, in favor of {@link #isAutowirableConstructor(Executable, PropertyProvider)};
170+ * to be removed in Spring Framework 7.1
157171 */
172+ @ Deprecated (since = "6.2.13" , forRemoval = true )
158173 public static boolean isAutowirableConstructor (Constructor <?> constructor , Class <?> testClass ,
159174 @ Nullable PropertyProvider fallbackPropertyProvider ) {
160175
176+ return isAutowirableConstructorInternal (constructor , testClass , fallbackPropertyProvider );
177+ }
178+
179+ /**
180+ * Determine if the supplied {@link Executable} is an autowirable {@link Constructor}.
181+ *
182+ * <p>A constructor is considered to be autowirable if one of the following
183+ * conditions is {@code true}.
184+ *
185+ * <ol>
186+ * <li>The constructor is annotated with {@link Autowired @Autowired},
187+ * {@link jakarta.inject.Inject @jakarta.inject.Inject}, or
188+ * {@link javax.inject.Inject @javax.inject.Inject}.</li>
189+ * <li>{@link TestConstructor @TestConstructor} is <em>present</em> or
190+ * <em>meta-present</em> on the test class with
191+ * {@link TestConstructor#autowireMode() autowireMode} set to
192+ * {@link AutowireMode#ALL ALL}.</li>
193+ * <li>The default <em>test constructor autowire mode</em> has been set to
194+ * {@code ALL} in {@link SpringProperties} or in the supplied fallback
195+ * {@link PropertyProvider}.</li>
196+ * </ol>
197+ * @param executable an {@code Executable} for a test class
198+ * @param fallbackPropertyProvider fallback property provider used to look up
199+ * the value for {@value TestConstructor#TEST_CONSTRUCTOR_AUTOWIRE_MODE_PROPERTY_NAME}
200+ * if no such value is found in {@link SpringProperties}; may be {@code null}
201+ * if there is no fallback support
202+ * @return {@code true} if the executable is an autowirable constructor
203+ * @since 6.2.13
204+ * @see TestConstructor#TEST_CONSTRUCTOR_AUTOWIRE_MODE_PROPERTY_NAME
205+ */
206+ public static boolean isAutowirableConstructor (Executable executable ,
207+ @ Nullable PropertyProvider fallbackPropertyProvider ) {
208+
209+ return (executable instanceof Constructor <?> constructor &&
210+ isAutowirableConstructorInternal (constructor , constructor .getDeclaringClass (), fallbackPropertyProvider ));
211+ }
212+
213+
214+ private static boolean isAutowirableConstructorInternal (Constructor <?> constructor , Class <?> testClass ,
215+ @ Nullable PropertyProvider fallbackPropertyProvider ) {
216+
161217 // Is the constructor annotated with @Autowired/@Inject?
162218 if (isAnnotatedWithAutowiredOrInject (constructor )) {
163219 return true ;
0 commit comments