Do not set server.port=-1 for non embedded tests
Closes gh-16998
This commit is contained in:
parent
1199b7c014
commit
f4c68dbc98
|
|
@ -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<String> properties) {
|
||||
Binder binder = new Binder(convertToConfigurationPropertySource(properties));
|
||||
return binder.bind("server.port", Bindable.of(String.class)).isBound();
|
||||
}
|
||||
|
||||
private ConfigurationPropertySource convertToConfigurationPropertySource(List<String> 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
|
||||
|
|
|
|||
Loading…
Reference in New Issue