use of org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory in project spring-boot by spring-projects.
the class EndpointWebMvcAutoConfigurationTests method tomcatManagementAccessLogUsesCustomPrefix.
@Test
public void tomcatManagementAccessLogUsesCustomPrefix() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext, "management.port=" + ports.get().management);
this.applicationContext.register(TomcatWebServerConfig.class, RootConfig.class, EndpointConfig.class, DifferentPortConfig.class, BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.applicationContext, "server.tomcat.accesslog.enabled: true");
this.applicationContext.refresh();
ApplicationContext managementContext = this.applicationContext.getBean(ManagementContextResolver.class).getApplicationContext();
ServletWebServerFactory factory = managementContext.getBean(ServletWebServerFactory.class);
assertThat(factory).isInstanceOf(TomcatServletWebServerFactory.class);
AccessLogValve accessLogValve = findAccessLogValve(((TomcatServletWebServerFactory) factory));
assertThat(accessLogValve).isNotNull();
assertThat(accessLogValve.getPrefix()).isEqualTo("management_access_log");
}
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;
}
use of org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory in project spring-boot by spring-projects.
the class DefaultServletWebServerFactoryCustomizerTests method customTomcatAcceptCount.
@Test
public void customTomcatAcceptCount() {
Map<String, String> map = new HashMap<>();
map.put("server.tomcat.accept-count", "10");
bindProperties(map);
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
this.customizer.customize(factory);
TomcatWebServer embeddedFactory = (TomcatWebServer) factory.getWebServer();
embeddedFactory.start();
try {
assertThat(((AbstractProtocol<?>) embeddedFactory.getTomcat().getConnector().getProtocolHandler()).getBacklog()).isEqualTo(10);
} finally {
embeddedFactory.stop();
}
}
use of org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory in project spring-boot by spring-projects.
the class DefaultServletWebServerFactoryCustomizerTests method tomcatAccessLogCanBeEnabled.
@Test
public void tomcatAccessLogCanBeEnabled() {
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
Map<String, String> map = new HashMap<>();
map.put("server.tomcat.accesslog.enabled", "true");
bindProperties(map);
this.customizer.customize(factory);
assertThat(factory.getEngineValves()).hasSize(1);
assertThat(factory.getEngineValves()).first().isInstanceOf(AccessLogValve.class);
}
use of org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory in project spring-boot by spring-projects.
the class DefaultServletWebServerFactoryCustomizerTests method tomcatAccessLogBufferingCanBeDisabled.
@Test
public void tomcatAccessLogBufferingCanBeDisabled() {
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
Map<String, String> map = new HashMap<>();
map.put("server.tomcat.accesslog.enabled", "true");
map.put("server.tomcat.accesslog.buffered", "false");
bindProperties(map);
this.customizer.customize(factory);
assertThat(((AccessLogValve) factory.getEngineValves().iterator().next()).isBuffered()).isFalse();
}
Aggregations