Use ephemeral ports rather than 8080 in our tests

Closes gh-17025
This commit is contained in:
Andy Wilkinson 2019-07-10 17:20:30 +01:00
parent 906f7637ed
commit dc0432665b
2 changed files with 9 additions and 6 deletions

View File

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

View File

@ -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);