use of org.springframework.boot.test.context.FilteredClassLoader in project spring-boot by spring-projects.
the class ServletWebServerFactoryAutoConfigurationTests method undertowBuilderCustomizerBeanIsAddedToFactory.
@Test
void undertowBuilderCustomizerBeanIsAddedToFactory() {
WebApplicationContextRunner runner = new WebApplicationContextRunner(AnnotationConfigServletWebServerApplicationContext::new).withClassLoader(new FilteredClassLoader(Tomcat.class, HttpServer.class, Server.class)).withConfiguration(AutoConfigurations.of(ServletWebServerFactoryAutoConfiguration.class)).withUserConfiguration(UndertowBuilderCustomizerConfiguration.class).withPropertyValues("server.port:0");
runner.run((context) -> {
UndertowServletWebServerFactory factory = context.getBean(UndertowServletWebServerFactory.class);
assertThat(factory.getBuilderCustomizers()).hasSize(1);
});
}
use of org.springframework.boot.test.context.FilteredClassLoader in project spring-boot by spring-projects.
the class ServletWebServerFactoryAutoConfigurationTests method undertowBuilderCustomizerRegisteredAsBeanAndViaFactoryIsOnlyCalledOnce.
@Test
void undertowBuilderCustomizerRegisteredAsBeanAndViaFactoryIsOnlyCalledOnce() {
WebApplicationContextRunner runner = new WebApplicationContextRunner(AnnotationConfigServletWebServerApplicationContext::new).withClassLoader(new FilteredClassLoader(Tomcat.class, HttpServer.class, Server.class)).withConfiguration(AutoConfigurations.of(ServletWebServerFactoryAutoConfiguration.class)).withUserConfiguration(DoubleRegistrationUndertowBuilderCustomizerConfiguration.class).withPropertyValues("server.port: 0");
runner.run((context) -> {
UndertowServletWebServerFactory factory = context.getBean(UndertowServletWebServerFactory.class);
UndertowBuilderCustomizer customizer = context.getBean("builderCustomizer", UndertowBuilderCustomizer.class);
assertThat(factory.getBuilderCustomizers()).contains(customizer);
then(customizer).should().customize(any(Builder.class));
});
}
use of org.springframework.boot.test.context.FilteredClassLoader in project spring-boot by spring-projects.
the class ServletWebServerFactoryAutoConfigurationTests method undertowDeploymentInfoCustomizerBeanIsAddedToFactory.
@Test
void undertowDeploymentInfoCustomizerBeanIsAddedToFactory() {
WebApplicationContextRunner runner = new WebApplicationContextRunner(AnnotationConfigServletWebServerApplicationContext::new).withClassLoader(new FilteredClassLoader(Tomcat.class, HttpServer.class, Server.class)).withConfiguration(AutoConfigurations.of(ServletWebServerFactoryAutoConfiguration.class)).withUserConfiguration(UndertowDeploymentInfoCustomizerConfiguration.class).withPropertyValues("server.port:0");
runner.run((context) -> {
UndertowServletWebServerFactory factory = context.getBean(UndertowServletWebServerFactory.class);
assertThat(factory.getDeploymentInfoCustomizers()).hasSize(1);
});
}
use of org.springframework.boot.test.context.FilteredClassLoader in project spring-boot by spring-projects.
the class ServletWebServerFactoryAutoConfigurationTests method jettyServerCustomizerBeanIsAddedToFactory.
@Test
void jettyServerCustomizerBeanIsAddedToFactory() {
WebApplicationContextRunner runner = new WebApplicationContextRunner(AnnotationConfigServletWebServerApplicationContext::new).withClassLoader(new FilteredClassLoader(Tomcat.class, HttpServer.class)).withConfiguration(AutoConfigurations.of(ServletWebServerFactoryAutoConfiguration.class)).withUserConfiguration(JettyServerCustomizerConfiguration.class).withPropertyValues("server.port:0");
runner.run((context) -> {
JettyServletWebServerFactory factory = context.getBean(JettyServletWebServerFactory.class);
assertThat(factory.getServerCustomizers()).hasSize(1);
});
}
use of org.springframework.boot.test.context.FilteredClassLoader in project spring-boot by spring-projects.
the class ServletWebServerFactoryAutoConfigurationTests method relativeRedirectsShouldNotBeEnabledWhenNotUsingTomcatContainer.
@Test
void relativeRedirectsShouldNotBeEnabledWhenNotUsingTomcatContainer() {
WebApplicationContextRunner runner = new WebApplicationContextRunner(AnnotationConfigServletWebServerApplicationContext::new).withClassLoader(new FilteredClassLoader(Tomcat.class)).withConfiguration(AutoConfigurations.of(ServletWebServerFactoryAutoConfiguration.class)).withPropertyValues("server.forward-headers-strategy=framework", "server.port=0");
runner.run((context) -> {
Filter filter = context.getBean(FilterRegistrationBean.class).getFilter();
assertThat(filter).isInstanceOf(ForwardedHeaderFilter.class);
assertThat(filter).extracting("relativeRedirects").isEqualTo(false);
});
}
Aggregations