Search in sources :

Example 1 with TomcatConnectorCustomizer

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

the class ServletWebServerFactoryAutoConfigurationTests method tomcatConnectorCustomizerBeanIsAddedToFactory.

@Test
void tomcatConnectorCustomizerBeanIsAddedToFactory() {
    WebApplicationContextRunner runner = new WebApplicationContextRunner(AnnotationConfigServletWebServerApplicationContext::new).withConfiguration(AutoConfigurations.of(ServletWebServerFactoryAutoConfiguration.class)).withUserConfiguration(TomcatConnectorCustomizerConfiguration.class).withPropertyValues("server.port: 0");
    runner.run((context) -> {
        TomcatServletWebServerFactory factory = context.getBean(TomcatServletWebServerFactory.class);
        TomcatConnectorCustomizer customizer = context.getBean("connectorCustomizer", TomcatConnectorCustomizer.class);
        assertThat(factory.getTomcatConnectorCustomizers()).contains(customizer);
        then(customizer).should().customize(any(Connector.class));
    });
}
Also used : Connector(org.apache.catalina.connector.Connector) WebApplicationContextRunner(org.springframework.boot.test.context.runner.WebApplicationContextRunner) TomcatServletWebServerFactory(org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory) TomcatConnectorCustomizer(org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer) Test(org.junit.jupiter.api.Test)

Example 2 with TomcatConnectorCustomizer

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

the class ReactiveWebServerFactoryAutoConfigurationTests method tomcatConnectorCustomizerRegisteredAsBeanAndViaFactoryIsOnlyCalledOnce.

@Test
void tomcatConnectorCustomizerRegisteredAsBeanAndViaFactoryIsOnlyCalledOnce() {
    ReactiveWebApplicationContextRunner runner = new ReactiveWebApplicationContextRunner(AnnotationConfigReactiveWebServerApplicationContext::new).withConfiguration(AutoConfigurations.of(ReactiveWebServerFactoryAutoConfiguration.class)).withUserConfiguration(HttpHandlerConfiguration.class, DoubleRegistrationTomcatConnectorCustomizerConfiguration.class).withPropertyValues("server.port: 0");
    runner.run((context) -> {
        TomcatReactiveWebServerFactory factory = context.getBean(TomcatReactiveWebServerFactory.class);
        TomcatConnectorCustomizer customizer = context.getBean("connectorCustomizer", TomcatConnectorCustomizer.class);
        assertThat(factory.getTomcatConnectorCustomizers()).contains(customizer);
        then(customizer).should().customize(any(Connector.class));
    });
}
Also used : Connector(org.apache.catalina.connector.Connector) TomcatReactiveWebServerFactory(org.springframework.boot.web.embedded.tomcat.TomcatReactiveWebServerFactory) TomcatConnectorCustomizer(org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer) ReactiveWebApplicationContextRunner(org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner) Test(org.junit.jupiter.api.Test)

Example 3 with TomcatConnectorCustomizer

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

the class ReactiveWebServerFactoryAutoConfigurationTests method tomcatConnectorCustomizerBeanIsAddedToFactory.

@Test
void tomcatConnectorCustomizerBeanIsAddedToFactory() {
    ReactiveWebApplicationContextRunner runner = new ReactiveWebApplicationContextRunner(AnnotationConfigReactiveWebServerApplicationContext::new).withConfiguration(AutoConfigurations.of(ReactiveWebServerFactoryAutoConfiguration.class)).withUserConfiguration(HttpHandlerConfiguration.class, TomcatConnectorCustomizerConfiguration.class).withPropertyValues("server.port: 0");
    runner.run((context) -> {
        TomcatReactiveWebServerFactory factory = context.getBean(TomcatReactiveWebServerFactory.class);
        TomcatConnectorCustomizer customizer = context.getBean("connectorCustomizer", TomcatConnectorCustomizer.class);
        assertThat(factory.getTomcatConnectorCustomizers()).contains(customizer);
        then(customizer).should().customize(any(Connector.class));
    });
}
Also used : Connector(org.apache.catalina.connector.Connector) TomcatReactiveWebServerFactory(org.springframework.boot.web.embedded.tomcat.TomcatReactiveWebServerFactory) TomcatConnectorCustomizer(org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer) ReactiveWebApplicationContextRunner(org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner) Test(org.junit.jupiter.api.Test)

Example 4 with TomcatConnectorCustomizer

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

the class ServletWebServerFactoryAutoConfigurationTests method tomcatConnectorCustomizerRegisteredAsBeanAndViaFactoryIsOnlyCalledOnce.

@Test
void tomcatConnectorCustomizerRegisteredAsBeanAndViaFactoryIsOnlyCalledOnce() {
    WebApplicationContextRunner runner = new WebApplicationContextRunner(AnnotationConfigServletWebServerApplicationContext::new).withConfiguration(AutoConfigurations.of(ServletWebServerFactoryAutoConfiguration.class)).withUserConfiguration(DoubleRegistrationTomcatConnectorCustomizerConfiguration.class).withPropertyValues("server.port: 0");
    runner.run((context) -> {
        TomcatServletWebServerFactory factory = context.getBean(TomcatServletWebServerFactory.class);
        TomcatConnectorCustomizer customizer = context.getBean("connectorCustomizer", TomcatConnectorCustomizer.class);
        assertThat(factory.getTomcatConnectorCustomizers()).contains(customizer);
        then(customizer).should().customize(any(Connector.class));
    });
}
Also used : Connector(org.apache.catalina.connector.Connector) WebApplicationContextRunner(org.springframework.boot.test.context.runner.WebApplicationContextRunner) TomcatServletWebServerFactory(org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory) TomcatConnectorCustomizer(org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer) Test(org.junit.jupiter.api.Test)

Aggregations

Connector (org.apache.catalina.connector.Connector)4 Test (org.junit.jupiter.api.Test)4 TomcatConnectorCustomizer (org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer)4 ReactiveWebApplicationContextRunner (org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner)2 WebApplicationContextRunner (org.springframework.boot.test.context.runner.WebApplicationContextRunner)2 TomcatReactiveWebServerFactory (org.springframework.boot.web.embedded.tomcat.TomcatReactiveWebServerFactory)2 TomcatServletWebServerFactory (org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory)2