diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.java index c5d59b431..d54b31f97 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.java @@ -95,10 +95,22 @@ import com.fasterxml.jackson.databind.SerializationFeature; @Configuration @ComponentScan(basePackageClasses = RepositoryRestController.class, includeFilters = @Filter(RepositoryRestController.class), useDefaultFilters = false) -@EnableHypermediaSupport(type = HypermediaType.HAL) @ImportResource("classpath*:META-INF/spring-data-rest/**/*.xml") public class RepositoryRestMvcConfiguration extends HateoasAwareSpringDataWebConfiguration { + /** + * Helper class instead of using {@link EnableHypermediaSupport} directly to make sure the annotation gets inspected + * correctly even if users extend {@link RepositoryRestMvcConfiguration}. + * + * @see https://jira.springsource.org/browse/SPR-11251 + * @author Oliver Gierke + */ + @Configuration + @EnableHypermediaSupport(type = HypermediaType.HAL) + static class HypermediaConfigurationDelegate { + + } + private static final boolean IS_JAVAX_VALIDATION_AVAILABLE = ClassUtils.isPresent( "javax.validation.ConstraintViolationException", RepositoryRestMvcConfiguration.class.getClassLoader()); private static final boolean IS_JPA_AVAILABLE = ClassUtils.isPresent("javax.persistence.EntityManager", diff --git a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/config/RepositoryRestMvConfigurationIntegrationTests.java b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/config/RepositoryRestMvConfigurationIntegrationTests.java index a02930e00..e91060aca 100644 --- a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/config/RepositoryRestMvConfigurationIntegrationTests.java +++ b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/config/RepositoryRestMvConfigurationIntegrationTests.java @@ -15,6 +15,9 @@ */ package org.springframework.data.rest.webmvc.config; +import static org.hamcrest.CoreMatchers.*; +import static org.junit.Assert.*; + import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -24,12 +27,15 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.support.AbstractApplicationContext; import org.springframework.data.rest.webmvc.RepositoryLinksResource; import org.springframework.data.web.PageableHandlerMethodArgumentResolver; +import org.springframework.hateoas.LinkDiscoverers; import org.springframework.hateoas.core.DefaultRelProvider; import org.springframework.http.converter.HttpMessageConverter; import com.fasterxml.jackson.databind.ObjectMapper; /** + * Integration tests for basic application bootstrapping (general configuration related checks). + * * @author Oliver Gierke */ public class RepositoryRestMvConfigurationIntegrationTests { @@ -48,6 +54,16 @@ public class RepositoryRestMvConfigurationIntegrationTests { } } + /** + * @see DATAREST-210 + */ + @Test + public void assertEnableHypermediaSupportWorkingCorrectly() { + + assertThat(context.getBean("entityLinksPluginRegistry"), is(notNullValue())); + assertThat(context.getBean(LinkDiscoverers.class), is(notNullValue())); + } + @Test public void assertBeansBeingSetUp() throws Exception {