diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryAutoConfigurationTests.java index e627122ac31..59218e86792 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryAutoConfigurationTests.java @@ -250,14 +250,14 @@ class ReactiveWebServerFactoryAutoConfigurationTests { @Test void forwardedHeaderTransformerShouldBeConfigured() { this.contextRunner.withUserConfiguration(HttpHandlerConfiguration.class) - .withPropertyValues("server.forward-headers-strategy=framework") + .withPropertyValues("server.forward-headers-strategy=framework", "server.port=0") .run((context) -> assertThat(context).hasSingleBean(ForwardedHeaderTransformer.class)); } @Test void forwardedHeaderTransformerWhenStrategyNotFilterShouldNotBeConfigured() { this.contextRunner.withUserConfiguration(HttpHandlerConfiguration.class) - .withPropertyValues("server.forward-headers-strategy=native") + .withPropertyValues("server.forward-headers-strategy=native", "server.port=0") .run((context) -> assertThat(context).doesNotHaveBean(ForwardedHeaderTransformer.class)); } @@ -265,7 +265,7 @@ class ReactiveWebServerFactoryAutoConfigurationTests { void forwardedHeaderTransformerWhenAlreadyRegisteredShouldBackOff() { this.contextRunner .withUserConfiguration(ForwardedHeaderTransformerConfiguration.class, HttpHandlerConfiguration.class) - .withPropertyValues("server.forward-headers-strategy=framework") + .withPropertyValues("server.forward-headers-strategy=framework", "server.port=0") .run((context) -> assertThat(context).hasSingleBean(ForwardedHeaderTransformer.class)); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfigurationTests.java index 6096fd86fe7..700698c5e4b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfigurationTests.java @@ -155,7 +155,8 @@ class ServletWebServerFactoryAutoConfigurationTests { AnnotationConfigServletWebServerApplicationContext::new) .withClassLoader(new FilteredClassLoader(Tomcat.class, HttpServer.class)) .withConfiguration(AutoConfigurations.of(ServletWebServerFactoryAutoConfiguration.class)) - .withUserConfiguration(JettyServerCustomizerConfiguration.class); + .withUserConfiguration(JettyServerCustomizerConfiguration.class) + .withPropertyValues("server.port:0"); runner.run((context) -> { JettyServletWebServerFactory factory = context.getBean(JettyServletWebServerFactory.class); assertThat(factory.getServerCustomizers()).hasSize(1); @@ -168,7 +169,8 @@ class ServletWebServerFactoryAutoConfigurationTests { AnnotationConfigServletWebServerApplicationContext::new) .withClassLoader(new FilteredClassLoader(Tomcat.class, HttpServer.class, Server.class)) .withConfiguration(AutoConfigurations.of(ServletWebServerFactoryAutoConfiguration.class)) - .withUserConfiguration(UndertowDeploymentInfoCustomizerConfiguration.class); + .withUserConfiguration(UndertowDeploymentInfoCustomizerConfiguration.class) + .withPropertyValues("server.port:0"); runner.run((context) -> { UndertowServletWebServerFactory factory = context.getBean(UndertowServletWebServerFactory.class); assertThat(factory.getDeploymentInfoCustomizers()).hasSize(1); @@ -181,7 +183,8 @@ class ServletWebServerFactoryAutoConfigurationTests { AnnotationConfigServletWebServerApplicationContext::new) .withClassLoader(new FilteredClassLoader(Tomcat.class, HttpServer.class, Server.class)) .withConfiguration(AutoConfigurations.of(ServletWebServerFactoryAutoConfiguration.class)) - .withUserConfiguration(UndertowBuilderCustomizerConfiguration.class); + .withUserConfiguration(UndertowBuilderCustomizerConfiguration.class) + .withPropertyValues("server.port:0"); runner.run((context) -> { UndertowServletWebServerFactory factory = context.getBean(UndertowServletWebServerFactory.class); assertThat(factory.getBuilderCustomizers()).hasSize(1);