From f13f96d7052b8debdeccfc6c1affc977333c5cdc Mon Sep 17 00:00:00 2001 From: Madhura Bhave Date: Wed, 24 Jul 2019 16:11:18 -0700 Subject: [PATCH] Fix customizer for windows tests JettyServerCustomizers beans do not get picked up automatically in 2.1.x See gh-15553 --- .../jetty/jsp/SampleWebJspApplicationTests.java | 13 ++++++++----- .../com/example/JettyServerCustomizerConfig.java | 15 +++++++++------ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/spring-boot-samples/spring-boot-sample-jetty-jsp/src/test/java/sample/jetty/jsp/SampleWebJspApplicationTests.java b/spring-boot-samples/spring-boot-sample-jetty-jsp/src/test/java/sample/jetty/jsp/SampleWebJspApplicationTests.java index 0a93eb9510f..087fbb622c7 100644 --- a/spring-boot-samples/spring-boot-sample-jetty-jsp/src/test/java/sample/jetty/jsp/SampleWebJspApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-jetty-jsp/src/test/java/sample/jetty/jsp/SampleWebJspApplicationTests.java @@ -24,7 +24,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.boot.web.embedded.jetty.JettyServerCustomizer; +import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory; +import org.springframework.boot.web.server.WebServerFactoryCustomizer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpStatus; @@ -59,10 +60,12 @@ public class SampleWebJspApplicationTests { // To allow aliased resources on Concourse Windows CI (See gh-15553) to be served // as static resources. @Bean - public JettyServerCustomizer jettyServerCustomizer() { - return (server) -> { - ContextHandler handler = (ContextHandler) server.getHandler(); - handler.addAliasCheck(new ContextHandler.ApproveAliases()); + public WebServerFactoryCustomizer jettyServerCustomizer() { + return (factory) -> { + factory.addServerCustomizers((server) -> { + ContextHandler handler = (ContextHandler) server.getHandler(); + handler.addAliasCheck(new ContextHandler.ApproveAliases()); + }); }; } diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/com/example/JettyServerCustomizerConfig.java b/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/com/example/JettyServerCustomizerConfig.java index 7ae4c7f0570..55574cdc476 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/com/example/JettyServerCustomizerConfig.java +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/com/example/JettyServerCustomizerConfig.java @@ -18,12 +18,13 @@ package com.example; import org.eclipse.jetty.server.handler.ContextHandler; -import org.springframework.boot.web.embedded.jetty.JettyServerCustomizer; +import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory; +import org.springframework.boot.web.server.WebServerFactoryCustomizer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; /** - * {@link JettyServerCustomizer} that approves all aliases (Used for Windows CI on + * {@link WebServerFactoryCustomizer} that approves all aliases (Used for Windows CI on * Concourse). * * @author Madhura Bhave @@ -32,10 +33,12 @@ import org.springframework.context.annotation.Configuration; public class JettyServerCustomizerConfig { @Bean - public JettyServerCustomizer jettyServerCustomizer() { - return (server) -> { - ContextHandler handler = (ContextHandler) server.getHandler(); - handler.addAliasCheck(new ContextHandler.ApproveAliases()); + public WebServerFactoryCustomizer jettyServerCustomizer() { + return (factory) -> { + factory.addServerCustomizers((server) -> { + ContextHandler handler = (ContextHandler) server.getHandler(); + handler.addAliasCheck(new ContextHandler.ApproveAliases()); + }); }; }