Search in sources :

Example 6 with UndertowServletWebServerFactory

use of org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory in project jhipster-sample-app-hazelcast by jhipster.

the class WebConfigurerTest method testUndertowHttp2Enabled.

@Test
public void testUndertowHttp2Enabled() {
    props.getHttp().setVersion(JHipsterProperties.Http.Version.V_2_0);
    UndertowServletWebServerFactory container = new UndertowServletWebServerFactory();
    webConfigurer.customize(container);
    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)).isTrue();
}
Also used : UndertowServletWebServerFactory(org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory) Builder(io.undertow.Undertow.Builder) OptionMap(org.xnio.OptionMap) Test(org.junit.Test)

Example 7 with UndertowServletWebServerFactory

use of org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory in project jhipster-sample-app-elasticsearch by jhipster.

the class WebConfigurerTest method testUndertowHttp2Enabled.

@Test
public void testUndertowHttp2Enabled() {
    props.getHttp().setVersion(JHipsterProperties.Http.Version.V_2_0);
    UndertowServletWebServerFactory container = new UndertowServletWebServerFactory();
    webConfigurer.customize(container);
    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)).isTrue();
}
Also used : UndertowServletWebServerFactory(org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory) Builder(io.undertow.Undertow.Builder) OptionMap(org.xnio.OptionMap) Test(org.junit.Test)

Example 8 with UndertowServletWebServerFactory

use of org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory in project jhipster-sample-app-elasticsearch 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)

Example 9 with UndertowServletWebServerFactory

use of org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory in project spring-boot by spring-projects.

the class DefaultServletWebServerFactoryCustomizer method customize.

@Override
public void customize(ConfigurableServletWebServerFactory factory) {
    if (this.serverProperties.getPort() != null) {
        factory.setPort(this.serverProperties.getPort());
    }
    if (this.serverProperties.getAddress() != null) {
        factory.setAddress(this.serverProperties.getAddress());
    }
    if (this.serverProperties.getServlet().getContextPath() != null) {
        factory.setContextPath(this.serverProperties.getServlet().getContextPath());
    }
    if (this.serverProperties.getDisplayName() != null) {
        factory.setDisplayName(this.serverProperties.getDisplayName());
    }
    if (this.serverProperties.getSession().getTimeout() != null) {
        factory.setSessionTimeout(this.serverProperties.getSession().getTimeout());
    }
    factory.setPersistSession(this.serverProperties.getSession().isPersistent());
    factory.setSessionStoreDir(this.serverProperties.getSession().getStoreDir());
    if (this.serverProperties.getSsl() != null) {
        factory.setSsl(this.serverProperties.getSsl());
    }
    if (this.serverProperties.getServlet() != null) {
        factory.setJsp(this.serverProperties.getServlet().getJsp());
    }
    if (this.serverProperties.getCompression() != null) {
        factory.setCompression(this.serverProperties.getCompression());
    }
    factory.setServerHeader(this.serverProperties.getServerHeader());
    if (factory instanceof TomcatServletWebServerFactory) {
        TomcatCustomizer.customizeTomcat(this.serverProperties, this.environment, (TomcatServletWebServerFactory) factory);
    }
    if (factory instanceof JettyServletWebServerFactory) {
        JettyCustomizer.customizeJetty(this.serverProperties, this.environment, (JettyServletWebServerFactory) factory);
    }
    if (factory instanceof UndertowServletWebServerFactory) {
        UndertowCustomizer.customizeUndertow(this.serverProperties, this.environment, (UndertowServletWebServerFactory) factory);
    }
    factory.addInitializers(new SessionConfiguringInitializer(this.serverProperties.getSession()));
    factory.addInitializers(new InitParameterConfiguringServletContextInitializer(this.serverProperties.getServlet().getContextParameters()));
}
Also used : TomcatServletWebServerFactory(org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory) JettyServletWebServerFactory(org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory) UndertowServletWebServerFactory(org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory) InitParameterConfiguringServletContextInitializer(org.springframework.boot.web.servlet.server.InitParameterConfiguringServletContextInitializer)

Example 10 with UndertowServletWebServerFactory

use of org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory in project spring-boot by spring-projects.

the class DefaultServletWebServerFactoryCustomizerTests method defaultUseForwardHeadersUndertow.

@Test
public void defaultUseForwardHeadersUndertow() throws Exception {
    UndertowServletWebServerFactory factory = spy(new UndertowServletWebServerFactory());
    this.customizer.customize(factory);
    verify(factory).setUseForwardHeaders(false);
}
Also used : UndertowServletWebServerFactory(org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory) 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