DATACMNS-442 - Added test case to show that id resolution succeeds for intermediate repositories.

Adapted test case failing on Spring 4 due to eager RepositoryMetadata resolution.
This commit is contained in:
Oliver Gierke
2014-02-19 14:01:30 +01:00
parent f047cce7c3
commit 611c6194f4
2 changed files with 22 additions and 2 deletions

View File

@@ -91,6 +91,16 @@ public class DefaultRepositoryMetadataUnitTests {
assertEquals(Integer.class, metadata.getIdType());
}
/**
* @see DATACMNS-442
*/
@Test
public void detectsIdTypeOnIntermediateRepository() {
RepositoryMetadata metadata = new DefaultRepositoryMetadata(ConcreteRepository.class);
assertEquals(Long.class, metadata.getIdType());
}
@SuppressWarnings("unused")
private class User {
@@ -149,4 +159,12 @@ public class DefaultRepositoryMetadataUnitTests {
static class GenericEntity<T> {}
static interface GenericEntityRepository extends CrudRepository<GenericEntity<String>, Long> {}
static interface IdTypeFixingRepository<T> extends Repository<T, Long> {
}
static interface ConcreteRepository extends IdTypeFixingRepository<User> {
}
}

View File

@@ -22,7 +22,7 @@ import static org.mockito.Mockito.*;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.Repository;
import org.springframework.test.util.ReflectionTestUtils;
/**
@@ -47,7 +47,7 @@ public class RepositoryFactoryBeanSupportUnitTests {
RepositoryFactoryBeanSupport factoryBean = new DummyRepositoryFactoryBean();
factoryBean.setBeanClassLoader(classLoader);
factoryBean.setLazyInit(true);
factoryBean.setRepositoryInterface(CrudRepository.class);
factoryBean.setRepositoryInterface(SampleRepository.class);
factoryBean.afterPropertiesSet();
Object factory = ReflectionTestUtils.getField(factoryBean, "factory");
@@ -67,4 +67,6 @@ public class RepositoryFactoryBeanSupportUnitTests {
RepositoryFactoryBeanSupport factoryBean = new DummyRepositoryFactoryBean();
factoryBean.afterPropertiesSet();
}
interface SampleRepository extends Repository<Object, Long> {}
}