DATACMNS-502 - Prevent IndexOutOfBoundException in AnnotationRepositoryConfigurationSource.

If a configuration class resides in the default package and no base package is defined in the @Enable…Repositories annotation we previously failed in extracting the package from the class name (as there is none).

We now use Spring's ClassUtils that correctly handles this case and returns an empty String for the default package.
This commit is contained in:
Oliver Gierke
2014-05-08 12:11:21 +02:00
parent e0006e21ae
commit 28f7630acc
3 changed files with 41 additions and 1 deletions

View File

@@ -120,6 +120,20 @@ public class AnnotationRepositoryConfigurationSourceUnitTests {
assertThat(source.getAttribute("namedQueriesLocation"), is("bar"));
}
/**
* @see DATACMNS-502
*/
@Test
public void returnsEmptyStringForBasePackage() throws Exception {
StandardAnnotationMetadata metadata = new StandardAnnotationMetadata(getClass().getClassLoader().loadClass(
"TypeInDefaultPackage"));
RepositoryConfigurationSource configurationSource = new AnnotationRepositoryConfigurationSource(metadata,
EnableRepositories.class, resourceLoader, environment);
assertThat(configurationSource.getBasePackages(), hasItem(""));
}
private AnnotationRepositoryConfigurationSource getConfigSource(Class<?> type) {
AnnotationMetadata metadata = new StandardAnnotationMetadata(type);