mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-15 01:07:30 +08:00
Small assertions improvements
See gh-34796
This commit is contained in:
parent
cb2773da21
commit
d802ca017b
@ -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() {
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user