Search in sources :

Example 1 with ConfigurableUndertowWebServerFactory

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

the class UndertowWebServerFactoryCustomizerTests method boundSocketOption.

private <T> T boundSocketOption(Option<T> option) {
    Builder builder = Undertow.builder();
    ConfigurableUndertowWebServerFactory factory = mockFactory(builder);
    this.customizer.customize(factory);
    OptionMap map = ((OptionMap.Builder) ReflectionTestUtils.getField(builder, "socketOptions")).getMap();
    return map.get(option);
}
Also used : Builder(io.undertow.Undertow.Builder) OptionMap(org.xnio.OptionMap) ConfigurableUndertowWebServerFactory(org.springframework.boot.web.embedded.undertow.ConfigurableUndertowWebServerFactory)

Example 2 with ConfigurableUndertowWebServerFactory

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

the class UndertowWebServerFactoryCustomizerTests method forwardHeadersWhenStrategyIsNativeShouldConfigureValve.

@Test
void forwardHeadersWhenStrategyIsNativeShouldConfigureValve() {
    this.serverProperties.setForwardHeadersStrategy(ServerProperties.ForwardHeadersStrategy.NATIVE);
    ConfigurableUndertowWebServerFactory factory = mock(ConfigurableUndertowWebServerFactory.class);
    this.customizer.customize(factory);
    then(factory).should().setUseForwardHeaders(true);
}
Also used : ConfigurableUndertowWebServerFactory(org.springframework.boot.web.embedded.undertow.ConfigurableUndertowWebServerFactory) Test(org.junit.jupiter.api.Test)

Example 3 with ConfigurableUndertowWebServerFactory

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

the class UndertowWebServerFactoryCustomizerTests method boundServerOption.

private <T> T boundServerOption(Option<T> option) {
    Builder builder = Undertow.builder();
    ConfigurableUndertowWebServerFactory factory = mockFactory(builder);
    this.customizer.customize(factory);
    OptionMap map = ((OptionMap.Builder) ReflectionTestUtils.getField(builder, "serverOptions")).getMap();
    return map.get(option);
}
Also used : Builder(io.undertow.Undertow.Builder) OptionMap(org.xnio.OptionMap) ConfigurableUndertowWebServerFactory(org.springframework.boot.web.embedded.undertow.ConfigurableUndertowWebServerFactory)

Example 4 with ConfigurableUndertowWebServerFactory

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

the class UndertowWebServerFactoryCustomizerTests method mockFactory.

private ConfigurableUndertowWebServerFactory mockFactory(Builder builder) {
    ConfigurableUndertowWebServerFactory factory = mock(ConfigurableUndertowWebServerFactory.class);
    willAnswer((invocation) -> {
        Object argument = invocation.getArgument(0);
        Arrays.stream((argument instanceof UndertowBuilderCustomizer) ? new UndertowBuilderCustomizer[] { (UndertowBuilderCustomizer) argument } : (UndertowBuilderCustomizer[]) argument).forEach((customizer) -> customizer.customize(builder));
        return null;
    }).given(factory).addBuilderCustomizers(any());
    return factory;
}
Also used : UndertowBuilderCustomizer(org.springframework.boot.web.embedded.undertow.UndertowBuilderCustomizer) ConfigurableUndertowWebServerFactory(org.springframework.boot.web.embedded.undertow.ConfigurableUndertowWebServerFactory)

Example 5 with ConfigurableUndertowWebServerFactory

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

the class UndertowWebServerFactoryCustomizerTests method customizeUndertowAccessLog.

@Test
void customizeUndertowAccessLog() {
    bind("server.undertow.accesslog.enabled=true", "server.undertow.accesslog.pattern=foo", "server.undertow.accesslog.prefix=test_log", "server.undertow.accesslog.suffix=txt", "server.undertow.accesslog.dir=test-logs", "server.undertow.accesslog.rotate=false");
    ConfigurableUndertowWebServerFactory factory = mock(ConfigurableUndertowWebServerFactory.class);
    this.customizer.customize(factory);
    then(factory).should().setAccessLogEnabled(true);
    then(factory).should().setAccessLogPattern("foo");
    then(factory).should().setAccessLogPrefix("test_log");
    then(factory).should().setAccessLogSuffix("txt");
    then(factory).should().setAccessLogDirectory(new File("test-logs"));
    then(factory).should().setAccessLogRotate(false);
}
Also used : ConfigurableUndertowWebServerFactory(org.springframework.boot.web.embedded.undertow.ConfigurableUndertowWebServerFactory) File(java.io.File) Test(org.junit.jupiter.api.Test)

Aggregations

ConfigurableUndertowWebServerFactory (org.springframework.boot.web.embedded.undertow.ConfigurableUndertowWebServerFactory)10 Test (org.junit.jupiter.api.Test)7 Builder (io.undertow.Undertow.Builder)2 OptionMap (org.xnio.OptionMap)2 File (java.io.File)1 UndertowBuilderCustomizer (org.springframework.boot.web.embedded.undertow.UndertowBuilderCustomizer)1