diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/aop/AopAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/aop/AopAutoConfigurationTests.java index 9cca79a157..806792e4d7 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/aop/AopAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/aop/AopAutoConfigurationTests.java @@ -90,10 +90,7 @@ class AopAutoConfigurationTests { void whenGlobalMethodSecurityIsEnabledAndAspectJIsNotAvailableThenClassProxyingIsStillUsedByDefault() { this.contextRunner.withClassLoader(new FilteredClassLoader(Advice.class)) .withUserConfiguration(ExampleController.class, EnableGlobalMethodSecurityConfiguration.class) - .run((context) -> { - ExampleController exampleController = context.getBean(ExampleController.class); - assertThat(AopUtils.isCglibProxy(exampleController)).isTrue(); - }); + .run((context) -> assertThat(context).getBean(ExampleController.class).matches(AopUtils::isCglibProxy)); } private ContextConsumer proxyTargetClassEnabled() { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java index 70b800675d..15759a908e 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java @@ -655,10 +655,8 @@ class WebFluxAutoConfigurationTests { this.contextRunner.withConfiguration(AutoConfigurations.of(AopAutoConfiguration.class)) .withBean(ExceptionHandlerInterceptor.class) .withPropertyValues("spring.webflux.problemdetails.enabled:true") - .run((context) -> { - assertThat(context).hasSingleBean(ProblemDetailsExceptionHandler.class); - assertThat(AopUtils.isCglibProxy(context.getBean(ProblemDetailsExceptionHandler.class))).isTrue(); - }); + .run((context) -> assertThat(context).getBean(ProblemDetailsExceptionHandler.class) + .matches(AopUtils::isCglibProxy)); } @Test diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java index 46ca55b562..f7aa8288f9 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java @@ -998,10 +998,8 @@ class WebMvcAutoConfigurationTests { this.contextRunner.withConfiguration(AutoConfigurations.of(AopAutoConfiguration.class)) .withBean(ExceptionHandlerInterceptor.class) .withPropertyValues("spring.mvc.problemdetails.enabled:true") - .run((context) -> { - assertThat(context).hasSingleBean(ProblemDetailsExceptionHandler.class); - assertThat(AopUtils.isCglibProxy(context.getBean(ProblemDetailsExceptionHandler.class))).isTrue(); - }); + .run((context) -> assertThat(context).getBean(ProblemDetailsExceptionHandler.class) + .matches(AopUtils::isCglibProxy)); } @Test diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/classloader/RestartClassLoaderTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/classloader/RestartClassLoaderTests.java index 488af96235..40f9fcc3ac 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/classloader/RestartClassLoaderTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/classloader/RestartClassLoaderTests.java @@ -223,13 +223,11 @@ class RestartClassLoaderTests { new URL[] { this.sampleJarFile.toURI().toURL() }, this.updatedFiles)) { new ApplicationContextRunner().withClassLoader(restartClassLoader) .withUserConfiguration(ProxyConfiguration.class) - .run((context) -> { - assertThat(context).hasNotFailed(); - ExampleTransactional transactional = context.getBean(ExampleTransactional.class); - assertThat(AopUtils.isCglibProxy(transactional)).isTrue(); - assertThat(transactional.getClass().getClassLoader()) - .isEqualTo(ExampleTransactional.class.getClassLoader()); - }); + .run((context) -> assertThat(context).getBean(ExampleTransactional.class) + .matches(AopUtils::isCglibProxy) + .extracting(Object::getClass) + .extracting(Class::getClassLoader) + .isEqualTo(ExampleTransactional.class.getClassLoader())); } }