DATACMNS-439 - AnnotationRepositoryConfigSource now evaluates REGEX and ASPECTJ filters.

We now leniently detect AspectJ and regular expression filters in an @Filter annotation in @Enable…Repositories annotations.
This commit is contained in:
Oliver Gierke
2014-02-12 11:49:05 +01:00
parent d1faa7187d
commit 20846809e1
3 changed files with 52 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2013 the original author or authors.
* Copyright 2012-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@ import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.core.env.Environment;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.StandardAnnotationMetadata;
@@ -39,13 +40,16 @@ public class AnnotationRepositoryConfigurationSourceUnitTests {
RepositoryConfigurationSource source;
Environment environment;
ResourceLoader resourceLoader;
@Before
public void setUp() {
AnnotationMetadata annotationMetadata = new StandardAnnotationMetadata(SampleConfiguration.class, true);
environment = new StandardEnvironment();
source = new AnnotationRepositoryConfigurationSource(annotationMetadata, EnableRepositories.class, environment);
resourceLoader = new DefaultResourceLoader();
source = new AnnotationRepositoryConfigurationSource(annotationMetadata, EnableRepositories.class, resourceLoader,
environment);
}
@Test
@@ -70,7 +74,7 @@ public class AnnotationRepositoryConfigurationSourceUnitTests {
AnnotationMetadata metadata = new StandardAnnotationMetadata(DefaultConfiguration.class);
AnnotationRepositoryConfigurationSource source = new AnnotationRepositoryConfigurationSource(metadata,
EnableRepositories.class, environment);
EnableRepositories.class, resourceLoader, environment);
Iterable<String> packages = source.getBasePackages();
assertThat(packages, hasItem(DefaultConfiguration.class.getPackage().getName()));
@@ -82,7 +86,7 @@ public class AnnotationRepositoryConfigurationSourceUnitTests {
AnnotationMetadata metadata = new StandardAnnotationMetadata(DefaultConfigurationWithBasePackage.class);
AnnotationRepositoryConfigurationSource source = new AnnotationRepositoryConfigurationSource(metadata,
EnableRepositories.class, environment);
EnableRepositories.class, resourceLoader, environment);
Iterable<String> packages = source.getBasePackages();
assertThat(packages, hasItem("foo"));
@@ -96,7 +100,7 @@ public class AnnotationRepositoryConfigurationSourceUnitTests {
AnnotationMetadata metadata = new StandardAnnotationMetadata(DefaultConfigurationWithNestedRepositories.class);
AnnotationRepositoryConfigurationSource source = new AnnotationRepositoryConfigurationSource(metadata,
EnableRepositories.class, environment);
EnableRepositories.class, resourceLoader, environment);
assertThat(source.shouldConsiderNestedRepositories(), is(true));
}