Search in sources :

Example 1 with UndertowReactiveWebServerFactory

use of org.springframework.boot.web.embedded.undertow.UndertowReactiveWebServerFactory in project spring-boot by spring-projects.

the class ReactiveWebServerFactoryAutoConfigurationTests method undertowBuilderCustomizerRegisteredAsBeanAndViaFactoryIsOnlyCalledOnce.

@Test
void undertowBuilderCustomizerRegisteredAsBeanAndViaFactoryIsOnlyCalledOnce() {
    new ReactiveWebApplicationContextRunner(AnnotationConfigReactiveWebServerApplicationContext::new).withConfiguration(AutoConfigurations.of(ReactiveWebServerFactoryAutoConfiguration.class)).withClassLoader(new FilteredClassLoader(Tomcat.class, HttpServer.class, Server.class)).withUserConfiguration(DoubleRegistrationUndertowBuilderCustomizerConfiguration.class, HttpHandlerConfiguration.class).withPropertyValues("server.port: 0").run((context) -> {
        UndertowReactiveWebServerFactory factory = context.getBean(UndertowReactiveWebServerFactory.class);
        UndertowBuilderCustomizer customizer = context.getBean("builderCustomizer", UndertowBuilderCustomizer.class);
        assertThat(factory.getBuilderCustomizers()).contains(customizer);
        then(customizer).should().customize(any(Builder.class));
    });
}
Also used : UndertowBuilderCustomizer(org.springframework.boot.web.embedded.undertow.UndertowBuilderCustomizer) Builder(io.undertow.Undertow.Builder) UndertowReactiveWebServerFactory(org.springframework.boot.web.embedded.undertow.UndertowReactiveWebServerFactory) ReactiveWebApplicationContextRunner(org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner) FilteredClassLoader(org.springframework.boot.test.context.FilteredClassLoader) Test(org.junit.jupiter.api.Test)

Example 2 with UndertowReactiveWebServerFactory

use of org.springframework.boot.web.embedded.undertow.UndertowReactiveWebServerFactory 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);
    });
}
Also used : Tomcat(org.apache.catalina.startup.Tomcat) Server(org.eclipse.jetty.server.Server) HttpServer(reactor.netty.http.server.HttpServer) HttpServer(reactor.netty.http.server.HttpServer) UndertowReactiveWebServerFactory(org.springframework.boot.web.embedded.undertow.UndertowReactiveWebServerFactory) 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)

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 UndertowReactiveWebServerFactory (org.springframework.boot.web.embedded.undertow.UndertowReactiveWebServerFactory)2 Builder (io.undertow.Undertow.Builder)1 Tomcat (org.apache.catalina.startup.Tomcat)1 Server (org.eclipse.jetty.server.Server)1 UndertowBuilderCustomizer (org.springframework.boot.web.embedded.undertow.UndertowBuilderCustomizer)1 AnnotationConfigReactiveWebApplicationContext (org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebApplicationContext)1 HttpServer (reactor.netty.http.server.HttpServer)1