@ -37,6 +37,7 @@ import org.springframework.core.env.Environment;
import org.springframework.core.io.DefaultResourceLoader ;
import org.springframework.core.type.AnnotationMetadata ;
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory ;
import org.springframework.util.ClassUtils ;
import static org.assertj.core.api.Assertions.assertThat ;
import static org.mockito.Mockito.verifyZeroInteractions ;
@ -125,7 +126,6 @@ public class ImportAutoConfigurationImportSelectorTests {
public void exclusionsAliasesAreApplied ( ) throws Exception {
AnnotationMetadata annotationMetadata = getAnnotationMetadata (
ImportWithSelfAnnotatingAnnotationExclude . class ) ;
String [ ] imports = this . importSelector . selectImports ( annotationMetadata ) ;
assertThat ( imports ) . isEmpty ( ) ;
}
@ -182,6 +182,19 @@ public class ImportAutoConfigurationImportSelectorTests {
assertThat ( set1 ) . isNotEqualTo ( set2 ) ;
}
@Test
public void determineImportsShouldNotSetPackageImport ( ) throws Exception {
Class < ? > packageImportClass = ClassUtils . resolveClassName (
"org.springframework.boot.autoconfigure.AutoConfigurationPackages.PackageImport" ,
null ) ;
Set < Object > selectedImports = this . importSelector
. determineImports ( getAnnotationMetadata (
ImportMetaAutoConfigurationExcludeWithUnrelatedOne . class ) ) ;
for ( Object selectedImport : selectedImports ) {
assertThat ( selectedImport ) . isNotInstanceOf ( packageImportClass ) ;
}
}
private AnnotationMetadata getAnnotationMetadata ( Class < ? > source ) throws IOException {
return new SimpleMetadataReaderFactory ( ) . getMetadataReader ( source . getName ( ) )
. getAnnotationMetadata ( ) ;