Search in sources :

Example 6 with UndertowEmbeddedServletContainerFactory

use of org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory in project cetc by DiscoverForever.

the class WebConfigurerTest method testCustomizeServletContainer.

@Test
public void testCustomizeServletContainer() {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION);
    UndertowEmbeddedServletContainerFactory container = new UndertowEmbeddedServletContainerFactory();
    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("build/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 : UndertowEmbeddedServletContainerFactory(org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory) Builder(io.undertow.Undertow.Builder) OptionMap(org.xnio.OptionMap) Test(org.junit.Test)

Example 7 with UndertowEmbeddedServletContainerFactory

use of org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory in project xm-ms-entity by xm-online.

the class WebConfigurer method customize.

/**
 * Customize the Servlet engine: Mime types, the document root, the cache.
 */
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
    MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
    // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711
    mappings.add("html", "text/html;charset=utf-8");
    // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64
    mappings.add("json", "text/html;charset=utf-8");
    container.setMimeMappings(mappings);
    /*
         * Enable HTTP/2 for Undertow - https://twitter.com/ankinson/status/829256167700492288
         * HTTP/2 requires HTTPS, so HTTP requests will fallback to HTTP/1.1.
         * See the JHipsterProperties class and your application-*.yml configuration files
         * for more information.
         */
    if (jHipsterProperties.getHttp().getVersion().equals(JHipsterProperties.Http.Version.V_2_0) && container instanceof UndertowEmbeddedServletContainerFactory) {
        ((UndertowEmbeddedServletContainerFactory) container).addBuilderCustomizers(builder -> builder.setServerOption(UndertowOptions.ENABLE_HTTP2, true));
    }
}
Also used : UndertowEmbeddedServletContainerFactory(org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory) MimeMappings(org.springframework.boot.context.embedded.MimeMappings)

Example 8 with UndertowEmbeddedServletContainerFactory

use of org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory in project xm-ms-entity by xm-online.

the class WebConfigurerIntTest method testUndertowHttp2Enabled.

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

Example 9 with UndertowEmbeddedServletContainerFactory

use of org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory in project xm-ms-entity by xm-online.

the class WebConfigurerIntTest method testCustomizeServletContainer.

@Test
public void testCustomizeServletContainer() {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION);
    UndertowEmbeddedServletContainerFactory container = new UndertowEmbeddedServletContainerFactory();
    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");
    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 : UndertowEmbeddedServletContainerFactory(org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory) Builder(io.undertow.Undertow.Builder) OptionMap(org.xnio.OptionMap) Test(org.junit.Test)

Example 10 with UndertowEmbeddedServletContainerFactory

use of org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory in project ArTEMiS by ls1intum.

the class WebConfigurerTest method testCustomizeServletContainer.

@Test
public void testCustomizeServletContainer() {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION);
    UndertowEmbeddedServletContainerFactory container = new UndertowEmbeddedServletContainerFactory();
    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("build/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 : UndertowEmbeddedServletContainerFactory(org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory) Builder(io.undertow.Undertow.Builder) OptionMap(org.xnio.OptionMap) Test(org.junit.Test)

Aggregations

UndertowEmbeddedServletContainerFactory (org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory)22 Builder (io.undertow.Undertow.Builder)16 Test (org.junit.Test)14 OptionMap (org.xnio.OptionMap)14 Bean (org.springframework.context.annotation.Bean)5 MimeMappings (org.springframework.boot.context.embedded.MimeMappings)3 UndertowBuilderCustomizer (org.springframework.boot.context.embedded.undertow.UndertowBuilderCustomizer)2 Undertow (io.undertow.Undertow)1 DeploymentInfo (io.undertow.servlet.api.DeploymentInfo)1 CertificateException (java.security.cert.CertificateException)1 AbstractEmbeddedServletContainerFactory (org.springframework.boot.context.embedded.AbstractEmbeddedServletContainerFactory)1 JettyEmbeddedServletContainerFactory (org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory)1 TomcatEmbeddedServletContainerFactory (org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory)1 UndertowDeploymentInfoCustomizer (org.springframework.boot.context.embedded.undertow.UndertowDeploymentInfoCustomizer)1