diff --git a/spring-test/src/test/java/org/springframework/test/context/bean/override/convention/TestBeanTests.java b/spring-test/src/test/java/org/springframework/test/context/bean/override/convention/TestBeanTests.java index 8a9c4a25b2..f860700524 100644 --- a/spring-test/src/test/java/org/springframework/test/context/bean/override/convention/TestBeanTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/bean/override/convention/TestBeanTests.java @@ -64,8 +64,8 @@ public class TestBeanTests { .isThrownBy(context::refresh) .withMessage(""" Unable to override bean: there are no beans of \ - type %s (as required by field '%s.example').""".formatted( - String.class.getName(), FailureByTypeLookup.class.getSimpleName())); + type %s (as required by field '%s.example').""", + String.class.getName(), FailureByTypeLookup.class.getSimpleName()); } @Test @@ -87,8 +87,8 @@ public class TestBeanTests { assertThatIllegalStateException() .isThrownBy(() -> BeanOverrideContextCustomizerTestUtils.customizeApplicationContext( FailureMissingDefaultOverrideMethod.class, context)) - .withMessage("No static method found named example() or beanToOverride() in %s with return type %s" - .formatted(FailureMissingDefaultOverrideMethod.class.getName(), String.class.getName())); + .withMessage("No static method found named example() or beanToOverride() in %s with return type %s", + FailureMissingDefaultOverrideMethod.class.getName(), String.class.getName()); } @Test @@ -97,8 +97,8 @@ public class TestBeanTests { assertThatIllegalStateException() .isThrownBy(() -> BeanOverrideContextCustomizerTestUtils.customizeApplicationContext( FailureMissingExplicitOverrideMethod.class, context)) - .withMessage("No static method found named createExample() in %s with return type %s" - .formatted(FailureMissingExplicitOverrideMethod.class.getName(), String.class.getName())); + .withMessage("No static method found named createExample() in %s with return type %s", + FailureMissingExplicitOverrideMethod.class.getName(), String.class.getName()); } @Test @@ -108,8 +108,8 @@ public class TestBeanTests { assertThatIllegalStateException() .isThrownBy(() -> BeanOverrideContextCustomizerTestUtils.customizeApplicationContext( FailureOverrideInParentWithoutFactoryMethod.class, context)) - .withMessage("No static method found named beanToOverride() in %s with return type %s" - .formatted(FailureOverrideInParentWithoutFactoryMethod.class.getName(), String.class.getName())); + .withMessage("No static method found named beanToOverride() in %s with return type %s", + FailureOverrideInParentWithoutFactoryMethod.class.getName(), String.class.getName()); } @Test @@ -119,8 +119,8 @@ public class TestBeanTests { assertThatIllegalStateException() .isThrownBy(() -> BeanOverrideContextCustomizerTestUtils.customizeApplicationContext( FailureCompetingOverrideMethods.class, context)) - .withMessage("Found 2 competing static methods named example() or beanToOverride() in %s with return type %s" - .formatted(FailureCompetingOverrideMethods.class.getName(), String.class.getName())); + .withMessage("Found 2 competing static methods named example() or beanToOverride() in %s with return type %s", + FailureCompetingOverrideMethods.class.getName(), String.class.getName()); } @@ -151,7 +151,6 @@ public class TestBeanTests { // Expected static String example() { ... } // or static String beanToOverride() { ... } - } static class FailureMissingExplicitOverrideMethod { @@ -160,20 +159,17 @@ public class TestBeanTests { private String example; // Expected static String createExample() { ... } - } abstract static class AbstractByNameLookup { @TestBean(methodName = "beanToOverride") protected String beanToOverride; - } static class FailureOverrideInParentWithoutFactoryMethod extends AbstractByNameLookup { // No beanToOverride() method - } abstract static class AbstractCompetingMethods { @@ -191,7 +187,6 @@ public class TestBeanTests { static String beanToOverride() { throw new IllegalStateException("Should not be called"); } - } }