DATACMNS-1235 - Polishing.
Introduced BeanLookup to easily create a Lazy<T>-based lookup of a unique bean by type on a ListableBeanFactory. This is in support of making it easy for downstream Spring Data modules to consume the EntityPathResolver declared in an ApplicationContext using XML configuration. QuerydslWebConfiguration now uses a plain ObjectProvider to access the bean defined falling back to our default. Original pull request: #265.
This commit is contained in:
@@ -30,6 +30,9 @@ import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.data.classloadersupport.HidingClassLoader;
|
||||
import org.springframework.data.geo.Distance;
|
||||
import org.springframework.data.geo.Point;
|
||||
import org.springframework.data.querydsl.EntityPathResolver;
|
||||
import org.springframework.data.querydsl.SimpleEntityPathResolver;
|
||||
import org.springframework.data.querydsl.binding.QuerydslBindingsFactory;
|
||||
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
|
||||
import org.springframework.data.web.PagedResourcesAssemblerArgumentResolver;
|
||||
import org.springframework.data.web.ProxyingHandlerMethodArgumentResolver;
|
||||
@@ -88,6 +91,18 @@ public class EnableSpringDataWebSupportIntegrationTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableSpringDataWebSupport
|
||||
static class CustomEntityPathResolver {
|
||||
|
||||
static SimpleEntityPathResolver resolver = new SimpleEntityPathResolver("suffix");
|
||||
|
||||
@Bean
|
||||
SimpleEntityPathResolver entityPathResolver() {
|
||||
return resolver;
|
||||
}
|
||||
}
|
||||
|
||||
@Test // DATACMNS-330
|
||||
public void registersBasicBeanDefinitions() throws Exception {
|
||||
|
||||
@@ -215,6 +230,16 @@ public class EnableSpringDataWebSupportIntegrationTests {
|
||||
assertThat(adapter.getArgumentResolvers().get(0)).isInstanceOf(ProxyingHandlerMethodArgumentResolver.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1235
|
||||
public void picksUpEntityPathResolverIfRegistered() {
|
||||
|
||||
WebApplicationContext context = WebTestUtils.createApplicationContext(CustomEntityPathResolver.class);
|
||||
|
||||
assertThat(context.getBean(EntityPathResolver.class)).isEqualTo(CustomEntityPathResolver.resolver);
|
||||
assertThat(context.getBean(QuerydslBindingsFactory.class).getEntityPathResolver())
|
||||
.isEqualTo(CustomEntityPathResolver.resolver);
|
||||
}
|
||||
|
||||
private static void assertResolversRegistered(ApplicationContext context, Class<?>... resolverTypes) {
|
||||
|
||||
RequestMappingHandlerAdapter adapter = context.getBean(RequestMappingHandlerAdapter.class);
|
||||
|
||||
Reference in New Issue
Block a user