|
31 | 31 | import org.springframework.core.env.EnumerablePropertySource;
|
32 | 32 | import org.springframework.core.env.MapPropertySource;
|
33 | 33 | import org.springframework.core.env.PropertySource;
|
| 34 | +import org.springframework.core.env.StandardEnvironment; |
| 35 | +import org.springframework.core.env.SystemEnvironmentPropertySource; |
34 | 36 |
|
35 | 37 | import static org.assertj.core.api.Assertions.assertThat;
|
36 | 38 | import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
@@ -154,6 +156,23 @@ void containsDescendantOfShouldCheckSourceNames() {
|
154 | 156 | .isEqualTo(ConfigurationPropertyState.ABSENT);
|
155 | 157 | }
|
156 | 158 |
|
| 159 | + @Test |
| 160 | + void containsDescendantOfWhenSystemEnvironmentPropertySourceShouldLegacyProperty() { |
| 161 | + Map<String, Object> source = new LinkedHashMap<>(); |
| 162 | + source.put("FOO_BAR_BAZ_BONG", "bing"); |
| 163 | + source.put("FOO_ALPHABRAVO_GAMMA", "delta"); |
| 164 | + SystemEnvironmentPropertySource propertySource = new SystemEnvironmentPropertySource( |
| 165 | + StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, source); |
| 166 | + SpringIterableConfigurationPropertySource adapter = new SpringIterableConfigurationPropertySource( |
| 167 | + propertySource, SystemEnvironmentPropertyMapper.INSTANCE); |
| 168 | + assertThat(adapter.containsDescendantOf(ConfigurationPropertyName.of("foo.bar-baz"))) |
| 169 | + .isEqualTo(ConfigurationPropertyState.PRESENT); |
| 170 | + assertThat(adapter.containsDescendantOf(ConfigurationPropertyName.of("foo.alpha-bravo"))) |
| 171 | + .isEqualTo(ConfigurationPropertyState.PRESENT); |
| 172 | + assertThat(adapter.containsDescendantOf(ConfigurationPropertyName.of("foo.blah"))) |
| 173 | + .isEqualTo(ConfigurationPropertyState.ABSENT); |
| 174 | + } |
| 175 | + |
157 | 176 | @Test
|
158 | 177 | void simpleMapPropertySourceKeyDataChangeInvalidatesCache() {
|
159 | 178 | // gh-13344
|
|
0 commit comments