ReflectionUtilsTests.java 文件源码

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

项目:mqnaas 作者:
@Test
public void testGetAnnotationFieldsWithSimpelClass() {
    List<Field> fields = ReflectionUtils.getAnnotationFields(SimpleClass.class, TestAnnotation.class);
    Assert.assertEquals("SimpleClass does not contain any field annotated with TestAnnotation", 0, fields.size());

    fields = ReflectionUtils.getAnnotationFields(SimpleClassWithAnnotation.class, TestAnnotation.class);
    Assert.assertEquals("SimpleClassWithAnnotation contains a field annotated with TestAnnotation", 1, fields.size());

    fields = ReflectionUtils.getAnnotationFields(SubClass.class, TestAnnotation.class);
    Assert.assertEquals("SubClass contains a superclass field annotated with TestAnnotation", 1, fields.size());

    fields = ReflectionUtils.getAnnotationFields(SubSubClass.class, TestAnnotation.class);
    Assert.assertEquals("SubClass contains a field and a superclass field annotated with TestAnnotation", 2, fields.size());

    fields = ReflectionUtils.getAnnotationFields(SubSubClass.class, Target.class);
    Assert.assertEquals("SubClass contains no fields annotated with Target", 0, fields.size());

}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号