Search in sources :

Example 1 with UndertowServletWebServerFactory

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);
}
Also used : HashMap(java.util.HashMap) UndertowServletWebServerFactory(org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory) File(java.io.File) Test(org.junit.Test)

Example 2 with UndertowServletWebServerFactory

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());
}
Also used : UndertowServletWebServerFactory(org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory) Test(org.junit.Test)

Example 3 with UndertowServletWebServerFactory

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.");
}
Also used : AnnotationConfigServletWebServerApplicationContext(org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext) ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) TomcatServletWebServerFactory(org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory) ServletWebServerFactory(org.springframework.boot.web.servlet.server.ServletWebServerFactory) UndertowServletWebServerFactory(org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory) UndertowServletWebServerFactory(org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory) Test(org.junit.Test)

Example 4 with UndertowServletWebServerFactory

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;
}
Also used : UndertowServletWebServerFactory(org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory) Bean(org.springframework.context.annotation.Bean)

Example 5 with UndertowServletWebServerFactory

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();
}
Also used : UndertowServletWebServerFactory(org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory) Builder(io.undertow.Undertow.Builder) OptionMap(org.xnio.OptionMap) Test(org.junit.Test)

Aggregations

UndertowServletWebServerFactory (org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory)24 Test (org.junit.Test)21 Builder (io.undertow.Undertow.Builder)14 OptionMap (org.xnio.OptionMap)14 TomcatServletWebServerFactory (org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory)2 Bean (org.springframework.context.annotation.Bean)2 ConfigureListener (com.sun.faces.config.ConfigureListener)1 Undertow (io.undertow.Undertow)1 ClassPathResourceManager (io.undertow.server.handlers.resource.ClassPathResourceManager)1 DeploymentInfo (io.undertow.servlet.api.DeploymentInfo)1 File (java.io.File)1 URL (java.net.URL)1 URLClassLoader (java.net.URLClassLoader)1 AccessController (java.security.AccessController)1 PrivilegedAction (java.security.PrivilegedAction)1 HashMap (java.util.HashMap)1 RequiredArgsConstructor (lombok.RequiredArgsConstructor)1 Slf4j (lombok.extern.slf4j.Slf4j)1 ConditionalOnClass (org.springframework.boot.autoconfigure.condition.ConditionalOnClass)1 ConditionalOnWebApplication (org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication)1