Search in sources :

Example 16 with UndertowEmbeddedServletContainerFactory

use of org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory in project hello-world by haoziapple.

the class WebConfigurerTest method testCustomizeServletContainerNotProd.

@Test
public void testCustomizeServletContainerNotProd() {
    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");
    assertThat(container.getDocumentRoot().getPath()).isEqualTo(FilenameUtils.separatorsToSystem("src/main/webapp"));
    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 17 with UndertowEmbeddedServletContainerFactory

use of org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory in project FuryViewer by TheDoctor-95.

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("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 : UndertowEmbeddedServletContainerFactory(org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory) Builder(io.undertow.Undertow.Builder) OptionMap(org.xnio.OptionMap) Test(org.junit.Test)

Example 18 with UndertowEmbeddedServletContainerFactory

use of org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory in project FuryViewer by TheDoctor-95.

the class WebConfigurerTest 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 19 with UndertowEmbeddedServletContainerFactory

use of org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory in project spring-boot by Linda-Tan.

the class HelloWorldApplication method embeddedServletContainerFactory.

// @Bean
// public ServerEndpointExporter serverEndpointExporter(){
// return new ServerEndpointExporter();
// }
// @Bean
// public AccessFilter accessFilter(){
// return new AccessFilter();
// }
@Bean
public UndertowEmbeddedServletContainerFactory embeddedServletContainerFactory() {
    UndertowEmbeddedServletContainerFactory undertow = new UndertowEmbeddedServletContainerFactory();
    undertow.addBuilderCustomizers((Builder builder) -> {
        builder.addHttpListener(8762, "0.0.0.0");
    });
    // log.info("\n*** Undertow http setting successful." + properties.getPort());
    return undertow;
}
Also used : UndertowEmbeddedServletContainerFactory(org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory) Builder(io.undertow.Undertow.Builder) Bean(org.springframework.context.annotation.Bean)

Example 20 with UndertowEmbeddedServletContainerFactory

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

the class WebConfigurerTest 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)

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