|
|
|
@ -16,16 +16,17 @@
|
|
|
|
|
|
|
|
|
|
package org.springframework.boot.autoconfigure.web.reactive;
|
|
|
|
|
|
|
|
|
|
import org.apache.catalina.startup.Tomcat;
|
|
|
|
|
import org.eclipse.jetty.server.Server;
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
import org.mockito.Mockito;
|
|
|
|
|
import reactor.netty.http.server.HttpServer;
|
|
|
|
|
|
|
|
|
|
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
|
|
|
|
import org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration;
|
|
|
|
|
import org.springframework.boot.test.context.FilteredClassLoader;
|
|
|
|
|
import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner;
|
|
|
|
|
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
|
|
|
|
|
import org.springframework.boot.web.embedded.jetty.JettyReactiveWebServerFactory;
|
|
|
|
|
import org.springframework.boot.web.embedded.jetty.JettyServerCustomizer;
|
|
|
|
|
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
|
|
|
|
|
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
|
|
|
|
|
import org.springframework.boot.web.embedded.tomcat.TomcatContextCustomizer;
|
|
|
|
|
import org.springframework.boot.web.embedded.tomcat.TomcatProtocolHandlerCustomizer;
|
|
|
|
@ -33,13 +34,11 @@ import org.springframework.boot.web.embedded.tomcat.TomcatReactiveWebServerFacto
|
|
|
|
|
import org.springframework.boot.web.embedded.undertow.UndertowBuilderCustomizer;
|
|
|
|
|
import org.springframework.boot.web.embedded.undertow.UndertowDeploymentInfoCustomizer;
|
|
|
|
|
import org.springframework.boot.web.embedded.undertow.UndertowReactiveWebServerFactory;
|
|
|
|
|
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
|
|
|
|
|
import org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebApplicationContext;
|
|
|
|
|
import org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext;
|
|
|
|
|
import org.springframework.boot.web.reactive.server.ConfigurableReactiveWebServerFactory;
|
|
|
|
|
import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory;
|
|
|
|
|
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
|
|
|
|
|
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
|
|
|
|
|
import org.springframework.context.ApplicationContextException;
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
@ -161,44 +160,55 @@ public class ReactiveWebServerFactoryAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void jettyServerCustomizerBeanIsAddedToFactory() {
|
|
|
|
|
ReactiveWebApplicationContextRunner runner = new ReactiveWebApplicationContextRunner(
|
|
|
|
|
new ReactiveWebApplicationContextRunner(
|
|
|
|
|
AnnotationConfigReactiveWebApplicationContext::new)
|
|
|
|
|
.withConfiguration(AutoConfigurations
|
|
|
|
|
.of(ReactiveWebServerFactoryAutoConfiguration.class))
|
|
|
|
|
.withUserConfiguration(JettyServerCustomizer.class);
|
|
|
|
|
runner.run((context) -> {
|
|
|
|
|
JettyReactiveWebServerFactory factory = context
|
|
|
|
|
.getBean(JettyReactiveWebServerFactory.class);
|
|
|
|
|
assertThat(factory.getServerCustomizers()).hasSize(1);
|
|
|
|
|
});
|
|
|
|
|
.withClassLoader(
|
|
|
|
|
new FilteredClassLoader(Tomcat.class, HttpServer.class))
|
|
|
|
|
.withUserConfiguration(JettyServerCustomizerConfiguration.class,
|
|
|
|
|
HttpHandlerConfiguration.class)
|
|
|
|
|
.run((context) -> {
|
|
|
|
|
JettyReactiveWebServerFactory factory = context
|
|
|
|
|
.getBean(JettyReactiveWebServerFactory.class);
|
|
|
|
|
assertThat(factory.getServerCustomizers()).hasSize(1);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void undertowDeploymentInfoCustomizerBeanIsAddedToFactory() {
|
|
|
|
|
ReactiveWebApplicationContextRunner runner = new ReactiveWebApplicationContextRunner(
|
|
|
|
|
new ReactiveWebApplicationContextRunner(
|
|
|
|
|
AnnotationConfigReactiveWebApplicationContext::new)
|
|
|
|
|
.withConfiguration(AutoConfigurations
|
|
|
|
|
.of(ReactiveWebServerFactoryAutoConfiguration.class))
|
|
|
|
|
.withUserConfiguration(UndertowDeploymentInfoCustomizer.class);
|
|
|
|
|
runner.run((context) -> {
|
|
|
|
|
UndertowReactiveWebServerFactory factory = context
|
|
|
|
|
.getBean(UndertowReactiveWebServerFactory.class);
|
|
|
|
|
assertThat(factory.getDeploymentInfoCustomizers()).hasSize(1);
|
|
|
|
|
});
|
|
|
|
|
.withClassLoader(new FilteredClassLoader(Tomcat.class,
|
|
|
|
|
HttpServer.class, Server.class))
|
|
|
|
|
.withUserConfiguration(
|
|
|
|
|
UndertowDeploymentInfoCustomizerConfiguration.class,
|
|
|
|
|
HttpHandlerConfiguration.class)
|
|
|
|
|
.run((context) -> {
|
|
|
|
|
UndertowReactiveWebServerFactory factory = context
|
|
|
|
|
.getBean(UndertowReactiveWebServerFactory.class);
|
|
|
|
|
assertThat(factory.getDeploymentInfoCustomizers()).hasSize(1);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void undertowBuilderCustomizerBeanIsAddedToFactory() {
|
|
|
|
|
ReactiveWebApplicationContextRunner runner = new ReactiveWebApplicationContextRunner(
|
|
|
|
|
new ReactiveWebApplicationContextRunner(
|
|
|
|
|
AnnotationConfigReactiveWebApplicationContext::new)
|
|
|
|
|
.withConfiguration(AutoConfigurations
|
|
|
|
|
.of(ReactiveWebServerFactoryAutoConfiguration.class))
|
|
|
|
|
.withUserConfiguration(UndertowBuilderCustomizer.class);
|
|
|
|
|
runner.run((context) -> {
|
|
|
|
|
UndertowReactiveWebServerFactory factory = context
|
|
|
|
|
.getBean(UndertowReactiveWebServerFactory.class);
|
|
|
|
|
assertThat(factory.getBuilderCustomizers()).hasSize(1);
|
|
|
|
|
});
|
|
|
|
|
.withClassLoader(new FilteredClassLoader(Tomcat.class,
|
|
|
|
|
HttpServer.class, Server.class))
|
|
|
|
|
.withUserConfiguration(
|
|
|
|
|
UndertowBuilderCustomizerConfiguration.class,
|
|
|
|
|
HttpHandlerConfiguration.class)
|
|
|
|
|
.run((context) -> {
|
|
|
|
|
UndertowReactiveWebServerFactory factory = context
|
|
|
|
|
.getBean(UndertowReactiveWebServerFactory.class);
|
|
|
|
|
assertThat(factory.getBuilderCustomizers()).hasSize(1);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@ -300,6 +310,42 @@ public class ReactiveWebServerFactoryAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
|
static class JettyServerCustomizerConfiguration {
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
public JettyServerCustomizer protocolHandlerCustomizer() {
|
|
|
|
|
return (server) -> {
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
|
static class UndertowBuilderCustomizerConfiguration {
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
public UndertowBuilderCustomizer protocolHandlerCustomizer() {
|
|
|
|
|
return (builder) -> {
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
|
static class UndertowDeploymentInfoCustomizerConfiguration {
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
public UndertowDeploymentInfoCustomizer protocolHandlerCustomizer() {
|
|
|
|
|
return (deploymentInfo) -> {
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
|
static class ForwardedHeaderTransformerConfiguration {
|
|
|
|
|
|
|
|
|
|