From c1ed504ac1e80b0ce59e01f269182f50c2612df6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Nicoll?= Date: Tue, 26 Mar 2024 10:41:00 +0100 Subject: [PATCH] Avoid classpath scanning in test This commit updates SpringConfiguratorTests to not rely on classpath scanning as it could have side effect. In this particular case, the configuration class that sources the scan is detected again, leading to bean overriding. Irrespective of that, adding more code in that package may have side effect as they could be scanned as well. Closes gh-32535 --- .../web/socket/server/standard/SpringConfiguratorTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/server/standard/SpringConfiguratorTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/server/standard/SpringConfiguratorTests.java index 54978a409b4..ae3fede5b6b 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/server/standard/SpringConfiguratorTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/server/standard/SpringConfiguratorTests.java @@ -23,8 +23,8 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; import org.springframework.stereotype.Component; import org.springframework.web.context.ContextLoader; import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; @@ -84,7 +84,7 @@ public class SpringConfiguratorTests { @Configuration - @ComponentScan(basePackageClasses=SpringConfiguratorTests.class) + @Import(ComponentEchoEndpoint.class) static class Config { @Bean