Make it easier to add auto-configuration to a test slice
Previously, an entry had to be added to spring.factories using the name of one of the @AutoConfigure… meta-annotations on the @…Test annotation as the key. This indirection was unnecessarily complicated. This commit simplifies things by allowing the name of the @…Test annotation itself to be used as the key. Closes gh-6335
This commit is contained in:
@@ -76,12 +76,21 @@ TestSlice createTestSlice(Properties springFactories, ClassMetadata classMetadat
|
||||
}
|
||||
|
||||
Set<String> getImportedAutoConfiguration(Properties springFactories, ClassMetadata classMetadata, AnnotationMetadata annotationMetadata) {
|
||||
Set<String> importers = findMetaImporters(annotationMetadata)
|
||||
if (annotationMetadata.isAnnotated('org.springframework.boot.autoconfigure.ImportAutoConfiguration')) {
|
||||
importers.add(annotationMetadata.className)
|
||||
}
|
||||
importers
|
||||
.collect { autoConfigurationImporter ->
|
||||
StringUtils.commaDelimitedListToSet(springFactories.get(autoConfigurationImporter))
|
||||
}.flatten()
|
||||
}
|
||||
|
||||
Set<String> findMetaImporters(AnnotationMetadata annotationMetadata) {
|
||||
annotationMetadata.annotationTypes
|
||||
.findAll { annotationType ->
|
||||
isAutoConfigurationImporter(annotationType, annotationMetadata)
|
||||
}.collect { autoConfigurationImporter ->
|
||||
StringUtils.commaDelimitedListToSet(springFactories.get(autoConfigurationImporter))
|
||||
}.flatten()
|
||||
}
|
||||
}
|
||||
|
||||
boolean isAutoConfigurationImporter(String annotationType, AnnotationMetadata metadata) {
|
||||
|
||||
Reference in New Issue
Block a user