Upgrade to Servlet 6.0 and related EE 10 specs

Co-authored-by: Phillip Webb <pwebb@vmware.com>

Closes gh-33036
Closes gh-33037
Closes gh-33038
Closes gh-33039
Closes gh-33040
Closes gh-33041
Closes gh-33042
Closes gh-33043
This commit is contained in:
Andy Wilkinson
2022-11-05 17:57:18 -07:00
parent 1525ed9170
commit b67c427259
36 changed files with 188 additions and 62 deletions

View File

@@ -51,6 +51,8 @@ import org.springframework.boot.context.properties.bind.Bindable;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.boot.context.properties.source.ConfigurationPropertySource;
import org.springframework.boot.context.properties.source.MapConfigurationPropertySource;
import org.springframework.boot.testsupport.web.servlet.DirtiesUrlFactories;
import org.springframework.boot.testsupport.web.servlet.Servlet5ClassPathOverrides;
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
import org.springframework.boot.web.embedded.jetty.JettyWebServer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
@@ -84,6 +86,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Chris Bono
* @author Parviz Rozikov
*/
@DirtiesUrlFactories
class ServerPropertiesTests {
private final ServerProperties properties = new ServerProperties();
@@ -458,6 +461,7 @@ class ServerPropertiesTests {
}
@Test
@Servlet5ClassPathOverrides
void jettyThreadPoolPropertyDefaultsShouldMatchServerDefault() {
JettyServletWebServerFactory jettyFactory = new JettyServletWebServerFactory(0);
JettyWebServer jetty = (JettyWebServer) jettyFactory.getWebServer();
@@ -472,6 +476,7 @@ class ServerPropertiesTests {
}
@Test
@Servlet5ClassPathOverrides
void jettyMaxHttpFormPostSizeMatchesDefault() {
JettyServletWebServerFactory jettyFactory = new JettyServletWebServerFactory(0);
JettyWebServer jetty = (JettyWebServer) jettyFactory

View File

@@ -45,6 +45,8 @@ import org.springframework.boot.autoconfigure.web.ServerProperties.Jetty;
import org.springframework.boot.context.properties.bind.Bindable;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.boot.context.properties.source.ConfigurationPropertySources;
import org.springframework.boot.testsupport.web.servlet.DirtiesUrlFactories;
import org.springframework.boot.testsupport.web.servlet.Servlet5ClassPathOverrides;
import org.springframework.boot.web.embedded.jetty.ConfigurableJettyWebServerFactory;
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
import org.springframework.boot.web.embedded.jetty.JettyWebServer;
@@ -63,6 +65,8 @@ import static org.mockito.Mockito.mock;
* @author Phillip Webb
* @author HaiTao Zhang
*/
@DirtiesUrlFactories
@Servlet5ClassPathOverrides
class JettyWebServerFactoryCustomizerTests {
private MockEnvironment environment;

View File

@@ -28,6 +28,8 @@ import reactor.netty.http.server.HttpServer;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.FilteredClassLoader;
import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner;
import org.springframework.boot.testsupport.web.servlet.DirtiesUrlFactories;
import org.springframework.boot.testsupport.web.servlet.Servlet5ClassPathOverrides;
import org.springframework.boot.web.embedded.jetty.JettyReactiveWebServerFactory;
import org.springframework.boot.web.embedded.jetty.JettyServerCustomizer;
import org.springframework.boot.web.embedded.netty.NettyReactiveWebServerFactory;
@@ -63,6 +65,7 @@ import static org.mockito.Mockito.mock;
* @author Raheela Aslam
* @author Madhura Bhave
*/
@DirtiesUrlFactories
class ReactiveWebServerFactoryAutoConfigurationTests {
private final ReactiveWebApplicationContextRunner contextRunner = new ReactiveWebApplicationContextRunner(
@@ -215,6 +218,7 @@ class ReactiveWebServerFactoryAutoConfigurationTests {
}
@Test
@Servlet5ClassPathOverrides
void jettyServerCustomizerBeanIsAddedToFactory() {
new ReactiveWebApplicationContextRunner(AnnotationConfigReactiveWebApplicationContext::new)
.withConfiguration(AutoConfigurations.of(ReactiveWebServerFactoryAutoConfiguration.class))
@@ -227,6 +231,7 @@ class ReactiveWebServerFactoryAutoConfigurationTests {
}
@Test
@Servlet5ClassPathOverrides
void jettyServerCustomizerRegisteredAsBeanAndViaFactoryIsOnlyCalledOnce() {
new ReactiveWebApplicationContextRunner(AnnotationConfigReactiveWebServerApplicationContext::new)
.withConfiguration(AutoConfigurations.of(ReactiveWebServerFactoryAutoConfiguration.class))

View File

@@ -31,6 +31,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.boot.testsupport.classpath.ForkedClassPath;
import org.springframework.boot.testsupport.web.servlet.DirtiesUrlFactories;
import org.springframework.boot.testsupport.web.servlet.Servlet5ClassPathOverrides;
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
@@ -219,6 +220,7 @@ class MultipartAutoConfigurationTests {
}
@Servlet5ClassPathOverrides
@Configuration(proxyBeanMethods = false)
static class WebServerWithNoMultipartJetty {
@@ -279,6 +281,7 @@ class MultipartAutoConfigurationTests {
}
@Servlet5ClassPathOverrides
@Configuration(proxyBeanMethods = false)
static class WebServerWithEverythingJetty {

View File

@@ -37,6 +37,8 @@ import org.springframework.boot.test.context.FilteredClassLoader;
import org.springframework.boot.test.context.assertj.AssertableWebApplicationContext;
import org.springframework.boot.test.context.runner.ContextConsumer;
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
import org.springframework.boot.testsupport.web.servlet.DirtiesUrlFactories;
import org.springframework.boot.testsupport.web.servlet.Servlet5ClassPathOverrides;
import org.springframework.boot.web.embedded.jetty.JettyServerCustomizer;
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
@@ -76,6 +78,7 @@ import static org.mockito.Mockito.mock;
* @author Raheela Aslam
* @author Madhura Bhave
*/
@DirtiesUrlFactories
class ServletWebServerFactoryAutoConfigurationTests {
private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner(
@@ -151,6 +154,7 @@ class ServletWebServerFactoryAutoConfigurationTests {
}
@Test
@Servlet5ClassPathOverrides
void jettyServerCustomizerBeanIsAddedToFactory() {
WebApplicationContextRunner runner = new WebApplicationContextRunner(
AnnotationConfigServletWebServerApplicationContext::new)
@@ -165,6 +169,7 @@ class ServletWebServerFactoryAutoConfigurationTests {
}
@Test
@Servlet5ClassPathOverrides
void jettyServerCustomizerRegisteredAsBeanAndViaFactoryIsOnlyCalledOnce() {
WebApplicationContextRunner runner = new WebApplicationContextRunner(
AnnotationConfigServletWebServerApplicationContext::new)
@@ -410,7 +415,7 @@ class ServletWebServerFactoryAutoConfigurationTests {
void relativeRedirectsShouldNotBeEnabledWhenNotUsingTomcatContainer() {
WebApplicationContextRunner runner = new WebApplicationContextRunner(
AnnotationConfigServletWebServerApplicationContext::new)
.withClassLoader(new FilteredClassLoader(Tomcat.class))
.withClassLoader(new FilteredClassLoader(Tomcat.class, Server.class))
.withConfiguration(AutoConfigurations.of(ServletWebServerFactoryAutoConfiguration.class))
.withPropertyValues("server.forward-headers-strategy=framework", "server.port=0");
runner.run((context) -> {

View File

@@ -98,6 +98,7 @@ class ServletWebServerFactoryCustomizerTests {
}
@Test
@SuppressWarnings("removal")
void customizeSessionProperties() {
Map<String, String> map = new HashMap<>();
map.put("server.servlet.session.timeout", "123");

View File

@@ -24,7 +24,9 @@ import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.springframework.boot.testsupport.classpath.ForkedClassPath;
import org.springframework.boot.testsupport.web.servlet.DirtiesUrlFactories;
import org.springframework.boot.testsupport.web.servlet.Servlet5ClassPathOverrides;
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
@@ -49,6 +51,7 @@ class ServletWebServerServletContextListenerTests {
@ParameterizedTest(name = "{0}")
@MethodSource("testConfiguration")
@ForkedClassPath
void registeredServletContextListenerBeanIsCalled(String serverName, Class<?> configuration) {
AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext(
ServletListenerRegistrationBeanConfiguration.class, configuration);
@@ -60,6 +63,7 @@ class ServletWebServerServletContextListenerTests {
@ParameterizedTest(name = "{0}")
@MethodSource("testConfiguration")
@ForkedClassPath
void servletContextListenerBeanIsCalled(String serverName, Class<?> configuration) {
AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext(
ServletContextListenerBeanConfiguration.class, configuration);
@@ -85,6 +89,7 @@ class ServletWebServerServletContextListenerTests {
}
@Servlet5ClassPathOverrides
@Configuration(proxyBeanMethods = false)
static class JettyConfiguration {

View File

@@ -23,7 +23,9 @@ import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.springframework.boot.testsupport.classpath.ForkedClassPath;
import org.springframework.boot.testsupport.web.servlet.DirtiesUrlFactories;
import org.springframework.boot.testsupport.web.servlet.Servlet5ClassPathOverrides;
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostProcessor;
@@ -44,6 +46,7 @@ class WebSocketServletAutoConfigurationTests {
@ParameterizedTest(name = "{0}")
@MethodSource("testConfiguration")
@ForkedClassPath
void serverContainerIsAvailableFromTheServletContext(String server, Class<?>... configuration) {
try (AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext(
configuration)) {
@@ -84,6 +87,7 @@ class WebSocketServletAutoConfigurationTests {
}
@Servlet5ClassPathOverrides
@Configuration(proxyBeanMethods = false)
static class JettyConfiguration extends CommonConfiguration {