diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/SystemEnvironmentPropertyMapperTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/SystemEnvironmentPropertyMapperTests.java index 01458c2d21..0800f12e33 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/SystemEnvironmentPropertyMapperTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/SystemEnvironmentPropertyMapperTests.java @@ -78,17 +78,29 @@ class SystemEnvironmentPropertyMapperTests extends AbstractPropertyMapperTests { @Test void isAncestorOfConsidersLegacyNames() { ConfigurationPropertyName name = ConfigurationPropertyName.of("my.spring-boot"); - assertThat(getMapper().isAncestorOf(name, ConfigurationPropertyName.of("my.spring-boot.property"))).isTrue(); - assertThat(getMapper().isAncestorOf(name, ConfigurationPropertyName.of("my.springboot.property"))).isTrue(); - assertThat(getMapper().isAncestorOf(name, ConfigurationPropertyName.of("my.boot.property"))).isFalse(); + assertThat(getMapper().isAncestorOf(name, ConfigurationPropertyName.adapt("MY_SPRING_BOOT_PROPERTY", '_'))) + .isTrue(); + assertThat(getMapper().isAncestorOf(name, ConfigurationPropertyName.adapt("MY_SPRINGBOOT_PROPERTY", '_'))) + .isTrue(); + assertThat(getMapper().isAncestorOf(name, ConfigurationPropertyName.adapt("MY_BOOT_PROPERTY", '_'))).isFalse(); } @Test - void isAncestorOfWhenCamelCaseSourceConsidersLegacyNames() { + void isAncestorOfWhenNonCanonicalSource() { ConfigurationPropertyName name = ConfigurationPropertyName.adapt("my.springBoot", '.'); assertThat(getMapper().isAncestorOf(name, ConfigurationPropertyName.of("my.spring-boot.property"))).isTrue(); assertThat(getMapper().isAncestorOf(name, ConfigurationPropertyName.of("my.springboot.property"))).isTrue(); assertThat(getMapper().isAncestorOf(name, ConfigurationPropertyName.of("my.boot.property"))).isFalse(); } + @Test + void isAncestorOfWhenNonCanonicalAndDashedSource() { + ConfigurationPropertyName name = ConfigurationPropertyName.adapt("my.springBoot.input-value", '.'); + assertThat(getMapper().isAncestorOf(name, ConfigurationPropertyName.of("my.spring-boot.input-value.property"))) + .isTrue(); + assertThat(getMapper().isAncestorOf(name, ConfigurationPropertyName.of("my.springboot.inputvalue.property"))) + .isTrue(); + assertThat(getMapper().isAncestorOf(name, ConfigurationPropertyName.of("my.boot.property"))).isFalse(); + } + }