Search in sources :

Example 6 with TomcatReactiveWebServerFactory

use of org.springframework.boot.web.embedded.tomcat.TomcatReactiveWebServerFactory in project spring-boot by spring-projects.

the class ReactiveWebServerFactoryAutoConfigurationTests method tomcatContextCustomizerBeanIsAddedToFactory.

@Test
void tomcatContextCustomizerBeanIsAddedToFactory() {
    ReactiveWebApplicationContextRunner runner = new ReactiveWebApplicationContextRunner(AnnotationConfigReactiveWebServerApplicationContext::new).withConfiguration(AutoConfigurations.of(ReactiveWebServerFactoryAutoConfiguration.class)).withUserConfiguration(HttpHandlerConfiguration.class, TomcatContextCustomizerConfiguration.class).withPropertyValues("server.port: 0");
    runner.run((context) -> {
        TomcatReactiveWebServerFactory factory = context.getBean(TomcatReactiveWebServerFactory.class);
        TomcatContextCustomizer customizer = context.getBean("contextCustomizer", TomcatContextCustomizer.class);
        assertThat(factory.getTomcatContextCustomizers()).contains(customizer);
        then(customizer).should().customize(any(Context.class));
    });
}
Also used : TomcatContextCustomizer(org.springframework.boot.web.embedded.tomcat.TomcatContextCustomizer) AnnotationConfigReactiveWebServerApplicationContext(org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext) AnnotationConfigReactiveWebApplicationContext(org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebApplicationContext) Context(org.apache.catalina.Context) TomcatReactiveWebServerFactory(org.springframework.boot.web.embedded.tomcat.TomcatReactiveWebServerFactory) ReactiveWebApplicationContextRunner(org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)6 ReactiveWebApplicationContextRunner (org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner)6 TomcatReactiveWebServerFactory (org.springframework.boot.web.embedded.tomcat.TomcatReactiveWebServerFactory)6 Context (org.apache.catalina.Context)2 Connector (org.apache.catalina.connector.Connector)2 TomcatConnectorCustomizer (org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer)2 TomcatContextCustomizer (org.springframework.boot.web.embedded.tomcat.TomcatContextCustomizer)2 AnnotationConfigReactiveWebApplicationContext (org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebApplicationContext)2 AnnotationConfigReactiveWebServerApplicationContext (org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext)2