Examples of SimpleMetadataReaderFactory


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

* @author Juergen Hoeller
*/
public class AssignableTypeFilterTests extends TestCase {

  public void testDirectMatch() 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));
View Full Code Here

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

    assertFalse(notMatchingFilter.match(metadataReader, metadataReaderFactory));
    assertTrue(matchingFilter.match(metadataReader, metadataReaderFactory));
  }
 
  public void testInterfaceMatch() throws Exception {
    MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
    String classUnderTest = "org.springframework.core.type.AssignableTypeFilterTests$TestInterfaceImpl";
    MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(classUnderTest);

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

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

    assertTrue(filter.match(metadataReader, metadataReaderFactory));
    ClassloadingAssertions.assertClassNotLoaded(classUnderTest);
  }
 
  public void testSuperClassMatch() throws Exception {
    MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
    String classUnderTest = "org.springframework.core.type.AssignableTypeFilterTests$SomeDaoLikeImpl";
    MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(classUnderTest);

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

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

    assertTrue(filter.match(metadataReader, metadataReaderFactory));
    ClassloadingAssertions.assertClassNotLoaded(classUnderTest);
  }
 
  public void testInterfaceThroughSuperClassMatch() throws Exception {
    MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
    String classUnderTest = "org.springframework.core.type.AssignableTypeFilterTests$SomeDaoLikeImpl";
    MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(classUnderTest);

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

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

    assertEquals(ScopedProxyMode.NO, scopeMetadata.getScopedProxyMode());
  }

  @Test
  public void testCustomRequestScopeViaAsm() throws IOException {
    MetadataReaderFactory readerFactory = new SimpleMetadataReaderFactory();
    MetadataReader reader = readerFactory.getMetadataReader(AnnotatedWithCustomRequestScope.class.getName());
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(reader.getAnnotationMetadata());
    ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(bd);
    assertNotNull("resolveScopeMetadata(..) must *never* return null.", scopeMetadata);
    assertEquals("request", scopeMetadata.getScopeName());
    assertEquals(ScopedProxyMode.NO, scopeMetadata.getScopedProxyMode());
View Full Code Here

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

    assertEquals(ScopedProxyMode.TARGET_CLASS, scopeMetadata.getScopedProxyMode());
  }

  @Test
  public void testCustomRequestScopeWithAttributeViaAsm() throws IOException {
    MetadataReaderFactory readerFactory = new SimpleMetadataReaderFactory();
    MetadataReader reader = readerFactory.getMetadataReader(AnnotatedWithCustomRequestScopeWithAttribute.class.getName());
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(reader.getAnnotationMetadata());
    ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(bd);
    assertNotNull("resolveScopeMetadata(..) must *never* return null.", scopeMetadata);
    assertEquals("request", scopeMetadata.getScopeName());
    assertEquals(ScopedProxyMode.TARGET_CLASS, scopeMetadata.getScopedProxyMode());
View Full Code Here

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

                                                                                                                           classLoader );
        String patternFinder = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX
            + ClassUtils.convertClassNameToResourcePath( packageName ) + "/**/*.class";

        Resource[] resources = pathMatchingResourcePatternResolver.getResources( patternFinder );
        SimpleMetadataReaderFactory simpleMetadataReaderFactory = new SimpleMetadataReaderFactory();
        getLogger().debug( "springresource " + resources.length + " for pattern " + patternFinder );
        for ( Resource resource : resources )
        {
            getLogger().debug( "springresource " + resource.getFilename() );
            MetadataReader metadataReader = simpleMetadataReaderFactory.getMetadataReader( resource );

      AnnotationMetadata annotationMetadata = getAnnotationMetadataIfServlet(metadataReader,
                                           simpleMetadataReaderFactory,
                                           pathMatchingResourcePatternResolver);
            if ( annotationMetadata != null )
View Full Code Here

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

*/
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

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

    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

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

    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
TOP
Copyright © 2018 www.massapi.com. 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.