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:
Oliver Gierke
2013-10-31 12:18:54 +01:00
parent c34983b22b
commit 9b077890b4
3 changed files with 34 additions and 17 deletions

View File

@@ -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());
}