Introduce isAutowirableConstructor(Executable,PropertyProvider) in TestConstructorUtils

This commit introduces a new isAutowirableConstructor(Executable, PropertyProvider)
overload in TestConstructorUtils and deprecates all other existing variants
for removal in 7.1.

Closes gh-35676
This commit is contained in:
Sam Brannen
2025-10-21 17:37:04 +02:00
parent cb0f26a152
commit 82c34f7b51
3 changed files with 68 additions and 10 deletions
@@ -41,6 +41,9 @@ import static org.springframework.test.context.TestConstructor.AutowireMode.ANNO
*/
class TestConstructorUtilsTests {
private static final PropertyProvider propertyProvider = name -> null;
@AfterEach
void clearGlobalFlag() {
setGlobalFlag(null);
@@ -100,12 +103,12 @@ class TestConstructorUtilsTests {
private void assertAutowirable(Class<?> testClass) throws NoSuchMethodException {
Constructor<?> constructor = testClass.getDeclaredConstructor();
assertThat(TestConstructorUtils.isAutowirableConstructor(constructor, testClass)).isTrue();
assertThat(TestConstructorUtils.isAutowirableConstructor(constructor, propertyProvider)).isTrue();
}
private void assertNotAutowirable(Class<?> testClass) throws NoSuchMethodException {
Constructor<?> constructor = testClass.getDeclaredConstructor();
assertThat(TestConstructorUtils.isAutowirableConstructor(constructor, testClass)).isFalse();
assertThat(TestConstructorUtils.isAutowirableConstructor(constructor, propertyProvider)).isFalse();
}
private void setGlobalFlag() {