Search in sources :

Example 1 with JettyServerCustomizer

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));
    });
}
Also used : JettyServerCustomizer(org.springframework.boot.web.embedded.jetty.JettyServerCustomizer) WebApplicationContextRunner(org.springframework.boot.test.context.runner.WebApplicationContextRunner) Server(org.eclipse.jetty.server.Server) HttpServer(reactor.netty.http.server.HttpServer) AnnotationConfigServletWebServerApplicationContext(org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext) JettyServletWebServerFactory(org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory) FilteredClassLoader(org.springframework.boot.test.context.FilteredClassLoader) Test(org.junit.jupiter.api.Test)

Example 2 with JettyServerCustomizer

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));
    });
}
Also used : JettyServerCustomizer(org.springframework.boot.web.embedded.jetty.JettyServerCustomizer) JettyReactiveWebServerFactory(org.springframework.boot.web.embedded.jetty.JettyReactiveWebServerFactory) Server(org.eclipse.jetty.server.Server) HttpServer(reactor.netty.http.server.HttpServer) ReactiveWebApplicationContextRunner(org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner) FilteredClassLoader(org.springframework.boot.test.context.FilteredClassLoader) Test(org.junit.jupiter.api.Test)

Aggregations

Server (org.eclipse.jetty.server.Server)2 Test (org.junit.jupiter.api.Test)2 FilteredClassLoader (org.springframework.boot.test.context.FilteredClassLoader)2 JettyServerCustomizer (org.springframework.boot.web.embedded.jetty.JettyServerCustomizer)2 HttpServer (reactor.netty.http.server.HttpServer)2 ReactiveWebApplicationContextRunner (org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner)1 WebApplicationContextRunner (org.springframework.boot.test.context.runner.WebApplicationContextRunner)1 JettyReactiveWebServerFactory (org.springframework.boot.web.embedded.jetty.JettyReactiveWebServerFactory)1 JettyServletWebServerFactory (org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory)1 AnnotationConfigServletWebServerApplicationContext (org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext)1