use of org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory in project spring-boot by spring-projects.
the class ServletWebServerFactoryAutoConfigurationTests method tomcatProtocolHandlerCustomizerRegisteredAsBeanAndViaFactoryIsOnlyCalledOnce.
@Test
void tomcatProtocolHandlerCustomizerRegisteredAsBeanAndViaFactoryIsOnlyCalledOnce() {
WebApplicationContextRunner runner = new WebApplicationContextRunner(AnnotationConfigServletWebServerApplicationContext::new).withConfiguration(AutoConfigurations.of(ServletWebServerFactoryAutoConfiguration.class)).withUserConfiguration(DoubleRegistrationTomcatProtocolHandlerCustomizerConfiguration.class).withPropertyValues("server.port: 0");
runner.run((context) -> {
TomcatServletWebServerFactory factory = context.getBean(TomcatServletWebServerFactory.class);
TomcatProtocolHandlerCustomizer<?> customizer = context.getBean("protocolHandlerCustomizer", TomcatProtocolHandlerCustomizer.class);
assertThat(factory.getTomcatProtocolHandlerCustomizers()).contains(customizer);
then(customizer).should().customize(any());
});
}
use of org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory in project spring-boot by spring-projects.
the class ServletWebServerFactoryAutoConfigurationTests method tomcatContextCustomizerRegisteredAsBeanAndViaFactoryIsOnlyCalledOnce.
@Test
void tomcatContextCustomizerRegisteredAsBeanAndViaFactoryIsOnlyCalledOnce() {
WebApplicationContextRunner runner = new WebApplicationContextRunner(AnnotationConfigServletWebServerApplicationContext::new).withConfiguration(AutoConfigurations.of(ServletWebServerFactoryAutoConfiguration.class)).withUserConfiguration(DoubleRegistrationTomcatContextCustomizerConfiguration.class).withPropertyValues("server.port: 0");
runner.run((context) -> {
TomcatServletWebServerFactory factory = context.getBean(TomcatServletWebServerFactory.class);
TomcatContextCustomizer customizer = context.getBean("contextCustomizer", TomcatContextCustomizer.class);
assertThat(factory.getTomcatContextCustomizers()).contains(customizer);
then(customizer).should().customize(any(Context.class));
});
}
use of org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory 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));
});
}
use of org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory in project spring-boot by spring-projects.
the class MyCloudFoundryConfiguration method servletWebServerFactory.
@Bean
public TomcatServletWebServerFactory servletWebServerFactory() {
return new TomcatServletWebServerFactory() {
@Override
protected void prepareContext(Host host, ServletContextInitializer[] initializers) {
super.prepareContext(host, initializers);
StandardContext child = new StandardContext();
child.addLifecycleListener(new Tomcat.FixContextListener());
child.setPath("/cloudfoundryapplication");
ServletContainerInitializer initializer = getServletContextInitializer(getContextPath());
child.addServletContainerInitializer(initializer, Collections.emptySet());
child.setCrossContext(true);
host.addChild(child);
}
};
}
use of org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory in project spring-boot by spring-projects.
the class SampleTomcatTwoConnectorsApplication method servletContainer.
@Bean
public ServletWebServerFactory servletContainer() {
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
tomcat.addAdditionalTomcatConnectors(createStandardConnector());
return tomcat;
}
Aggregations