@@ -69,6 +69,7 @@ public abstract class TestConstructorUtils {
6969 private TestConstructorUtils () {
7070 }
7171
72+
7273 /**
7374 * Determine if the supplied executable for the given test class is an
7475 * autowirable constructor.
@@ -77,8 +78,11 @@ private TestConstructorUtils() {
7778 * @param executable an executable for the test class
7879 * @param testClass the test class
7980 * @return {@code true} if the executable is an autowirable constructor
80- * @see #isAutowirableConstructor(Executable, Class, PropertyProvider)
81+ * @see #isAutowirableConstructor(Executable, PropertyProvider)
82+ * @deprecated as of 6.2.13, in favor of {@link #isAutowirableConstructor(Executable, PropertyProvider)};
83+ * to be removed in Spring Framework 7.1
8184 */
85+ @ Deprecated (since = "6.2.13" , forRemoval = true )
8286 public static boolean isAutowirableConstructor (Executable executable , Class <?> testClass ) {
8387 return isAutowirableConstructor (executable , testClass , null );
8488 }
@@ -92,7 +96,10 @@ public static boolean isAutowirableConstructor(Executable executable, Class<?> t
9296 * @param testClass the test class
9397 * @return {@code true} if the constructor is autowirable
9498 * @see #isAutowirableConstructor(Constructor, Class, PropertyProvider)
99+ * @deprecated as of 6.2.13, in favor of {@link #isAutowirableConstructor(Executable, PropertyProvider)};
100+ * to be removed in Spring Framework 7.1
95101 */
102+ @ Deprecated (since = "6.2.13" , forRemoval = true )
96103 public static boolean isAutowirableConstructor (Constructor <?> constructor , Class <?> testClass ) {
97104 return isAutowirableConstructor (constructor , testClass , null );
98105 }
@@ -110,7 +117,10 @@ public static boolean isAutowirableConstructor(Constructor<?> constructor, Class
110117 * @return {@code true} if the executable is an autowirable constructor
111118 * @since 5.3
112119 * @see #isAutowirableConstructor(Constructor, Class, PropertyProvider)
120+ * @deprecated as of 6.2.13, in favor of {@link #isAutowirableConstructor(Executable, PropertyProvider)};
121+ * to be removed in Spring Framework 7.1
113122 */
123+ @ Deprecated (since = "6.2.13" , forRemoval = true )
114124 public static boolean isAutowirableConstructor (Executable executable , Class <?> testClass ,
115125 @ Nullable PropertyProvider fallbackPropertyProvider ) {
116126
@@ -138,16 +148,62 @@ public static boolean isAutowirableConstructor(Executable executable, Class<?> t
138148 * {@link TestConstructor#TEST_CONSTRUCTOR_AUTOWIRE_MODE_PROPERTY_NAME}).</li>
139149 * </ol>
140150 * @param constructor a constructor for the test class
141- * @param testClass the test class
151+ * @param testClass the test class, typically the declaring class of the constructor
142152 * @param fallbackPropertyProvider fallback property provider used to look up
143- * the value for the default <em>test constructor autowire mode</em> if no
144- * such value is found in {@link SpringProperties}
153+ * the value for {@link TestConstructor#TEST_CONSTRUCTOR_AUTOWIRE_MODE_PROPERTY_NAME}
154+ * if no such value is found in {@link SpringProperties}; may be {@code null}
155+ * if there is no fallback support
145156 * @return {@code true} if the constructor is autowirable
146157 * @since 5.3
158+ * @see #isAutowirableConstructor(Executable, PropertyProvider)
159+ * @deprecated as of 6.2.13, in favor of {@link #isAutowirableConstructor(Executable, PropertyProvider)};
160+ * to be removed in Spring Framework 7.1
147161 */
162+ @ Deprecated (since = "6.2.13" , forRemoval = true )
148163 public static boolean isAutowirableConstructor (Constructor <?> constructor , Class <?> testClass ,
149164 @ Nullable PropertyProvider fallbackPropertyProvider ) {
150165
166+ return isAutowirableConstructorInternal (constructor , testClass , fallbackPropertyProvider );
167+ }
168+
169+ /**
170+ * Determine if the supplied {@link Executable} is an autowirable {@link Constructor}.
171+ *
172+ * <p>A constructor is considered to be autowirable if one of the following
173+ * conditions is {@code true}.
174+ *
175+ * <ol>
176+ * <li>The constructor is annotated with {@link Autowired @Autowired},
177+ * {@link jakarta.inject.Inject @jakarta.inject.Inject}, or
178+ * {@link javax.inject.Inject @javax.inject.Inject}.</li>
179+ * <li>{@link TestConstructor @TestConstructor} is <em>present</em> or
180+ * <em>meta-present</em> on the test class with
181+ * {@link TestConstructor#autowireMode() autowireMode} set to
182+ * {@link AutowireMode#ALL ALL}.</li>
183+ * <li>The default <em>test constructor autowire mode</em> has been set to
184+ * {@code ALL} in {@link SpringProperties} or in the supplied fallback
185+ * {@link PropertyProvider}.</li>
186+ * </ol>
187+ * @param executable an {@code Executable} for a test class
188+ * @param fallbackPropertyProvider fallback property provider used to look up
189+ * the value for {@value TestConstructor#TEST_CONSTRUCTOR_AUTOWIRE_MODE_PROPERTY_NAME}
190+ * if no such value is found in {@link SpringProperties}; may be {@code null}
191+ * if there is no fallback support
192+ * @return {@code true} if the executable is an autowirable constructor
193+ * @since 6.2.13
194+ * @see TestConstructor#TEST_CONSTRUCTOR_AUTOWIRE_MODE_PROPERTY_NAME
195+ */
196+ public static boolean isAutowirableConstructor (Executable executable ,
197+ @ Nullable PropertyProvider fallbackPropertyProvider ) {
198+
199+ return (executable instanceof Constructor <?> constructor &&
200+ isAutowirableConstructorInternal (constructor , constructor .getDeclaringClass (), fallbackPropertyProvider ));
201+ }
202+
203+
204+ private static boolean isAutowirableConstructorInternal (Constructor <?> constructor , Class <?> testClass ,
205+ @ Nullable PropertyProvider fallbackPropertyProvider ) {
206+
151207 // Is the constructor annotated with @Autowired/@Inject?
152208 if (isAnnotatedWithAutowiredOrInject (constructor )) {
153209 return true ;
0 commit comments