Skip to content

Commit f4c68db

Browse files
committed
Do not set server.port=-1 for non embedded tests
Closes gh-16998
1 parent 1199b7c commit f4c68db

File tree

1 file changed

+0
-17
lines changed

1 file changed

+0
-17
lines changed

spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootContextLoader.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@
2323
import org.springframework.beans.BeanUtils;
2424
import org.springframework.boot.SpringApplication;
2525
import org.springframework.boot.WebApplicationType;
26-
import org.springframework.boot.context.properties.bind.Bindable;
27-
import org.springframework.boot.context.properties.bind.Binder;
28-
import org.springframework.boot.context.properties.source.ConfigurationPropertySource;
29-
import org.springframework.boot.context.properties.source.MapConfigurationPropertySource;
3026
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
3127
import org.springframework.boot.test.mock.web.SpringBootMockServletContext;
3228
import org.springframework.boot.test.util.TestPropertyValues;
@@ -166,26 +162,13 @@ protected String[] getInlinedProperties(MergedContextConfiguration config) {
166162
// JMX bean names will clash if the same bean is used in multiple contexts
167163
disableJmx(properties);
168164
properties.addAll(Arrays.asList(config.getPropertySourceProperties()));
169-
if (!isEmbeddedWebEnvironment(config) && !hasCustomServerPort(properties)) {
170-
properties.add("server.port=-1");
171-
}
172165
return StringUtils.toStringArray(properties);
173166
}
174167

175168
private void disableJmx(List<String> properties) {
176169
properties.add("spring.jmx.enabled=false");
177170
}
178171

179-
private boolean hasCustomServerPort(List<String> properties) {
180-
Binder binder = new Binder(convertToConfigurationPropertySource(properties));
181-
return binder.bind("server.port", Bindable.of(String.class)).isBound();
182-
}
183-
184-
private ConfigurationPropertySource convertToConfigurationPropertySource(List<String> properties) {
185-
return new MapConfigurationPropertySource(
186-
TestPropertySourceUtils.convertInlinedPropertiesToMap(StringUtils.toStringArray(properties)));
187-
}
188-
189172
/**
190173
* Return the {@link ApplicationContextInitializer initializers} that will be applied
191174
* to the context. By default this method will adapt {@link ContextCustomizer context

0 commit comments

Comments
 (0)