DATACMNS-471 - Added sample config files for PagedResourcesAssembler setup in XML.
Related issues: Spring HATEOAS - #161.
This commit is contained in:
@@ -26,6 +26,7 @@ import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.core.SpringVersion;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
@@ -79,6 +80,28 @@ public class PageableResourcesAssemblerIntegrationTests {
|
||||
assertThat(resources.getLink(Link.REL_SELF), is(notNullValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACMNS-471
|
||||
*/
|
||||
@Test
|
||||
public void setsUpPagedResourcesAssemblerFromManualXmlConfig() {
|
||||
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("manual.xml", getClass());
|
||||
assertThat(context.getBean(PagedResourcesAssembler.class), is(notNullValue()));
|
||||
context.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACMNS-471
|
||||
*/
|
||||
@Test
|
||||
public void setsUpPagedResourcesAssemblerFromJavaConfigXmlConfig() {
|
||||
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("via-config-class.xml", getClass());
|
||||
assertThat(context.getBean(PagedResourcesAssembler.class), is(notNullValue()));
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Controller
|
||||
static class SampleController {
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<bean class="org.springframework.data.web.PagedResourcesAssembler">
|
||||
<constructor-arg>
|
||||
<bean class="org.springframework.data.web.HateoasPageableHandlerMethodArgumentResolver" />
|
||||
</constructor-arg>
|
||||
<constructor-arg>
|
||||
<null />
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
<context:annotation-config />
|
||||
|
||||
<bean class="org.springframework.data.web.config.HateoasAwareSpringDataWebConfiguration" />
|
||||
|
||||
</beans>
|
||||
Reference in New Issue
Block a user