Small assertions improvements

See gh-34796
pull/35417/head
Stefano Cordio 2 years ago committed by Moritz Halbritter
parent cb2773da21
commit d802ca017b

@ -90,10 +90,7 @@ class AopAutoConfigurationTests {
void whenGlobalMethodSecurityIsEnabledAndAspectJIsNotAvailableThenClassProxyingIsStillUsedByDefault() { void whenGlobalMethodSecurityIsEnabledAndAspectJIsNotAvailableThenClassProxyingIsStillUsedByDefault() {
this.contextRunner.withClassLoader(new FilteredClassLoader(Advice.class)) this.contextRunner.withClassLoader(new FilteredClassLoader(Advice.class))
.withUserConfiguration(ExampleController.class, EnableGlobalMethodSecurityConfiguration.class) .withUserConfiguration(ExampleController.class, EnableGlobalMethodSecurityConfiguration.class)
.run((context) -> { .run((context) -> assertThat(context).getBean(ExampleController.class).matches(AopUtils::isCglibProxy));
ExampleController exampleController = context.getBean(ExampleController.class);
assertThat(AopUtils.isCglibProxy(exampleController)).isTrue();
});
} }
private ContextConsumer<AssertableApplicationContext> proxyTargetClassEnabled() { private ContextConsumer<AssertableApplicationContext> proxyTargetClassEnabled() {

@ -655,10 +655,8 @@ class WebFluxAutoConfigurationTests {
this.contextRunner.withConfiguration(AutoConfigurations.of(AopAutoConfiguration.class)) this.contextRunner.withConfiguration(AutoConfigurations.of(AopAutoConfiguration.class))
.withBean(ExceptionHandlerInterceptor.class) .withBean(ExceptionHandlerInterceptor.class)
.withPropertyValues("spring.webflux.problemdetails.enabled:true") .withPropertyValues("spring.webflux.problemdetails.enabled:true")
.run((context) -> { .run((context) -> assertThat(context).getBean(ProblemDetailsExceptionHandler.class)
assertThat(context).hasSingleBean(ProblemDetailsExceptionHandler.class); .matches(AopUtils::isCglibProxy));
assertThat(AopUtils.isCglibProxy(context.getBean(ProblemDetailsExceptionHandler.class))).isTrue();
});
} }
@Test @Test

@ -998,10 +998,8 @@ class WebMvcAutoConfigurationTests {
this.contextRunner.withConfiguration(AutoConfigurations.of(AopAutoConfiguration.class)) this.contextRunner.withConfiguration(AutoConfigurations.of(AopAutoConfiguration.class))
.withBean(ExceptionHandlerInterceptor.class) .withBean(ExceptionHandlerInterceptor.class)
.withPropertyValues("spring.mvc.problemdetails.enabled:true") .withPropertyValues("spring.mvc.problemdetails.enabled:true")
.run((context) -> { .run((context) -> assertThat(context).getBean(ProblemDetailsExceptionHandler.class)
assertThat(context).hasSingleBean(ProblemDetailsExceptionHandler.class); .matches(AopUtils::isCglibProxy));
assertThat(AopUtils.isCglibProxy(context.getBean(ProblemDetailsExceptionHandler.class))).isTrue();
});
} }
@Test @Test

@ -223,13 +223,11 @@ class RestartClassLoaderTests {
new URL[] { this.sampleJarFile.toURI().toURL() }, this.updatedFiles)) { new URL[] { this.sampleJarFile.toURI().toURL() }, this.updatedFiles)) {
new ApplicationContextRunner().withClassLoader(restartClassLoader) new ApplicationContextRunner().withClassLoader(restartClassLoader)
.withUserConfiguration(ProxyConfiguration.class) .withUserConfiguration(ProxyConfiguration.class)
.run((context) -> { .run((context) -> assertThat(context).getBean(ExampleTransactional.class)
assertThat(context).hasNotFailed(); .matches(AopUtils::isCglibProxy)
ExampleTransactional transactional = context.getBean(ExampleTransactional.class); .extracting(Object::getClass)
assertThat(AopUtils.isCglibProxy(transactional)).isTrue(); .extracting(Class::getClassLoader)
assertThat(transactional.getClass().getClassLoader()) .isEqualTo(ExampleTransactional.class.getClassLoader()));
.isEqualTo(ExampleTransactional.class.getClassLoader());
});
} }
} }

Loading…
Cancel
Save