Search in sources :

Example 1 with SimpleMetadataReaderFactory

use of cn.taketoday.core.type.classreading.SimpleMetadataReaderFactory in project today-infrastructure by TAKETODAY.

the class AnnotationMetadataTests method composedAnnotationWithMetaAnnotationsWithIdenticalAttributeNamesUsingAnnotationMetadataReadingVisitor.

@Test
// SPR-11649
void composedAnnotationWithMetaAnnotationsWithIdenticalAttributeNamesUsingAnnotationMetadataReadingVisitor() throws Exception {
    MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
    MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(NamedComposedAnnotationClass.class.getName());
    AnnotationMetadata metadata = metadataReader.getAnnotationMetadata();
    assertMultipleAnnotationsWithIdenticalAttributeNames(metadata);
}
Also used : SimpleMetadataReaderFactory(cn.taketoday.core.type.classreading.SimpleMetadataReaderFactory) MetadataReaderFactory(cn.taketoday.core.type.classreading.MetadataReaderFactory) SimpleMetadataReaderFactory(cn.taketoday.core.type.classreading.SimpleMetadataReaderFactory) MetadataReader(cn.taketoday.core.type.classreading.MetadataReader) Test(org.junit.jupiter.api.Test)

Example 2 with SimpleMetadataReaderFactory

use of cn.taketoday.core.type.classreading.SimpleMetadataReaderFactory in project today-infrastructure by TAKETODAY.

the class AspectJTypeFilterTests method assertMatch.

private void assertMatch(String type, String typePattern) throws Exception {
    MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
    MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(type);
    AspectJTypeFilter filter = new AspectJTypeFilter(typePattern, getClass().getClassLoader());
    assertThat(filter.match(metadataReader, metadataReaderFactory)).isTrue();
    ClassloadingAssertions.assertClassNotLoaded(type);
}
Also used : AspectJTypeFilter(cn.taketoday.core.type.filter.AspectJTypeFilter) SimpleMetadataReaderFactory(cn.taketoday.core.type.classreading.SimpleMetadataReaderFactory) MetadataReaderFactory(cn.taketoday.core.type.classreading.MetadataReaderFactory) SimpleMetadataReaderFactory(cn.taketoday.core.type.classreading.SimpleMetadataReaderFactory) MetadataReader(cn.taketoday.core.type.classreading.MetadataReader)

Example 3 with SimpleMetadataReaderFactory

use of cn.taketoday.core.type.classreading.SimpleMetadataReaderFactory in project today-infrastructure by TAKETODAY.

the class AnnotationTypeFilterTests method inheritedAnnotationFromInterfaceDoesNotMatch.

@Test
void inheritedAnnotationFromInterfaceDoesNotMatch() throws Exception {
    MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
    String classUnderTest = "type.AnnotationTypeFilterTestsTypes$SomeClassWithSomeComponentInterface";
    MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(classUnderTest);
    AnnotationTypeFilter filter = new AnnotationTypeFilter(InheritedAnnotation.class);
    // Must fail as annotation on interfaces should not be considered a match
    assertThat(filter.match(metadataReader, metadataReaderFactory)).isFalse();
    ClassloadingAssertions.assertClassNotLoaded(classUnderTest);
}
Also used : AnnotationTypeFilter(cn.taketoday.core.type.filter.AnnotationTypeFilter) SimpleMetadataReaderFactory(cn.taketoday.core.type.classreading.SimpleMetadataReaderFactory) MetadataReaderFactory(cn.taketoday.core.type.classreading.MetadataReaderFactory) SimpleMetadataReaderFactory(cn.taketoday.core.type.classreading.SimpleMetadataReaderFactory) MetadataReader(cn.taketoday.core.type.classreading.MetadataReader) Test(org.junit.jupiter.api.Test)

Example 4 with SimpleMetadataReaderFactory

use of cn.taketoday.core.type.classreading.SimpleMetadataReaderFactory in project today-infrastructure by TAKETODAY.

the class AnnotationTypeFilterTests method nonInheritedAnnotationDoesNotMatch.

@Test
void nonInheritedAnnotationDoesNotMatch() throws Exception {
    MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
    String classUnderTest = "type.AnnotationTypeFilterTestsTypes$SomeSubclassOfSomeClassMarkedWithNonInheritedAnnotation";
    MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(classUnderTest);
    AnnotationTypeFilter filter = new AnnotationTypeFilter(NonInheritedAnnotation.class);
    // Must fail as annotation isn't inherited
    assertThat(filter.match(metadataReader, metadataReaderFactory)).isFalse();
    ClassloadingAssertions.assertClassNotLoaded(classUnderTest);
}
Also used : AnnotationTypeFilter(cn.taketoday.core.type.filter.AnnotationTypeFilter) SimpleMetadataReaderFactory(cn.taketoday.core.type.classreading.SimpleMetadataReaderFactory) MetadataReaderFactory(cn.taketoday.core.type.classreading.MetadataReaderFactory) SimpleMetadataReaderFactory(cn.taketoday.core.type.classreading.SimpleMetadataReaderFactory) MetadataReader(cn.taketoday.core.type.classreading.MetadataReader) Test(org.junit.jupiter.api.Test)

Example 5 with SimpleMetadataReaderFactory

use of cn.taketoday.core.type.classreading.SimpleMetadataReaderFactory in project today-infrastructure by TAKETODAY.

the class AnnotationTypeFilterTests method inheritedAnnotationFromBaseClassDoesMatch.

@Test
void inheritedAnnotationFromBaseClassDoesMatch() throws Exception {
    MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
    String classUnderTest = "type.AnnotationTypeFilterTestsTypes$SomeSubclassOfSomeComponent";
    MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(classUnderTest);
    AnnotationTypeFilter filter = new AnnotationTypeFilter(InheritedAnnotation.class);
    assertThat(filter.match(metadataReader, metadataReaderFactory)).isTrue();
    ClassloadingAssertions.assertClassNotLoaded(classUnderTest);
}
Also used : AnnotationTypeFilter(cn.taketoday.core.type.filter.AnnotationTypeFilter) SimpleMetadataReaderFactory(cn.taketoday.core.type.classreading.SimpleMetadataReaderFactory) MetadataReaderFactory(cn.taketoday.core.type.classreading.MetadataReaderFactory) SimpleMetadataReaderFactory(cn.taketoday.core.type.classreading.SimpleMetadataReaderFactory) MetadataReader(cn.taketoday.core.type.classreading.MetadataReader) Test(org.junit.jupiter.api.Test)

Aggregations

SimpleMetadataReaderFactory (cn.taketoday.core.type.classreading.SimpleMetadataReaderFactory)50 MetadataReader (cn.taketoday.core.type.classreading.MetadataReader)44 MetadataReaderFactory (cn.taketoday.core.type.classreading.MetadataReaderFactory)44 Test (org.junit.jupiter.api.Test)42 AnnotationTypeFilter (cn.taketoday.core.type.filter.AnnotationTypeFilter)12 AnnotatedBeanDefinition (cn.taketoday.beans.factory.annotation.AnnotatedBeanDefinition)10 AssignableTypeFilter (cn.taketoday.core.type.filter.AssignableTypeFilter)8 AnnotatedGenericBeanDefinition (cn.taketoday.beans.factory.annotation.AnnotatedGenericBeanDefinition)4 ScopeMetadata (cn.taketoday.context.loader.ScopeMetadata)4 AspectJTypeFilter (cn.taketoday.core.type.filter.AspectJTypeFilter)4