Browse Source

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 6 years ago
parent
commit
f13f96d705
  1. 13
      spring-boot-samples/spring-boot-sample-jetty-jsp/src/test/java/sample/jetty/jsp/SampleWebJspApplicationTests.java
  2. 15
      spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/com/example/JettyServerCustomizerConfig.java

13
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; @@ -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 { @@ -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());
});
};
}

15
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; @@ -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; @@ -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());
});
};
}

Loading…
Cancel
Save