diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/env/EnvironmentEndpointTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/env/EnvironmentEndpointTests.java index 2d1a3a7ab71..16624855233 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/env/EnvironmentEndpointTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/env/EnvironmentEndpointTests.java @@ -273,6 +273,23 @@ public class EnvironmentEndpointTests { assertPropertySourceEntryDescriptor(sources.get("test"), null, null); } + @Test + public void multipleSourcesWithSameProperty() { + ConfigurableEnvironment environment = emptyEnvironment(); + environment.getPropertySources() + .addFirst(singleKeyPropertySource("one", "a", "alpha")); + environment.getPropertySources() + .addFirst(singleKeyPropertySource("two", "a", "apple")); + EnvironmentDescriptor descriptor = new EnvironmentEndpoint(environment) + .environment(null); + Map sources = propertySources(descriptor); + assertThat(sources.keySet()).containsExactly("two", "one"); + assertThat(sources.get("one").getProperties().get("a").getValue()) + .isEqualTo("alpha"); + assertThat(sources.get("two").getProperties().get("a").getValue()) + .isEqualTo("apple"); + } + private static ConfigurableEnvironment emptyEnvironment() { StandardEnvironment environment = new StandardEnvironment(); environment.getPropertySources()