Search in sources :

Example 1 with JettyReactiveWebServerFactory

use of org.springframework.boot.web.embedded.jetty.JettyReactiveWebServerFactory 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);
    });
}
Also used : Tomcat(org.apache.catalina.startup.Tomcat) JettyReactiveWebServerFactory(org.springframework.boot.web.embedded.jetty.JettyReactiveWebServerFactory) HttpServer(reactor.netty.http.server.HttpServer) ReactiveWebApplicationContextRunner(org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner) AnnotationConfigReactiveWebApplicationContext(org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebApplicationContext) FilteredClassLoader(org.springframework.boot.test.context.FilteredClassLoader) Test(org.junit.jupiter.api.Test)

Example 2 with JettyReactiveWebServerFactory

use of org.springframework.boot.web.embedded.jetty.JettyReactiveWebServerFactory 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

Test (org.junit.jupiter.api.Test)2 FilteredClassLoader (org.springframework.boot.test.context.FilteredClassLoader)2 ReactiveWebApplicationContextRunner (org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner)2 JettyReactiveWebServerFactory (org.springframework.boot.web.embedded.jetty.JettyReactiveWebServerFactory)2 HttpServer (reactor.netty.http.server.HttpServer)2 Tomcat (org.apache.catalina.startup.Tomcat)1 Server (org.eclipse.jetty.server.Server)1 JettyServerCustomizer (org.springframework.boot.web.embedded.jetty.JettyServerCustomizer)1 AnnotationConfigReactiveWebApplicationContext (org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebApplicationContext)1