@ -78,6 +78,7 @@ public abstract class TestConstructorUtils {
@@ -78,6 +78,7 @@ public abstract class TestConstructorUtils {
private TestConstructorUtils ( ) {
}
/ * *
* Determine if the supplied executable for the given test class is an
* autowirable constructor .
@ -86,8 +87,11 @@ public abstract class TestConstructorUtils {
@@ -86,8 +87,11 @@ public abstract class TestConstructorUtils {
* @param executable an executable for the test class
* @param testClass the test class
* @return { @code true } if the executable is an autowirable constructor
* @see # isAutowirableConstructor ( Executable , Class , PropertyProvider )
* @see # isAutowirableConstructor ( Executable , PropertyProvider )
* @deprecated as of 6 . 2 . 13 , in favor of { @link # isAutowirableConstructor ( Executable , PropertyProvider ) } ;
* to be removed in Spring Framework 7 . 1
* /
@Deprecated ( since = "6.2.13" , forRemoval = true )
public static boolean isAutowirableConstructor ( Executable executable , Class < ? > testClass ) {
return isAutowirableConstructor ( executable , testClass , null ) ;
}
@ -101,7 +105,10 @@ public abstract class TestConstructorUtils {
@@ -101,7 +105,10 @@ public abstract class TestConstructorUtils {
* @param testClass the test class
* @return { @code true } if the constructor is autowirable
* @see # isAutowirableConstructor ( Constructor , Class , PropertyProvider )
* @deprecated as of 6 . 2 . 13 , in favor of { @link # isAutowirableConstructor ( Executable , PropertyProvider ) } ;
* to be removed in Spring Framework 7 . 1
* /
@Deprecated ( since = "6.2.13" , forRemoval = true )
public static boolean isAutowirableConstructor ( Constructor < ? > constructor , Class < ? > testClass ) {
return isAutowirableConstructor ( constructor , testClass , null ) ;
}
@ -119,7 +126,10 @@ public abstract class TestConstructorUtils {
@@ -119,7 +126,10 @@ public abstract class TestConstructorUtils {
* @return { @code true } if the executable is an autowirable constructor
* @since 5 . 3
* @see # isAutowirableConstructor ( Constructor , Class , PropertyProvider )
* @deprecated as of 6 . 2 . 13 , in favor of { @link # isAutowirableConstructor ( Executable , PropertyProvider ) } ;
* to be removed in Spring Framework 7 . 1
* /
@Deprecated ( since = "6.2.13" , forRemoval = true )
public static boolean isAutowirableConstructor ( Executable executable , Class < ? > testClass ,
@Nullable PropertyProvider fallbackPropertyProvider ) {
@ -148,16 +158,62 @@ public abstract class TestConstructorUtils {
@@ -148,16 +158,62 @@ public abstract class TestConstructorUtils {
* { @link TestConstructor # TEST_CONSTRUCTOR_AUTOWIRE_MODE_PROPERTY_NAME } ) . < / li >
* < / ol >
* @param constructor a constructor for the test class
* @param testClass the test class
* @param testClass the test class , typically the declaring class of the constructor
* @param fallbackPropertyProvider fallback property provider used to look up
* the value for the default < em > test constructor autowire mode < / em > if no
* such value is found in { @link SpringProperties }
* the value for { @link TestConstructor # TEST_CONSTRUCTOR_AUTOWIRE_MODE_PROPERTY_NAME }
* if no such value is found in { @link SpringProperties } ; may be { @code null }
* if there is no fallback support
* @return { @code true } if the constructor is autowirable
* @since 5 . 3
* @see # isAutowirableConstructor ( Executable , PropertyProvider )
* @deprecated as of 6 . 2 . 13 , in favor of { @link # isAutowirableConstructor ( Executable , PropertyProvider ) } ;
* to be removed in Spring Framework 7 . 1
* /
@Deprecated ( since = "6.2.13" , forRemoval = true )
public static boolean isAutowirableConstructor ( Constructor < ? > constructor , Class < ? > testClass ,
@Nullable PropertyProvider fallbackPropertyProvider ) {
return isAutowirableConstructorInternal ( constructor , testClass , fallbackPropertyProvider ) ;
}
/ * *
* Determine if the supplied { @link Executable } is an autowirable { @link Constructor } .
*
* < p > A constructor is considered to be autowirable if one of the following
* conditions is { @code true } .
*
* < ol >
* < li > The constructor is annotated with { @link Autowired @Autowired } ,
* { @link jakarta . inject . Inject @jakarta.inject.Inject } , or
* { @link javax . inject . Inject @javax.inject.Inject } . < / li >
* < li > { @link TestConstructor @TestConstructor } is < em > present < / em > or
* < em > meta - present < / em > on the test class with
* { @link TestConstructor # autowireMode ( ) autowireMode } set to
* { @link AutowireMode # ALL ALL } . < / li >
* < li > The default < em > test constructor autowire mode < / em > has been set to
* { @code ALL } in { @link SpringProperties } or in the supplied fallback
* { @link PropertyProvider } . < / li >
* < / ol >
* @param executable an { @code Executable } for a test class
* @param fallbackPropertyProvider fallback property provider used to look up
* the value for { @value TestConstructor # TEST_CONSTRUCTOR_AUTOWIRE_MODE_PROPERTY_NAME }
* if no such value is found in { @link SpringProperties } ; may be { @code null }
* if there is no fallback support
* @return { @code true } if the executable is an autowirable constructor
* @since 6 . 2 . 13
* @see TestConstructor # TEST_CONSTRUCTOR_AUTOWIRE_MODE_PROPERTY_NAME
* /
public static boolean isAutowirableConstructor ( Executable executable ,
@Nullable PropertyProvider fallbackPropertyProvider ) {
return ( executable instanceof Constructor < ? > constructor & &
isAutowirableConstructorInternal ( constructor , constructor . getDeclaringClass ( ) , fallbackPropertyProvider ) ) ;
}
private static boolean isAutowirableConstructorInternal ( Constructor < ? > constructor , Class < ? > testClass ,
@Nullable PropertyProvider fallbackPropertyProvider ) {
// Is the constructor annotated with @Autowired/@Inject?
if ( isAnnotatedWithAutowiredOrInject ( constructor ) ) {
return true ;