Small assertions improvements

See gh-34796
This commit is contained in:
Stefano Cordio
2023-03-28 13:11:52 +02:00
committed by Moritz Halbritter
parent cb2773da21
commit d802ca017b
4 changed files with 10 additions and 19 deletions

View File

@@ -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<AssertableApplicationContext> proxyTargetClassEnabled() {

View File

@@ -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

View File

@@ -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