use of org.springframework.boot.test.context.FilteredClassLoader in project spring-boot by spring-projects.
the class ReactiveWebServerFactoryAutoConfigurationTests method jettyServerCustomizerBeanIsAddedToFactory.
@Test
void jettyServerCustomizerBeanIsAddedToFactory() {
new ReactiveWebApplicationContextRunner(AnnotationConfigReactiveWebApplicationContext::new).withConfiguration(AutoConfigurations.of(ReactiveWebServerFactoryAutoConfiguration.class)).withClassLoader(new FilteredClassLoader(Tomcat.class, HttpServer.class)).withUserConfiguration(JettyServerCustomizerConfiguration.class, HttpHandlerConfiguration.class).run((context) -> {
JettyReactiveWebServerFactory factory = context.getBean(JettyReactiveWebServerFactory.class);
assertThat(factory.getServerCustomizers()).hasSize(1);
});
}
use of org.springframework.boot.test.context.FilteredClassLoader in project spring-boot by spring-projects.
the class ReactiveWebServerFactoryAutoConfigurationTests method undertowBuilderCustomizerBeanIsAddedToFactory.
@Test
void undertowBuilderCustomizerBeanIsAddedToFactory() {
new ReactiveWebApplicationContextRunner(AnnotationConfigReactiveWebApplicationContext::new).withConfiguration(AutoConfigurations.of(ReactiveWebServerFactoryAutoConfiguration.class)).withClassLoader(new FilteredClassLoader(Tomcat.class, HttpServer.class, Server.class)).withUserConfiguration(UndertowBuilderCustomizerConfiguration.class, HttpHandlerConfiguration.class).run((context) -> {
UndertowReactiveWebServerFactory factory = context.getBean(UndertowReactiveWebServerFactory.class);
assertThat(factory.getBuilderCustomizers()).hasSize(1);
});
}
use of org.springframework.boot.test.context.FilteredClassLoader in project spring-boot by spring-projects.
the class ConnectionFactoryBeanCreationFailureAnalyzerTests method createFailure.
private BeanCreationException createFailure(Class<?> configuration) {
try {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
context.setClassLoader(new FilteredClassLoader("io.r2dbc.h2", "io.r2dbc.pool"));
context.setEnvironment(this.environment);
context.register(configuration);
context.refresh();
context.close();
return null;
} catch (BeanCreationException ex) {
return ex;
}
}
use of org.springframework.boot.test.context.FilteredClassLoader in project spring-boot by spring-projects.
the class ManagementWebSecurityAutoConfigurationTests method autoConfigIsConditionalOnSecurityFilterChainClass.
@Test
void autoConfigIsConditionalOnSecurityFilterChainClass() {
this.contextRunner.withClassLoader(new FilteredClassLoader(SecurityFilterChain.class)).run((context) -> {
assertThat(context).doesNotHaveBean(ManagementWebSecurityAutoConfiguration.class);
HttpStatus status = getResponseStatus(context, "/actuator/health");
assertThat(status).isEqualTo(HttpStatus.UNAUTHORIZED);
});
}
use of org.springframework.boot.test.context.FilteredClassLoader in project spring-boot by spring-projects.
the class ReactiveOAuth2ClientAutoConfigurationTests method assertWhenClassNotPresent.
private void assertWhenClassNotPresent(Class<?> classToFilter) {
FilteredClassLoader classLoader = new FilteredClassLoader(classToFilter);
this.contextRunner.withClassLoader(classLoader).withPropertyValues(REGISTRATION_PREFIX + ".foo.client-id=abcd", REGISTRATION_PREFIX + ".foo.client-secret=secret", REGISTRATION_PREFIX + ".foo.provider=github").run((context) -> assertThat(context).doesNotHaveBean(ReactiveOAuth2ClientAutoConfiguration.class));
}
Aggregations