use of org.springframework.core.env.MapPropertySource in project spring-boot by spring-projects.
the class EnvironmentEndpointWebIntegrationTests method nestedPathWhenPlaceholderCannotBeResolvedShouldReturnUnresolvedProperty.
@WebEndpointTest
void nestedPathWhenPlaceholderCannotBeResolvedShouldReturnUnresolvedProperty() {
Map<String, Object> map = new HashMap<>();
map.put("my.foo", "${my.bar}");
this.context.getEnvironment().getPropertySources().addFirst(new MapPropertySource("unresolved-placeholder", map));
this.client.get().uri("/actuator/env/my.foo").exchange().expectStatus().isOk().expectBody().jsonPath("property.value").isEqualTo("${my.bar}").jsonPath(forPropertyEntry("unresolved-placeholder")).isEqualTo("${my.bar}");
}
use of org.springframework.core.env.MapPropertySource in project spring-boot by spring-projects.
the class EnvironmentEndpointTests method compositeSourceIsHandledCorrectly.
@Test
void compositeSourceIsHandledCorrectly() {
ConfigurableEnvironment environment = emptyEnvironment();
CompositePropertySource source = new CompositePropertySource("composite");
source.addPropertySource(new MapPropertySource("one", Collections.singletonMap("foo", "bar")));
source.addPropertySource(new MapPropertySource("two", Collections.singletonMap("foo", "spam")));
environment.getPropertySources().addFirst(source);
EnvironmentDescriptor descriptor = new EnvironmentEndpoint(environment).environment(null);
Map<String, PropertySourceDescriptor> sources = propertySources(descriptor);
assertThat(sources.keySet()).containsExactly("composite:one", "composite:two");
assertThat(sources.get("composite:one").getProperties().get("foo").getValue()).isEqualTo("bar");
assertThat(sources.get("composite:two").getProperties().get("foo").getValue()).isEqualTo("spam");
}
use of org.springframework.core.env.MapPropertySource in project spring-boot by spring-projects.
the class SpringBootTestRandomPortEnvironmentPostProcessorTests method postProcessWhenTestServerPortIsZeroAndManagementPortMinusOne.
@Test
void postProcessWhenTestServerPortIsZeroAndManagementPortMinusOne() {
addTestPropertySource("0", null);
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")).isEqualTo("-1");
}
use of org.springframework.core.env.MapPropertySource in project spring-boot by spring-projects.
the class SpringBootTestRandomPortEnvironmentPostProcessorTests method postProcessWhenTestServerPortIsZeroAndManagementPortIsNotNullAndDifferentInProduction.
@Test
void postProcessWhenTestServerPortIsZeroAndManagementPortIsNotNullAndDifferentInProduction() {
addTestPropertySource("0", null);
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");
}
use of org.springframework.core.env.MapPropertySource in project spring-boot by spring-projects.
the class SpringBootTestRandomPortEnvironmentPostProcessorTests method postProcessWhenTestServerPortIsZeroAndManagementPortIsAnInteger.
@Test
void postProcessWhenTestServerPortIsZeroAndManagementPortIsAnInteger() {
addTestPropertySource("0", null);
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");
}
Aggregations