ClassUtilTest.java 文件源码

java
阅读 24 收藏 0 点赞 0 评论 0

项目:SocialDataImporter 作者:
/**
 * Test method for {@link ch.sdi.core.util.ClassUtil#findCandidatesByAnnotation(java.lang.Class, java.lang.String)}.
 */
@Test
public void testFindCandidatesByAnnotationAndType()
{
    myLog.debug( "we parse all classes which are below the top level package" );
    String pack = this.getClass().getPackage().getName();
    myLog.debug( "found package: " + pack );
    pack = pack.replace( '.', '/' );
    String root = pack.split( "/" )[0];

    Collection<? extends Class<?>> received = ClassUtil.findCandidatesByAnnotation( ConverterFactory.class,
                                                                                    Component.class,
                                                                                    root );

    Assert.assertNotNull( received );
    Assert.assertEquals( 1, received.size() );
    received.forEach( c -> myLog.debug( "Found class with annotation @Component and type 'ConverterFactory': "
                + c.getName() ) );

}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号