From fb2f7c1e38ce35bd2ed097f0c1b15c9d8cc08027 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 8 Aug 2022 14:18:40 +0100 Subject: [PATCH] Fix test to create correct type of child context Closes gh-32002 --- .../web/server/ChildManagementContextInitializerAotTests.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/ChildManagementContextInitializerAotTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/ChildManagementContextInitializerAotTests.java index 5b975ee428..27d22d8e34 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/ChildManagementContextInitializerAotTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/ChildManagementContextInitializerAotTests.java @@ -25,6 +25,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.aot.AotDetector; import org.springframework.aot.test.generator.compile.CompileWithTargetClassAccess; import org.springframework.aot.test.generator.compile.TestCompiler; import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration; @@ -86,7 +87,8 @@ class ChildManagementContextInitializerAotTests { .getInstance(ApplicationContextInitializer.class, className.toString()); initializer.initialize(freshApplicationContext); assertThat(output).satisfies(numberOfOccurrences("Tomcat started on port", 0)); - freshApplicationContext.refresh(); + TestPropertyValues.of(AotDetector.AOT_ENABLED + "=true") + .applyToSystemProperties(freshApplicationContext::refresh); assertThat(output).satisfies(numberOfOccurrences("Tomcat started on port", 2)); }); });