Use an ephemeral port to avoid potential port clash

Closes gh-30007
pull/30505/head
Andy Wilkinson 3 years ago
parent b60b5feefe
commit 7bc336cdc6

@ -375,7 +375,7 @@ class ServletWebServerFactoryAutoConfigurationTests {
AnnotationConfigServletWebServerApplicationContext::new) AnnotationConfigServletWebServerApplicationContext::new)
.withConfiguration(AutoConfigurations.of(ServletWebServerFactoryAutoConfiguration.class)) .withConfiguration(AutoConfigurations.of(ServletWebServerFactoryAutoConfiguration.class))
.withPropertyValues("server.forward-headers-strategy=framework", .withPropertyValues("server.forward-headers-strategy=framework",
"server.tomcat.use-relative-redirects=true"); "server.tomcat.use-relative-redirects=true", "server.port=0");
runner.run((context) -> { runner.run((context) -> {
Filter filter = context.getBean(FilterRegistrationBean.class).getFilter(); Filter filter = context.getBean(FilterRegistrationBean.class).getFilter();
assertThat(filter).isInstanceOf(ForwardedHeaderFilter.class); assertThat(filter).isInstanceOf(ForwardedHeaderFilter.class);
@ -389,7 +389,7 @@ class ServletWebServerFactoryAutoConfigurationTests {
AnnotationConfigServletWebServerApplicationContext::new) AnnotationConfigServletWebServerApplicationContext::new)
.withConfiguration(AutoConfigurations.of(ServletWebServerFactoryAutoConfiguration.class)) .withConfiguration(AutoConfigurations.of(ServletWebServerFactoryAutoConfiguration.class))
.withPropertyValues("server.forward-headers-strategy=framework", .withPropertyValues("server.forward-headers-strategy=framework",
"server.tomcat.use-relative-redirects=false"); "server.tomcat.use-relative-redirects=false", "server.port=0");
runner.run((context) -> { runner.run((context) -> {
Filter filter = context.getBean(FilterRegistrationBean.class).getFilter(); Filter filter = context.getBean(FilterRegistrationBean.class).getFilter();
assertThat(filter).isInstanceOf(ForwardedHeaderFilter.class); assertThat(filter).isInstanceOf(ForwardedHeaderFilter.class);
@ -403,7 +403,7 @@ class ServletWebServerFactoryAutoConfigurationTests {
AnnotationConfigServletWebServerApplicationContext::new) AnnotationConfigServletWebServerApplicationContext::new)
.withClassLoader(new FilteredClassLoader(Tomcat.class)) .withClassLoader(new FilteredClassLoader(Tomcat.class))
.withConfiguration(AutoConfigurations.of(ServletWebServerFactoryAutoConfiguration.class)) .withConfiguration(AutoConfigurations.of(ServletWebServerFactoryAutoConfiguration.class))
.withPropertyValues("server.forward-headers-strategy=framework"); .withPropertyValues("server.forward-headers-strategy=framework", "server.port=0");
runner.run((context) -> { runner.run((context) -> {
Filter filter = context.getBean(FilterRegistrationBean.class).getFilter(); Filter filter = context.getBean(FilterRegistrationBean.class).getFilter();
assertThat(filter).isInstanceOf(ForwardedHeaderFilter.class); assertThat(filter).isInstanceOf(ForwardedHeaderFilter.class);

Loading…
Cancel
Save