Fix customizer for windows tests

JettyServerCustomizers beans do not get picked up automatically in 2.1.x

See gh-15553
This commit is contained in:
Madhura Bhave 2019-07-24 16:11:18 -07:00
parent bb85612723
commit f13f96d705
2 changed files with 17 additions and 11 deletions

View File

@ -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<JettyServletWebServerFactory> jettyServerCustomizer() {
return (factory) -> {
factory.addServerCustomizers((server) -> {
ContextHandler handler = (ContextHandler) server.getHandler();
handler.addAliasCheck(new ContextHandler.ApproveAliases());
});
};
}

View File

@ -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<JettyServletWebServerFactory> jettyServerCustomizer() {
return (factory) -> {
factory.addServerCustomizers((server) -> {
ContextHandler handler = (ContextHandler) server.getHandler();
handler.addAliasCheck(new ContextHandler.ApproveAliases());
});
};
}