|
|
|
@ -15,6 +15,7 @@
|
|
|
|
|
*/
|
|
|
|
|
package org.springframework.boot.test.web;
|
|
|
|
|
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
@ -99,13 +100,10 @@ public class SpringBootTestRandomPortEnvironmentPostProcessorTests {
|
|
|
|
|
@Test
|
|
|
|
|
public void postProcessWhenTestServerPortIsZeroAndManagementPortIsNotNullAndDefaultSameInProduction() {
|
|
|
|
|
// mgmt port is 8080 which means it's on the same port as main server since that
|
|
|
|
|
// is
|
|
|
|
|
// null in app properties
|
|
|
|
|
// is null in app properties
|
|
|
|
|
addTestPropertySource("0", null);
|
|
|
|
|
Map<String, Object> other = new HashMap<>();
|
|
|
|
|
other.put("management.server.port", "8080");
|
|
|
|
|
MapPropertySource otherSource = new MapPropertySource("other", other);
|
|
|
|
|
this.propertySources.addLast(otherSource);
|
|
|
|
|
this.propertySources.addLast(new MapPropertySource("other",
|
|
|
|
|
Collections.singletonMap("management.server.port", "8080")));
|
|
|
|
|
this.postProcessor.postProcessEnvironment(this.environment, null);
|
|
|
|
|
assertThat(this.environment.getProperty("server.port")).isEqualTo("0");
|
|
|
|
|
assertThat(this.environment.getProperty("management.server.port")).isEqualTo("");
|
|
|
|
@ -114,10 +112,8 @@ public class SpringBootTestRandomPortEnvironmentPostProcessorTests {
|
|
|
|
|
@Test
|
|
|
|
|
public void postProcessWhenTestServerPortIsZeroAndManagementPortIsNotNullAndDifferentInProduction() {
|
|
|
|
|
addTestPropertySource("0", null);
|
|
|
|
|
Map<String, Object> other = new HashMap<>();
|
|
|
|
|
other.put("management.server.port", "8081");
|
|
|
|
|
MapPropertySource otherSource = new MapPropertySource("other", other);
|
|
|
|
|
this.propertySources.addLast(otherSource);
|
|
|
|
|
this.propertySources.addLast(new MapPropertySource("other",
|
|
|
|
|
Collections.singletonMap("management.server.port", "8081")));
|
|
|
|
|
this.postProcessor.postProcessEnvironment(this.environment, null);
|
|
|
|
|
assertThat(this.environment.getProperty("server.port")).isEqualTo("0");
|
|
|
|
|
assertThat(this.environment.getProperty("management.server.port")).isEqualTo("0");
|
|
|
|
@ -126,10 +122,8 @@ public class SpringBootTestRandomPortEnvironmentPostProcessorTests {
|
|
|
|
|
@Test
|
|
|
|
|
public void postProcessWhenTestServerPortIsZeroAndManagementPortMinusOne() {
|
|
|
|
|
addTestPropertySource("0", null);
|
|
|
|
|
Map<String, Object> other = new HashMap<>();
|
|
|
|
|
other.put("management.server.port", "-1");
|
|
|
|
|
MapPropertySource otherSource = new MapPropertySource("other", other);
|
|
|
|
|
this.propertySources.addLast(otherSource);
|
|
|
|
|
this.propertySources.addLast(new MapPropertySource("other",
|
|
|
|
|
Collections.singletonMap("management.server.port", "-1")));
|
|
|
|
|
this.postProcessor.postProcessEnvironment(this.environment, null);
|
|
|
|
|
assertThat(this.environment.getProperty("server.port")).isEqualTo("0");
|
|
|
|
|
assertThat(this.environment.getProperty("management.server.port"))
|
|
|
|
|