Search in sources :

Example 31 with FilteredClassLoader

use of org.springframework.boot.test.context.FilteredClassLoader 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

FilteredClassLoader (org.springframework.boot.test.context.FilteredClassLoader)31 Test (org.junit.jupiter.api.Test)27 WebApplicationContextRunner (org.springframework.boot.test.context.runner.WebApplicationContextRunner)8 AnnotationConfigServletWebServerApplicationContext (org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext)7 ReactiveWebApplicationContextRunner (org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner)6 HttpServer (reactor.netty.http.server.HttpServer)6 Tomcat (org.apache.catalina.startup.Tomcat)4 Server (org.eclipse.jetty.server.Server)4 UndertowServletWebServerFactory (org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory)4 AnnotationConfigReactiveWebApplicationContext (org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebApplicationContext)3 Builder (io.undertow.Undertow.Builder)2 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)2 JettyReactiveWebServerFactory (org.springframework.boot.web.embedded.jetty.JettyReactiveWebServerFactory)2 JettyServerCustomizer (org.springframework.boot.web.embedded.jetty.JettyServerCustomizer)2 JettyServletWebServerFactory (org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory)2 NettyReactiveWebServerFactory (org.springframework.boot.web.embedded.netty.NettyReactiveWebServerFactory)2 UndertowBuilderCustomizer (org.springframework.boot.web.embedded.undertow.UndertowBuilderCustomizer)2 UndertowReactiveWebServerFactory (org.springframework.boot.web.embedded.undertow.UndertowReactiveWebServerFactory)2 Gson (com.google.gson.Gson)1 Config (com.hazelcast.config.Config)1