use of org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory in project spring-boot by spring-projects.
the class DefaultServletWebServerFactoryCustomizerTests method customizeUndertowAccessLog.
@Test
public void customizeUndertowAccessLog() {
Map<String, String> map = new HashMap<>();
map.put("server.undertow.accesslog.enabled", "true");
map.put("server.undertow.accesslog.pattern", "foo");
map.put("server.undertow.accesslog.prefix", "test_log");
map.put("server.undertow.accesslog.suffix", "txt");
map.put("server.undertow.accesslog.dir", "test-logs");
map.put("server.undertow.accesslog.rotate", "false");
bindProperties(map);
UndertowServletWebServerFactory factory = spy(new UndertowServletWebServerFactory());
this.customizer.customize(factory);
verify(factory).setAccessLogEnabled(true);
verify(factory).setAccessLogPattern("foo");
verify(factory).setAccessLogPrefix("test_log");
verify(factory).setAccessLogSuffix("txt");
verify(factory).setAccessLogDirectory(new File("test-logs"));
verify(factory).setAccessLogRotate(false);
}
use of org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory in project spring-boot by spring-projects.
the class DefaultServletWebServerFactoryCustomizerTests method skipNullElementsForUndertow.
@Test
public void skipNullElementsForUndertow() throws Exception {
UndertowServletWebServerFactory factory = mock(UndertowServletWebServerFactory.class);
this.customizer.customize(factory);
verify(factory, never()).setAccessLogEnabled(anyBoolean());
}
use of org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory in project spring-boot by spring-projects.
the class EndpointWebMvcAutoConfigurationTests method undertowManagementAccessLogUsesCustomPrefix.
@Test
public void undertowManagementAccessLogUsesCustomPrefix() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext, "management.port=" + ports.get().management, "server.undertow.accesslog.enabled: true");
this.applicationContext.register(UndertowWebServerConfig.class, RootConfig.class, EndpointConfig.class, DifferentPortConfig.class, BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
this.applicationContext.refresh();
ApplicationContext managementContext = this.applicationContext.getBean(ManagementContextResolver.class).getApplicationContext();
ServletWebServerFactory factory = managementContext.getBean(ServletWebServerFactory.class);
assertThat(factory).isInstanceOf(UndertowServletWebServerFactory.class);
assertThat(((UndertowServletWebServerFactory) factory).getAccessLogPrefix()).isEqualTo("management_access_log.");
}
use of org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory in project zhcet-web by zhcet-amu.
the class Http2Config method undertowServletWebServerFactory.
@Bean
UndertowServletWebServerFactory undertowServletWebServerFactory() {
UndertowServletWebServerFactory factory = new UndertowServletWebServerFactory();
factory.addBuilderCustomizers(builder -> builder.setServerOption(UndertowOptions.ENABLE_HTTP2, true));
return factory;
}
use of org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory in project jhipster-sample-app-dto by jhipster.
the class WebConfigurerTest method testCustomizeServletContainer.
@Test
public void testCustomizeServletContainer() {
env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION);
UndertowServletWebServerFactory container = new UndertowServletWebServerFactory();
webConfigurer.customize(container);
assertThat(container.getMimeMappings().get("abs")).isEqualTo("audio/x-mpeg");
assertThat(container.getMimeMappings().get("html")).isEqualTo("text/html;charset=utf-8");
assertThat(container.getMimeMappings().get("json")).isEqualTo("text/html;charset=utf-8");
if (container.getDocumentRoot() != null) {
assertThat(container.getDocumentRoot().getPath()).isEqualTo(FilenameUtils.separatorsToSystem("target/www"));
}
Builder builder = Undertow.builder();
container.getBuilderCustomizers().forEach(c -> c.customize(builder));
OptionMap.Builder serverOptions = (OptionMap.Builder) ReflectionTestUtils.getField(builder, "serverOptions");
assertThat(serverOptions.getMap().get(UndertowOptions.ENABLE_HTTP2)).isNull();
}
Aggregations