DATAREST-210 - Added workaround for SPR-11251.
We're now using @EnableHypermediaSupport via a delegated class to prevent @EnableHypermediaSupport from breaking when RepositoryRestMvcConfiguration is subclassed.
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user