|
|
@ -33,6 +33,7 @@ import org.springframework.boot.context.annotation.DeterminableImports;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.context.annotation.Import;
|
|
|
|
import org.springframework.context.annotation.Import;
|
|
|
|
import org.springframework.context.annotation.ImportSelector;
|
|
|
|
import org.springframework.context.annotation.ImportSelector;
|
|
|
|
|
|
|
|
import org.springframework.core.annotation.AliasFor;
|
|
|
|
import org.springframework.core.type.AnnotationMetadata;
|
|
|
|
import org.springframework.core.type.AnnotationMetadata;
|
|
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
@ -41,6 +42,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
* Tests for {@link ImportsContextCustomizer}.
|
|
|
|
* Tests for {@link ImportsContextCustomizer}.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @author Andy Wilkinson
|
|
|
|
* @author Andy Wilkinson
|
|
|
|
|
|
|
|
* @author Laurent Martelli
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
class ImportsContextCustomizerTests {
|
|
|
|
class ImportsContextCustomizerTests {
|
|
|
|
|
|
|
|
|
|
|
@ -80,6 +82,30 @@ class ImportsContextCustomizerTests {
|
|
|
|
.isEqualTo(new ImportsContextCustomizer(SecondJUnitAnnotatedTestClass.class));
|
|
|
|
.isEqualTo(new ImportsContextCustomizer(SecondJUnitAnnotatedTestClass.class));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
void customizersForClassesWithDifferentImportsAreNotEqual() {
|
|
|
|
|
|
|
|
assertThat(new ImportsContextCustomizer(FirstAnnotatedTestClass.class))
|
|
|
|
|
|
|
|
.isNotEqualTo(new ImportsContextCustomizer(SecondAnnotatedTestClass.class));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
void customizersForClassesWithDifferentMetaImportsAreNotEqual() {
|
|
|
|
|
|
|
|
assertThat(new ImportsContextCustomizer(FirstMetaAnnotatedTestClass.class))
|
|
|
|
|
|
|
|
.isNotEqualTo(new ImportsContextCustomizer(SecondMetaAnnotatedTestClass.class));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
void customizersForClassesWithDifferentAliasedImportsAreNotEqual() {
|
|
|
|
|
|
|
|
assertThat(new ImportsContextCustomizer(FirstAliasAnnotatedTestClass.class))
|
|
|
|
|
|
|
|
.isNotEqualTo(new ImportsContextCustomizer(SecondAliasAnnotatedTestClass.class));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
void importsCanBeScatteredOnMultipleAnnotations() {
|
|
|
|
|
|
|
|
assertThat(new ImportsContextCustomizer(SingleImportAnnotationTestClass.class))
|
|
|
|
|
|
|
|
.isEqualTo(new ImportsContextCustomizer(MultipleImportAnnotationTestClass.class));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Import(TestImportSelector.class)
|
|
|
|
@Import(TestImportSelector.class)
|
|
|
|
@Indicator1
|
|
|
|
@Indicator1
|
|
|
|
static class FirstImportSelectorAnnotatedClass {
|
|
|
|
static class FirstImportSelectorAnnotatedClass {
|
|
|
@ -152,6 +178,17 @@ class ImportsContextCustomizerTests {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Import({ FirstImportedClass.class, SecondImportedClass.class })
|
|
|
|
|
|
|
|
static class SingleImportAnnotationTestClass {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@FirstMetaImport
|
|
|
|
|
|
|
|
@Import(SecondImportedClass.class)
|
|
|
|
|
|
|
|
static class MultipleImportAnnotationTestClass {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Retention(RetentionPolicy.RUNTIME)
|
|
|
|
@Retention(RetentionPolicy.RUNTIME)
|
|
|
|
@interface Indicator1 {
|
|
|
|
@interface Indicator1 {
|
|
|
|
|
|
|
|
|
|
|
@ -162,6 +199,65 @@ class ImportsContextCustomizerTests {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Retention(RetentionPolicy.RUNTIME)
|
|
|
|
|
|
|
|
@Import(AliasFor.class)
|
|
|
|
|
|
|
|
public @interface AliasedImport {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@AliasFor(annotation = Import.class)
|
|
|
|
|
|
|
|
Class<?>[] value();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Retention(RetentionPolicy.RUNTIME)
|
|
|
|
|
|
|
|
@Import(FirstImportedClass.class)
|
|
|
|
|
|
|
|
public @interface FirstMetaImport {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Retention(RetentionPolicy.RUNTIME)
|
|
|
|
|
|
|
|
@Import(SecondImportedClass.class)
|
|
|
|
|
|
|
|
public @interface SecondMetaImport {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static class FirstImportedClass {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static class SecondImportedClass {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@AliasedImport(FirstImportedClass.class)
|
|
|
|
|
|
|
|
static class FirstAliasAnnotatedTestClass {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@AliasedImport(SecondImportedClass.class)
|
|
|
|
|
|
|
|
static class SecondAliasAnnotatedTestClass {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@FirstMetaImport
|
|
|
|
|
|
|
|
static class FirstMetaAnnotatedTestClass {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SecondMetaImport
|
|
|
|
|
|
|
|
static class SecondMetaAnnotatedTestClass {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Import(FirstImportedClass.class)
|
|
|
|
|
|
|
|
static class FirstAnnotatedTestClass {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Import(SecondImportedClass.class)
|
|
|
|
|
|
|
|
static class SecondAnnotatedTestClass {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static class TestImportSelector implements ImportSelector {
|
|
|
|
static class TestImportSelector implements ImportSelector {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|