DATACMNS-391 - Mitigate changes between Spring 3 and 4' GenericTypeResolver.
As of Spring 4, the GenericTypeResolver is more consistent in detecting raw types. It now returns null for both resolveTypeArguments(Set.class, Set.class) as well as resolveTypeArguments(Set.class, Iterable.class). The latter returns an array of Object.class in 3.x. As this shouldn't make a pratical difference to actual clients (as they need to check for null anyway, we loosen the test case to be able to build Spring Data Commons against both Spring 3 and Spring 4. Some polishing in the version detection in integration tests. Moved the Servlet 3.0 dependency into the Spring 4 profile.
This commit is contained in:
@@ -41,14 +41,6 @@ import org.springframework.test.util.ReflectionTestUtils;
|
||||
*/
|
||||
public class ResourceReaderRepositoryPopulatorBeanDefinitionParserIntegrationTests {
|
||||
|
||||
private ClassPathResource getPopulatorResource() {
|
||||
String populatorsResourceName = "populators.xml";
|
||||
if (SpringVersion.getVersion().startsWith("4.0")) {
|
||||
populatorsResourceName = "populators-spring-4.0.xml";
|
||||
}
|
||||
return new ClassPathResource(populatorsResourceName, getClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACMNS-58
|
||||
*/
|
||||
@@ -117,7 +109,7 @@ public class ResourceReaderRepositoryPopulatorBeanDefinitionParserIntegrationTes
|
||||
assertIsListOfClasspathResourcesWithPath(resources, "org/springframework/data/repository/init/data.xml");
|
||||
}
|
||||
|
||||
private void assertIsListOfClasspathResourcesWithPath(Object source, String path) {
|
||||
private static void assertIsListOfClasspathResourcesWithPath(Object source, String path) {
|
||||
|
||||
assertThat(source, is(instanceOf(List.class)));
|
||||
List<?> list = (List<?>) source;
|
||||
@@ -127,4 +119,13 @@ public class ResourceReaderRepositoryPopulatorBeanDefinitionParserIntegrationTes
|
||||
ClassPathResource resource = (ClassPathResource) element;
|
||||
assertThat(resource.getPath(), is(path));
|
||||
}
|
||||
|
||||
private static ClassPathResource getPopulatorResource() {
|
||||
|
||||
String springVersion = SpringVersion.getVersion();
|
||||
String populatorsResourceName = springVersion.startsWith("4") ? "populators-spring-4.0.xml" : "populators.xml";
|
||||
|
||||
return new ClassPathResource(populatorsResourceName,
|
||||
ResourceReaderRepositoryPopulatorBeanDefinitionParserIntegrationTests.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,9 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
import org.springframework.core.SpringVersion;
|
||||
import org.springframework.data.mapping.Person;
|
||||
|
||||
/**
|
||||
@@ -104,7 +106,14 @@ public class ClassTypeInformationUnitTests {
|
||||
|
||||
property = information.getProperty("rawSet");
|
||||
assertEquals(Set.class, property.getType());
|
||||
assertEquals(Object.class, property.getComponentType().getType());
|
||||
|
||||
// Spring 4 returns null for component types of raw types
|
||||
if (SpringVersion.getVersion().startsWith("4")) {
|
||||
assertThat(property.getComponentType(), nullValue());
|
||||
} else {
|
||||
assertThat(property.getComponentType().getType(), is(Matchers.<Class<?>> equalTo(Object.class)));
|
||||
}
|
||||
|
||||
assertNull(property.getMapValueType());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user