Package org.springframework.core.type.classreading

Examples of org.springframework.core.type.classreading.MetadataReaderFactory


*/
public class AnnotationTypeFilterTests {

  @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);
  }
View Full Code Here


    ClassloadingAssertions.assertClassNotLoaded(classUnderTest);
  }

  @Test
  public void testInheritedAnnotationFromInterfaceDoesNotMatch() throws Exception {
    MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
    String classUnderTest = "org.springframework.core.type.AnnotationTypeFilterTests$SomeSubClassOfSomeComponentInterface";
    MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(classUnderTest);

    AnnotationTypeFilter filter = new AnnotationTypeFilter(InheritedAnnotation.class);
    // Must fail as annotation on interfaces should not be considered a match
    assertFalse(filter.match(metadataReader, metadataReaderFactory));
    ClassloadingAssertions.assertClassNotLoaded(classUnderTest);
View Full Code Here

    ClassloadingAssertions.assertClassNotLoaded(classUnderTest);
  }

  @Test
  public void testInheritedAnnotationFromBaseClassDoesMatch() throws Exception {
    MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
    String classUnderTest = "org.springframework.core.type.AnnotationTypeFilterTests$SomeSubClassOfSomeComponent";
    MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(classUnderTest);

    AnnotationTypeFilter filter = new AnnotationTypeFilter(InheritedAnnotation.class);
    assertTrue(filter.match(metadataReader, metadataReaderFactory));
    ClassloadingAssertions.assertClassNotLoaded(classUnderTest);
  }
View Full Code Here

    ClassloadingAssertions.assertClassNotLoaded(classUnderTest);
  }

  @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);
View Full Code Here

    ClassloadingAssertions.assertClassNotLoaded(classUnderTest);
  }

  @Test
  public void testNonAnnotatedClassDoesntMatch() throws Exception {
    MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
    String classUnderTest = "org.springframework.core.type.AnnotationTypeFilterTests$SomeNonCandidateClass";
    MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(classUnderTest);

    AnnotationTypeFilter filter = new AnnotationTypeFilter(Component.class);
    assertFalse(filter.match(metadataReader, metadataReaderFactory));
    ClassloadingAssertions.assertClassNotLoaded(classUnderTest);
  }
View Full Code Here

  }

  @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);
View Full Code Here

    doTestMethodAnnotationInfo(metadata);
  }

  @Test
  public void asmAnnotationMetadata() throws Exception {
    MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
    MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(AnnotatedComponent.class.getName());
    AnnotationMetadata metadata = metadataReader.getAnnotationMetadata();
    doTestAnnotationInfo(metadata);
    doTestMethodAnnotationInfo(metadata);
  }
View Full Code Here

    doTestSubClassAnnotationInfo(metadata);
  }

  @Test
  public void asmAnnotationMetadataForSubclass() throws Exception {
    MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
    MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(AnnotatedComponentSubClass.class.getName());
    AnnotationMetadata metadata = metadataReader.getAnnotationMetadata();
    doTestSubClassAnnotationInfo(metadata);
  }
View Full Code Here

    doTestMetadataForInterfaceClass(metadata);
  }

  @Test
  public void asmAnnotationMetadataForInterface() throws Exception {
    MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
    MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(AnnotationMetadata.class.getName());
    AnnotationMetadata metadata = metadataReader.getAnnotationMetadata();
    doTestMetadataForInterfaceClass(metadata);
  }
View Full Code Here

    doTestMetadataForAnnotationClass(metadata);
  }

  @Test
  public void asmAnnotationMetadataForAnnotation() throws Exception {
    MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
    MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(Component.class.getName());
    AnnotationMetadata metadata = metadataReader.getAnnotationMetadata();
    doTestMetadataForAnnotationClass(metadata);
  }
View Full Code Here

TOP

Related Classes of org.springframework.core.type.classreading.MetadataReaderFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.