Skip to content

Commit c1ed504

Browse files
committed
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
1 parent 5b660da commit c1ed504

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

spring-websocket/src/test/java/org/springframework/web/socket/server/standard/SpringConfiguratorTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323

2424
import org.springframework.beans.factory.annotation.Autowired;
2525
import org.springframework.context.annotation.Bean;
26-
import org.springframework.context.annotation.ComponentScan;
2726
import org.springframework.context.annotation.Configuration;
27+
import org.springframework.context.annotation.Import;
2828
import org.springframework.stereotype.Component;
2929
import org.springframework.web.context.ContextLoader;
3030
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
@@ -84,7 +84,7 @@ void getEndpointSingletonByComponentName() throws Exception {
8484

8585

8686
@Configuration
87-
@ComponentScan(basePackageClasses=SpringConfiguratorTests.class)
87+
@Import(ComponentEchoEndpoint.class)
8888
static class Config {
8989

9090
@Bean

0 commit comments

Comments
 (0)