|
26 | 26 | import example.scannable.CustomStereotype; |
27 | 27 | import example.scannable.DefaultNamedComponent; |
28 | 28 | import example.scannable.FooService; |
| 29 | +import example.scannable.FooServiceImpl; |
29 | 30 | import example.scannable.MessageBean; |
30 | 31 | import example.scannable.ScopedProxyTestBean; |
31 | 32 | import example.scannable_implicitbasepackage.ComponentScanAnnotatedConfigWithImplicitBasePackage; |
|
43 | 44 | import org.springframework.beans.factory.config.BeanDefinition; |
44 | 45 | import org.springframework.beans.factory.support.BeanDefinitionRegistry; |
45 | 46 | import org.springframework.beans.factory.support.DefaultListableBeanFactory; |
| 47 | +import org.springframework.beans.factory.support.RootBeanDefinition; |
46 | 48 | import org.springframework.context.ApplicationContext; |
47 | 49 | import org.springframework.context.EnvironmentAware; |
48 | 50 | import org.springframework.context.ResourceLoaderAware; |
@@ -84,6 +86,17 @@ void controlScan() { |
84 | 86 | assertContextContainsBean(ctx, "fooServiceImpl"); |
85 | 87 | } |
86 | 88 |
|
| 89 | + @Test |
| 90 | + void controlScanWithExplicitRegistration() { |
| 91 | + AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); |
| 92 | + ctx.registerBeanDefinition("myFooService", new RootBeanDefinition(FooServiceImpl.class)); |
| 93 | + ctx.scan(example.scannable.PackageMarker.class.getPackage().getName()); |
| 94 | + ctx.refresh(); |
| 95 | + |
| 96 | + assertContextContainsBean(ctx, "myFooService"); |
| 97 | + assertContextContainsBean(ctx, "fooServiceImpl"); |
| 98 | + } |
| 99 | + |
87 | 100 | @Test |
88 | 101 | void viaContextRegistration() { |
89 | 102 | ApplicationContext ctx = new AnnotationConfigApplicationContext(ComponentScanAnnotatedConfig.class); |
|
0 commit comments