From 7306fd04de912d02dbef8f1edda20bba889653e8 Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Sun, 8 Mar 2026 16:56:54 +0100 Subject: [PATCH] Use MergedContextConfiguration.hasResources() Simplify the code by using MergedContextConfiguration.hasResources(). See gh-49504 --- .../boot/test/context/SpringBootContextLoader.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootContextLoader.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootContextLoader.java index afc3baf925b..16071b72668 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootContextLoader.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootContextLoader.java @@ -153,9 +153,7 @@ public class SpringBootContextLoader extends AbstractContextLoader implements Ao } private void assertHasClassesOrLocations(MergedContextConfiguration mergedConfig) { - boolean hasClasses = !ObjectUtils.isEmpty(mergedConfig.getClasses()); - boolean hasLocations = !ObjectUtils.isEmpty(mergedConfig.getLocations()); - Assert.state(hasClasses || hasLocations, + Assert.state(mergedConfig.hasResources(), () -> "No configuration classes or locations found in @SpringApplicationConfiguration. " + "For default configuration detection to work you need Spring 4.0.3 or better (found " + SpringVersion.getVersion() + ").");