DATAMONGO-901 - Fixed regression of not registering type predicting post processor.
The changes for DATAMONGO-843 introduced a regression by skipping the registration of the RepositoryInterfaceAwareBeanPostProcessor. This can cause the wiring of repository bean definitions to fail depending on in which order the bean definitions get instantiated. This change reintroduces the registration and adds an explicit test case for it.
This commit is contained in:
@@ -105,6 +105,8 @@ public class MongoRepositoryConfigurationExtension extends RepositoryConfigurati
|
||||
@Override
|
||||
public void registerBeansForRoot(BeanDefinitionRegistry registry, RepositoryConfigurationSource configurationSource) {
|
||||
|
||||
super.registerBeansForRoot(registry, configurationSource);
|
||||
|
||||
if (!registry.containsBeanDefinition(BeanNames.MAPPING_CONTEXT_BEAN_NAME)) {
|
||||
|
||||
RootBeanDefinition definition = new RootBeanDefinition(MongoMappingContext.class);
|
||||
|
||||
@@ -15,9 +15,12 @@
|
||||
*/
|
||||
package org.springframework.data.mongodb.repository.config;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.mongodb.core.MongoOperations;
|
||||
@@ -49,9 +52,25 @@ public class MongoRepositoriesRegistrarIntegrationTests {
|
||||
}
|
||||
|
||||
@Autowired PersonRepository personRepository;
|
||||
@Autowired ApplicationContext context;
|
||||
|
||||
@Test
|
||||
public void testConfiguration() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAMONGO-901
|
||||
*/
|
||||
@Test
|
||||
public void registersTypePredictingPostProcessor() {
|
||||
|
||||
for (String name : context.getBeanDefinitionNames()) {
|
||||
if (name.startsWith("org.springframework.data.repository.core.support.RepositoryInterfaceAwareBeanPostProcessor")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
fail("Expected to find a bean with name starting with RepositoryInterfaceAwareBeanPostProcessor");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user