diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySourceTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySourceTests.java index 30c97f02e7..03c3ac35cf 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySourceTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySourceTests.java @@ -152,10 +152,12 @@ class SpringIterableConfigurationPropertySourceTests { } @Test - void containsDescendantOfWhenSystemEnvironmentPropertySourceShouldLegacyProperty() { + void containsDescendantOfWhenSystemEnvironmentPropertySourceShouldSupportLegacyProperty() { Map source = new LinkedHashMap<>(); source.put("FOO_BAR_BAZ_BONG", "bing"); source.put("FOO_ALPHABRAVO_GAMMA", "delta"); + source.put("loo_bar_baz_bong", "bing"); + source.put("loo_alphabravo_gamma", "delta"); SystemEnvironmentPropertySource propertySource = new SystemEnvironmentPropertySource( StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, source); SpringIterableConfigurationPropertySource adapter = new SpringIterableConfigurationPropertySource( @@ -166,6 +168,27 @@ class SpringIterableConfigurationPropertySourceTests { .isEqualTo(ConfigurationPropertyState.PRESENT); assertThat(adapter.containsDescendantOf(ConfigurationPropertyName.of("foo.blah"))) .isEqualTo(ConfigurationPropertyState.ABSENT); + assertThat(adapter.containsDescendantOf(ConfigurationPropertyName.of("loo.bar-baz"))) + .isEqualTo(ConfigurationPropertyState.PRESENT); + assertThat(adapter.containsDescendantOf(ConfigurationPropertyName.of("loo.alpha-bravo"))) + .isEqualTo(ConfigurationPropertyState.PRESENT); + assertThat(adapter.containsDescendantOf(ConfigurationPropertyName.of("loo.blah"))) + .isEqualTo(ConfigurationPropertyState.ABSENT); + } + + @Test + void getConfigurationPropertyWhenSystemEnvironmentPropertySourceShouldSupportLegacyProperty() { + Map source = new LinkedHashMap<>(); + source.put("TEST_VALUE_UPPER", "upper"); + source.put("test_value_lower", "lower"); + SystemEnvironmentPropertySource propertySource = new SystemEnvironmentPropertySource( + StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, source); + SpringIterableConfigurationPropertySource adapter = new SpringIterableConfigurationPropertySource( + propertySource, SystemEnvironmentPropertyMapper.INSTANCE, DefaultPropertyMapper.INSTANCE); + assertThat(adapter.getConfigurationProperty(ConfigurationPropertyName.of("test.value-upper")).getValue()) + .isEqualTo("upper"); + assertThat(adapter.getConfigurationProperty(ConfigurationPropertyName.of("test.value-lower")).getValue()) + .isEqualTo("lower"); } @Test