use of org.springframework.boot.web.embedded.jetty.JettyServerCustomizer in project spring-boot by spring-projects.
the class ServletWebServerFactoryAutoConfigurationTests method jettyServerCustomizerRegisteredAsBeanAndViaFactoryIsOnlyCalledOnce.
@Test
void jettyServerCustomizerRegisteredAsBeanAndViaFactoryIsOnlyCalledOnce() {
WebApplicationContextRunner runner = new WebApplicationContextRunner(AnnotationConfigServletWebServerApplicationContext::new).withClassLoader(new FilteredClassLoader(Tomcat.class, HttpServer.class)).withConfiguration(AutoConfigurations.of(ServletWebServerFactoryAutoConfiguration.class)).withUserConfiguration(DoubleRegistrationJettyServerCustomizerConfiguration.class).withPropertyValues("server.port: 0");
runner.run((context) -> {
JettyServletWebServerFactory factory = context.getBean(JettyServletWebServerFactory.class);
JettyServerCustomizer customizer = context.getBean("serverCustomizer", JettyServerCustomizer.class);
assertThat(factory.getServerCustomizers()).contains(customizer);
then(customizer).should().customize(any(Server.class));
});
}
use of org.springframework.boot.web.embedded.jetty.JettyServerCustomizer in project spring-boot by spring-projects.
the class ReactiveWebServerFactoryAutoConfigurationTests method jettyServerCustomizerRegisteredAsBeanAndViaFactoryIsOnlyCalledOnce.
@Test
void jettyServerCustomizerRegisteredAsBeanAndViaFactoryIsOnlyCalledOnce() {
new ReactiveWebApplicationContextRunner(AnnotationConfigReactiveWebServerApplicationContext::new).withConfiguration(AutoConfigurations.of(ReactiveWebServerFactoryAutoConfiguration.class)).withClassLoader(new FilteredClassLoader(Tomcat.class, HttpServer.class)).withUserConfiguration(DoubleRegistrationJettyServerCustomizerConfiguration.class, HttpHandlerConfiguration.class).withPropertyValues("server.port=0").run((context) -> {
JettyReactiveWebServerFactory factory = context.getBean(JettyReactiveWebServerFactory.class);
JettyServerCustomizer customizer = context.getBean("serverCustomizer", JettyServerCustomizer.class);
assertThat(factory.getServerCustomizers()).contains(customizer);
then(customizer).should().customize(any(Server.class));
});
}
Aggregations