From 8a01a55046faa8392366054e7304dcb94cf46e18 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Fri, 23 Nov 2012 14:39:02 +0100 Subject: [PATCH] DATACMNS-227 - Renamed repository resource populator location attribute to locations. Tightened test cases to check correct population more strictly. Upgraded to Hamcrest 1.3 as test dependency on the way. --- .../main/resources/META-INF/spring.schemas | 3 +- .../config/spring-repository-1.5.xsd | 187 ++++++++++++++++++ ...rBeanDefinitionParserIntegrationTests.java | 21 +- .../data/repository/config/populators.xml | 4 +- spring-data-commons-parent/pom.xml | 2 +- 5 files changed, 212 insertions(+), 5 deletions(-) create mode 100644 spring-data-commons-core/src/main/resources/org/springframework/data/repository/config/spring-repository-1.5.xsd diff --git a/spring-data-commons-core/src/main/resources/META-INF/spring.schemas b/spring-data-commons-core/src/main/resources/META-INF/spring.schemas index 95afeab10..cd7991393 100644 --- a/spring-data-commons-core/src/main/resources/META-INF/spring.schemas +++ b/spring-data-commons-core/src/main/resources/META-INF/spring.schemas @@ -1,3 +1,4 @@ http\://www.springframework.org/schema/data/repository/spring-repository-1.0.xsd=org/springframework/data/repository/config/spring-repository-1.0.xsd http\://www.springframework.org/schema/data/repository/spring-repository-1.4.xsd=org/springframework/data/repository/config/spring-repository-1.4.xsd -http\://www.springframework.org/schema/data/repository/spring-repository.xsd=org/springframework/data/repository/config/spring-repository-1.4.xsd +http\://www.springframework.org/schema/data/repository/spring-repository-1.5.xsd=org/springframework/data/repository/config/spring-repository-1.5.xsd +http\://www.springframework.org/schema/data/repository/spring-repository.xsd=org/springframework/data/repository/config/spring-repository-1.5.xsd diff --git a/spring-data-commons-core/src/main/resources/org/springframework/data/repository/config/spring-repository-1.5.xsd b/spring-data-commons-core/src/main/resources/org/springframework/data/repository/config/spring-repository-1.5.xsd new file mode 100644 index 000000000..c5b522cb2 --- /dev/null +++ b/spring-data-commons-core/src/main/resources/org/springframework/data/repository/config/spring-repository-1.5.xsd @@ -0,0 +1,187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Where to find the files to read the objects from the repository shall be populated with. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-data-commons-core/src/test/java/org/springframework/data/repository/config/ResourceReaderRepositoryPopulatorBeanDefinitionParserIntegrationTests.java b/spring-data-commons-core/src/test/java/org/springframework/data/repository/config/ResourceReaderRepositoryPopulatorBeanDefinitionParserIntegrationTests.java index 9faf6706c..a87144606 100644 --- a/spring-data-commons-core/src/test/java/org/springframework/data/repository/config/ResourceReaderRepositoryPopulatorBeanDefinitionParserIntegrationTests.java +++ b/spring-data-commons-core/src/test/java/org/springframework/data/repository/config/ResourceReaderRepositoryPopulatorBeanDefinitionParserIntegrationTests.java @@ -15,9 +15,11 @@ */ package org.springframework.data.repository.config; -import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; +import java.util.List; + import org.junit.Test; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.DefaultListableBeanFactory; @@ -53,6 +55,9 @@ public class ResourceReaderRepositoryPopulatorBeanDefinitionParserIntegrationTes assertThat(bean, is(instanceOf(ResourceReaderRepositoryPopulator.class))); Object resourceReader = ReflectionTestUtils.getField(bean, "reader"); assertThat(resourceReader, is(instanceOf(JacksonResourceReader.class))); + + Object resources = ReflectionTestUtils.getField(bean, "resources"); + assertIsListOfClasspathResourcesWithPath(resources, "org/springframework/data/repository/init/data.json"); } /** @@ -74,5 +79,19 @@ public class ResourceReaderRepositoryPopulatorBeanDefinitionParserIntegrationTes assertThat(resourceReader, is(instanceOf(UnmarshallingResourceReader.class))); Object unmarshaller = ReflectionTestUtils.getField(resourceReader, "unmarshaller"); assertThat(unmarshaller, is(instanceOf(Jaxb2Marshaller.class))); + + Object resources = ReflectionTestUtils.getField(bean, "resources"); + assertIsListOfClasspathResourcesWithPath(resources, "org/springframework/data/repository/init/data.xml"); + } + + private void assertIsListOfClasspathResourcesWithPath(Object source, String path) { + + assertThat(source, is(instanceOf(List.class))); + List list = (List) source; + assertThat(list, is(not(empty()))); + Object element = list.get(0); + assertThat(element, is(instanceOf(ClassPathResource.class))); + ClassPathResource resource = (ClassPathResource) element; + assertThat(resource.getPath(), is(path)); } } diff --git a/spring-data-commons-core/src/test/resources/org/springframework/data/repository/config/populators.xml b/spring-data-commons-core/src/test/resources/org/springframework/data/repository/config/populators.xml index 62643d683..7459b3d04 100644 --- a/spring-data-commons-core/src/test/resources/org/springframework/data/repository/config/populators.xml +++ b/spring-data-commons-core/src/test/resources/org/springframework/data/repository/config/populators.xml @@ -7,10 +7,10 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> + locations="classpath:org/springframework/data/repository/init/data.json" /> diff --git a/spring-data-commons-parent/pom.xml b/spring-data-commons-parent/pom.xml index e1ba107a8..858e91e47 100644 --- a/spring-data-commons-parent/pom.xml +++ b/spring-data-commons-parent/pom.xml @@ -15,7 +15,7 @@ 3.0.7.RELEASE 3.1.2.RELEASE 0.3.0.RELEASE - 1.2.1 + 1.3 true