|
23 | 23 | import org.mockito.junit.jupiter.MockitoExtension;
|
24 | 24 | import org.mockito.junit.jupiter.MockitoSettings;
|
25 | 25 | import org.mockito.quality.Strictness;
|
26 |
| - |
27 | 26 | import org.springframework.aop.framework.Advised;
|
| 27 | +import org.springframework.aot.hint.RuntimeHints; |
28 | 28 | import org.springframework.beans.factory.FactoryBean;
|
29 | 29 | import org.springframework.beans.factory.ListableBeanFactory;
|
30 | 30 | import org.springframework.context.annotation.AnnotationBeanNameGenerator;
|
@@ -194,6 +194,29 @@ void skipsRegistrationOnAlreadyRegisteredBeansUsingAtComponentNames() {
|
194 | 194 | assertThat(context.getBeanFactory().getBeanDefinition("fragmentFragment")).isNotNull();
|
195 | 195 | }
|
196 | 196 |
|
| 197 | + @Test // GH-2760 |
| 198 | + void registersAotPostProcessorForDifferentConfigurations() { |
| 199 | + |
| 200 | + var environment = new StandardEnvironment(); |
| 201 | + var context = new GenericApplicationContext(); |
| 202 | + context.setAllowBeanDefinitionOverriding(false); |
| 203 | + |
| 204 | + RepositoryConfigurationSource configSource = new AnnotationRepositoryConfigurationSource( |
| 205 | + AnnotationMetadata.introspect(AnnotatedBeanNamesConfig.class), EnableRepositories.class, context, environment, |
| 206 | + context.getDefaultListableBeanFactory(), new AnnotationBeanNameGenerator()); |
| 207 | + |
| 208 | + new RepositoryConfigurationDelegate(configSource, context, environment).registerRepositoriesIn(context, extension); |
| 209 | + |
| 210 | + RepositoryConfigurationSource configSource2 = new AnnotationRepositoryConfigurationSource( |
| 211 | + AnnotationMetadata.introspect(TestConfig.class), EnableRepositories.class, context, environment, |
| 212 | + context.getDefaultListableBeanFactory(), new AnnotationBeanNameGenerator()); |
| 213 | + |
| 214 | + new RepositoryConfigurationDelegate(configSource2, context, environment).registerRepositoriesIn(context, extension); |
| 215 | + |
| 216 | + context.refreshForAotProcessing(new RuntimeHints()); |
| 217 | + assertThat(context.getBeanNamesForType(RepositoryRegistrationAotProcessor.class)).hasSize(2); |
| 218 | + } |
| 219 | + |
197 | 220 | private static ListableBeanFactory assertLazyRepositoryBeanSetup(Class<?> configClass) {
|
198 | 221 |
|
199 | 222 | var context = new AnnotationConfigApplicationContext(configClass);
|
|
0 commit comments