From 3911507b3611f4f12c66052a76a3fe03cab9417e Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 13 Jun 2025 18:47:51 +0100 Subject: [PATCH] Prevent NAME environment variable from affecting test Closes gh-45874 --- .../boot/context/properties/ConfigurationPropertiesTests.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java index b710293fa3..ee4face157 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java @@ -302,9 +302,12 @@ class ConfigurationPropertiesTests { @Test void loadWhenBindingWithParentContextShouldBind() { AnnotationConfigApplicationContext parent = load(BasicConfiguration.class, "name=parent"); + assertThat(parent.getEnvironment().getProperty("name")).isEqualTo("parent"); this.context = new AnnotationConfigApplicationContext(); this.context.setParent(parent); + removeSystemProperties(); load(new Class[] { BasicConfiguration.class, BasicPropertiesConsumer.class }, "name=child"); + assertThat(this.context.getEnvironment().getProperty("name")).isEqualTo("child"); assertThat(this.context.getBean(BasicProperties.class)).isNotNull(); assertThat(parent.getBean(BasicProperties.class)).isNotNull(); assertThat(this.context.getBean(BasicPropertiesConsumer.class).getName()).isEqualTo("child");