Search in sources :

Example 11 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 12 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 13 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 14 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 15 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)20 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)3 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 ThymeleafAutoConfiguration (org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration)2 MethodMetadata (org.springframework.core.type.MethodMetadata)2 MetadataReader (org.springframework.core.type.classreading.MetadataReader)2 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 AnnotatedBeanDefinition (org.springframework.beans.factory.annotation.AnnotatedBeanDefinition)1 AnnotatedGenericBeanDefinition (org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition)1 BeanDefinitionHolder (org.springframework.beans.factory.config.BeanDefinitionHolder)1 AbstractBeanDefinition (org.springframework.beans.factory.support.AbstractBeanDefinition)1 Bean (org.springframework.context.annotation.Bean)1 Configuration (org.springframework.context.annotation.Configuration)1 ConfigurationPhase (org.springframework.context.annotation.ConfigurationCondition.ConfigurationPhase)1 NestedIOException (org.springframework.core.NestedIOException)1