Fix customizer for windows tests

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

See gh-15553
pull/17662/head
Madhura Bhave 5 years ago
parent bb85612723
commit f13f96d705

@ -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;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate; 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.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus; 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 // To allow aliased resources on Concourse Windows CI (See gh-15553) to be served
// as static resources. // as static resources.
@Bean @Bean
public JettyServerCustomizer jettyServerCustomizer() { public WebServerFactoryCustomizer<JettyServletWebServerFactory> jettyServerCustomizer() {
return (server) -> { return (factory) -> {
ContextHandler handler = (ContextHandler) server.getHandler(); factory.addServerCustomizers((server) -> {
handler.addAliasCheck(new ContextHandler.ApproveAliases()); ContextHandler handler = (ContextHandler) server.getHandler();
handler.addAliasCheck(new ContextHandler.ApproveAliases());
});
}; };
} }

@ -18,12 +18,13 @@ package com.example;
import org.eclipse.jetty.server.handler.ContextHandler; 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.Bean;
import org.springframework.context.annotation.Configuration; 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). * Concourse).
* *
* @author Madhura Bhave * @author Madhura Bhave
@ -32,10 +33,12 @@ import org.springframework.context.annotation.Configuration;
public class JettyServerCustomizerConfig { public class JettyServerCustomizerConfig {
@Bean @Bean
public JettyServerCustomizer jettyServerCustomizer() { public WebServerFactoryCustomizer<JettyServletWebServerFactory> jettyServerCustomizer() {
return (server) -> { return (factory) -> {
ContextHandler handler = (ContextHandler) server.getHandler(); factory.addServerCustomizers((server) -> {
handler.addAliasCheck(new ContextHandler.ApproveAliases()); ContextHandler handler = (ContextHandler) server.getHandler();
handler.addAliasCheck(new ContextHandler.ApproveAliases());
});
}; };
} }

Loading…
Cancel
Save