use of org.springframework.core.type.classreading.MetadataReader in project spring-framework by spring-projects.
the class AnnotationTypeFilterTests method testDirectAnnotationMatch.
@Test
public void testDirectAnnotationMatch() throws Exception {
MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
String classUnderTest = "org.springframework.core.type.AnnotationTypeFilterTests$SomeComponent";
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(classUnderTest);
AnnotationTypeFilter filter = new AnnotationTypeFilter(InheritedAnnotation.class);
assertTrue(filter.match(metadataReader, metadataReaderFactory));
ClassloadingAssertions.assertClassNotLoaded(classUnderTest);
}
use of org.springframework.core.type.classreading.MetadataReader in project spring-framework by spring-projects.
the class AnnotationTypeFilterTests method testNonInheritedAnnotationDoesNotMatch.
@Test
public void testNonInheritedAnnotationDoesNotMatch() throws Exception {
MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
String classUnderTest = "org.springframework.core.type.AnnotationTypeFilterTests$SomeSubclassOfSomeClassMarkedWithNonInheritedAnnotation";
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(classUnderTest);
AnnotationTypeFilter filter = new AnnotationTypeFilter(NonInheritedAnnotation.class);
// Must fail as annotation isn't inherited
assertFalse(filter.match(metadataReader, metadataReaderFactory));
ClassloadingAssertions.assertClassNotLoaded(classUnderTest);
}
use of org.springframework.core.type.classreading.MetadataReader in project spring-framework by spring-projects.
the class AnnotationTypeFilterTests method testMatchesInterfacesIfConfigured.
@Test
public void testMatchesInterfacesIfConfigured() throws Exception {
MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
String classUnderTest = "org.springframework.core.type.AnnotationTypeFilterTests$SomeComponentInterface";
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(classUnderTest);
AnnotationTypeFilter filter = new AnnotationTypeFilter(InheritedAnnotation.class, false, true);
assertTrue(filter.match(metadataReader, metadataReaderFactory));
ClassloadingAssertions.assertClassNotLoaded(classUnderTest);
}
use of org.springframework.core.type.classreading.MetadataReader in project spring-framework by spring-projects.
the class AspectJTypeFilterTests method assertNoMatch.
private void assertNoMatch(String type, String typePattern) throws Exception {
MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(type);
AspectJTypeFilter filter = new AspectJTypeFilter(typePattern, getClass().getClassLoader());
assertFalse(filter.match(metadataReader, metadataReaderFactory));
ClassloadingAssertions.assertClassNotLoaded(type);
}
use of org.springframework.core.type.classreading.MetadataReader in project spring-framework by spring-projects.
the class AssignableTypeFilterTests method directMatch.
@Test
public void directMatch() throws Exception {
MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
String classUnderTest = "org.springframework.core.type.AssignableTypeFilterTests$TestNonInheritingClass";
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(classUnderTest);
AssignableTypeFilter matchingFilter = new AssignableTypeFilter(TestNonInheritingClass.class);
AssignableTypeFilter notMatchingFilter = new AssignableTypeFilter(TestInterface.class);
assertFalse(notMatchingFilter.match(metadataReader, metadataReaderFactory));
assertTrue(matchingFilter.match(metadataReader, metadataReaderFactory));
}
Aggregations