mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Test SpringIterableConfigurationPropertySource support lower case names
Add a test to ensure that `SpringIterableConfigurationPropertySource` can support lower case names. See gh-45741
This commit is contained in:
+24
-1
@@ -152,10 +152,12 @@ class SpringIterableConfigurationPropertySourceTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void containsDescendantOfWhenSystemEnvironmentPropertySourceShouldLegacyProperty() {
|
void containsDescendantOfWhenSystemEnvironmentPropertySourceShouldSupportLegacyProperty() {
|
||||||
Map<String, Object> source = new LinkedHashMap<>();
|
Map<String, Object> source = new LinkedHashMap<>();
|
||||||
source.put("FOO_BAR_BAZ_BONG", "bing");
|
source.put("FOO_BAR_BAZ_BONG", "bing");
|
||||||
source.put("FOO_ALPHABRAVO_GAMMA", "delta");
|
source.put("FOO_ALPHABRAVO_GAMMA", "delta");
|
||||||
|
source.put("loo_bar_baz_bong", "bing");
|
||||||
|
source.put("loo_alphabravo_gamma", "delta");
|
||||||
SystemEnvironmentPropertySource propertySource = new SystemEnvironmentPropertySource(
|
SystemEnvironmentPropertySource propertySource = new SystemEnvironmentPropertySource(
|
||||||
StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, source);
|
StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, source);
|
||||||
SpringIterableConfigurationPropertySource adapter = new SpringIterableConfigurationPropertySource(
|
SpringIterableConfigurationPropertySource adapter = new SpringIterableConfigurationPropertySource(
|
||||||
@@ -166,6 +168,27 @@ class SpringIterableConfigurationPropertySourceTests {
|
|||||||
.isEqualTo(ConfigurationPropertyState.PRESENT);
|
.isEqualTo(ConfigurationPropertyState.PRESENT);
|
||||||
assertThat(adapter.containsDescendantOf(ConfigurationPropertyName.of("foo.blah")))
|
assertThat(adapter.containsDescendantOf(ConfigurationPropertyName.of("foo.blah")))
|
||||||
.isEqualTo(ConfigurationPropertyState.ABSENT);
|
.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<String, Object> 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
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user