Search in sources :

Example 16 with AnnotationMetadata

use of org.springframework.core.type.AnnotationMetadata in project spring-boot by spring-projects.

the class ImportAutoConfigurationImportSelectorTests method exclusionsWithoutImport.

@Test
public void exclusionsWithoutImport() throws Exception {
    AnnotationMetadata annotationMetadata = getAnnotationMetadata(ExclusionWithoutImport.class);
    String[] imports = this.importSelector.selectImports(annotationMetadata);
    assertThat(imports).containsOnly(FreeMarkerAutoConfiguration.class.getName());
}
Also used : FreeMarkerAutoConfiguration(org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration) AnnotationMetadata(org.springframework.core.type.AnnotationMetadata) Test(org.junit.Test)

Example 17 with AnnotationMetadata

use of org.springframework.core.type.AnnotationMetadata in project spring-boot by spring-projects.

the class ImportAutoConfigurationImportSelectorTests method importsAreSelected.

@Test
public void importsAreSelected() throws Exception {
    AnnotationMetadata annotationMetadata = getAnnotationMetadata(ImportFreeMarker.class);
    String[] imports = this.importSelector.selectImports(annotationMetadata);
    assertThat(imports).containsExactly(FreeMarkerAutoConfiguration.class.getName());
}
Also used : FreeMarkerAutoConfiguration(org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration) AnnotationMetadata(org.springframework.core.type.AnnotationMetadata) Test(org.junit.Test)

Example 18 with AnnotationMetadata

use of org.springframework.core.type.AnnotationMetadata in project spring-boot by spring-projects.

the class ImportAutoConfigurationImportSelectorTests method multipleImportsAreFound.

@Test
public void multipleImportsAreFound() throws Exception {
    AnnotationMetadata annotationMetadata = getAnnotationMetadata(MultipleImports.class);
    String[] imports = this.importSelector.selectImports(annotationMetadata);
    assertThat(imports).containsOnly(FreeMarkerAutoConfiguration.class.getName(), ThymeleafAutoConfiguration.class.getName());
}
Also used : FreeMarkerAutoConfiguration(org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration) ThymeleafAutoConfiguration(org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration) AnnotationMetadata(org.springframework.core.type.AnnotationMetadata) Test(org.junit.Test)

Example 19 with AnnotationMetadata

use of org.springframework.core.type.AnnotationMetadata in project spring-boot by spring-projects.

the class ImportAutoConfigurationImportSelectorTests method exclusionsAliasesAreApplied.

@Test
public void exclusionsAliasesAreApplied() throws Exception {
    AnnotationMetadata annotationMetadata = getAnnotationMetadata(ImportWithSelfAnnotatingAnnotationExclude.class);
    String[] imports = this.importSelector.selectImports(annotationMetadata);
    assertThat(imports).isEmpty();
}
Also used : AnnotationMetadata(org.springframework.core.type.AnnotationMetadata) Test(org.junit.Test)

Example 20 with AnnotationMetadata

use of org.springframework.core.type.AnnotationMetadata in project spring-boot by spring-projects.

the class AbstractConfigurationClassTests method allBeanMethodsArePublic.

@Test
public void allBeanMethodsArePublic() throws IOException, ClassNotFoundException {
    Set<String> nonPublicBeanMethods = new HashSet<>();
    for (AnnotationMetadata configurationClass : findConfigurationClasses()) {
        Set<MethodMetadata> beanMethods = configurationClass.getAnnotatedMethods(Bean.class.getName());
        for (MethodMetadata methodMetadata : beanMethods) {
            if (!isPublic(methodMetadata)) {
                nonPublicBeanMethods.add(methodMetadata.getDeclaringClassName() + "." + methodMetadata.getMethodName());
            }
        }
    }
    assertThat(nonPublicBeanMethods).as("Found non-public @Bean methods").isEmpty();
}
Also used : MethodMetadata(org.springframework.core.type.MethodMetadata) AnnotationMetadata(org.springframework.core.type.AnnotationMetadata) HashSet(java.util.HashSet) Bean(org.springframework.context.annotation.Bean) Test(org.junit.Test)

Aggregations

AnnotationMetadata (org.springframework.core.type.AnnotationMetadata)22 Test (org.junit.Test)13 StandardAnnotationMetadata (org.springframework.core.type.StandardAnnotationMetadata)7 FreeMarkerAutoConfiguration (org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration)5 AnnotationAttributes (org.springframework.core.annotation.AnnotationAttributes)4 MetadataReader (org.springframework.core.type.classreading.MetadataReader)3 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 AnnotatedBeanDefinition (org.springframework.beans.factory.annotation.AnnotatedBeanDefinition)2 ThymeleafAutoConfiguration (org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration)2 Resource (org.springframework.core.io.Resource)2 MethodMetadata (org.springframework.core.type.MethodMetadata)2 Annotation (java.lang.annotation.Annotation)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1 AnnotatedGenericBeanDefinition (org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition)1 BeanDefinitionHolder (org.springframework.beans.factory.config.BeanDefinitionHolder)1