Search in sources :

Example 1 with UndertowDeploymentInfoCustomizer

use of org.springframework.boot.web.embedded.undertow.UndertowDeploymentInfoCustomizer in project joinfaces by joinfaces.

the class UndertowAutoConfigurationIT method customize.

@Test
public void customize() throws IOException {
    UndertowServletWebServerFactory factory = new UndertowServletWebServerFactory();
    this.undertowAutoConfiguration.jsfUndertowFactoryCustomizer().customize(factory);
    UndertowDeploymentInfoCustomizer undertowDeploymentInfoCustomizer = factory.getDeploymentInfoCustomizers().iterator().next();
    DeploymentInfo deploymentInfo = new DeploymentInfo();
    undertowDeploymentInfoCustomizer.customize(deploymentInfo);
    assertThat(deploymentInfo.getResourceManager().getResource("testUndertow.txt")).isNotNull();
}
Also used : UndertowServletWebServerFactory(org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo) UndertowDeploymentInfoCustomizer(org.springframework.boot.web.embedded.undertow.UndertowDeploymentInfoCustomizer) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 2 with UndertowDeploymentInfoCustomizer

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

the class ServletWebServerFactoryAutoConfigurationTests method undertowDeploymentInfoCustomizerRegisteredAsBeanAndViaFactoryIsOnlyCalledOnce.

@Test
void undertowDeploymentInfoCustomizerRegisteredAsBeanAndViaFactoryIsOnlyCalledOnce() {
    WebApplicationContextRunner runner = new WebApplicationContextRunner(AnnotationConfigServletWebServerApplicationContext::new).withClassLoader(new FilteredClassLoader(Tomcat.class, HttpServer.class, Server.class)).withConfiguration(AutoConfigurations.of(ServletWebServerFactoryAutoConfiguration.class)).withUserConfiguration(DoubleRegistrationUndertowDeploymentInfoCustomizerConfiguration.class).withPropertyValues("server.port: 0");
    runner.run((context) -> {
        UndertowServletWebServerFactory factory = context.getBean(UndertowServletWebServerFactory.class);
        UndertowDeploymentInfoCustomizer customizer = context.getBean("deploymentInfoCustomizer", UndertowDeploymentInfoCustomizer.class);
        assertThat(factory.getDeploymentInfoCustomizers()).contains(customizer);
        then(customizer).should().customize(any(DeploymentInfo.class));
    });
}
Also used : WebApplicationContextRunner(org.springframework.boot.test.context.runner.WebApplicationContextRunner) AnnotationConfigServletWebServerApplicationContext(org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext) UndertowServletWebServerFactory(org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo) UndertowDeploymentInfoCustomizer(org.springframework.boot.web.embedded.undertow.UndertowDeploymentInfoCustomizer) FilteredClassLoader(org.springframework.boot.test.context.FilteredClassLoader) Test(org.junit.jupiter.api.Test)

Aggregations

DeploymentInfo (io.undertow.servlet.api.DeploymentInfo)2 UndertowDeploymentInfoCustomizer (org.springframework.boot.web.embedded.undertow.UndertowDeploymentInfoCustomizer)2 UndertowServletWebServerFactory (org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory)2 Test (org.junit.Test)1 Test (org.junit.jupiter.api.Test)1 FilteredClassLoader (org.springframework.boot.test.context.FilteredClassLoader)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 WebApplicationContextRunner (org.springframework.boot.test.context.runner.WebApplicationContextRunner)1 AnnotationConfigServletWebServerApplicationContext (org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext)1