diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootContextLoader.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootContextLoader.java index 2bcaaebdb9f..e90d067a5f6 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootContextLoader.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootContextLoader.java @@ -23,10 +23,6 @@ import java.util.List; import org.springframework.beans.BeanUtils; import org.springframework.boot.SpringApplication; import org.springframework.boot.WebApplicationType; -import org.springframework.boot.context.properties.bind.Bindable; -import org.springframework.boot.context.properties.bind.Binder; -import org.springframework.boot.context.properties.source.ConfigurationPropertySource; -import org.springframework.boot.context.properties.source.MapConfigurationPropertySource; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.mock.web.SpringBootMockServletContext; import org.springframework.boot.test.util.TestPropertyValues; @@ -166,9 +162,6 @@ public class SpringBootContextLoader extends AbstractContextLoader { // JMX bean names will clash if the same bean is used in multiple contexts disableJmx(properties); properties.addAll(Arrays.asList(config.getPropertySourceProperties())); - if (!isEmbeddedWebEnvironment(config) && !hasCustomServerPort(properties)) { - properties.add("server.port=-1"); - } return StringUtils.toStringArray(properties); } @@ -176,16 +169,6 @@ public class SpringBootContextLoader extends AbstractContextLoader { properties.add("spring.jmx.enabled=false"); } - private boolean hasCustomServerPort(List properties) { - Binder binder = new Binder(convertToConfigurationPropertySource(properties)); - return binder.bind("server.port", Bindable.of(String.class)).isBound(); - } - - private ConfigurationPropertySource convertToConfigurationPropertySource(List properties) { - return new MapConfigurationPropertySource( - TestPropertySourceUtils.convertInlinedPropertiesToMap(StringUtils.toStringArray(properties))); - } - /** * Return the {@link ApplicationContextInitializer initializers} that will be applied * to the context. By default this method will adapt {@link ContextCustomizer context