mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
注解工具类支持主动清空缓存
This commit is contained in:
@@ -37,6 +37,31 @@ public class AnnotatedElementUtilTest {
|
||||
ANNOTATION6, ANNOTATION5 // Interface.class's annotations
|
||||
};
|
||||
|
||||
@Test
|
||||
public void testClearCaches() {
|
||||
AnnotatedElement type = Foo.class;
|
||||
|
||||
AnnotatedElement element = AnnotatedElementUtil.getResolvedMetaElementCache(type);
|
||||
Assert.assertSame(element, AnnotatedElementUtil.getResolvedMetaElementCache(type));
|
||||
AnnotatedElementUtil.clearCaches();
|
||||
Assert.assertNotSame(element, AnnotatedElementUtil.getResolvedMetaElementCache(type));
|
||||
|
||||
element = AnnotatedElementUtil.getMetaElementCache(type);
|
||||
Assert.assertSame(element, AnnotatedElementUtil.getMetaElementCache(type));
|
||||
AnnotatedElementUtil.clearCaches();
|
||||
Assert.assertNotSame(element, AnnotatedElementUtil.getMetaElementCache(type));
|
||||
|
||||
element = AnnotatedElementUtil.getResolvedRepeatableMetaElementCache(type);
|
||||
Assert.assertSame(element, AnnotatedElementUtil.getResolvedRepeatableMetaElementCache(type));
|
||||
AnnotatedElementUtil.clearCaches();
|
||||
Assert.assertNotSame(element, AnnotatedElementUtil.getResolvedRepeatableMetaElementCache(type));
|
||||
|
||||
element = AnnotatedElementUtil.getRepeatableMetaElementCache(type);
|
||||
Assert.assertSame(element, AnnotatedElementUtil.getRepeatableMetaElementCache(type));
|
||||
AnnotatedElementUtil.clearCaches();
|
||||
Assert.assertNotSame(element, AnnotatedElementUtil.getRepeatableMetaElementCache(type));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsAnnotated() {
|
||||
Assert.assertTrue(AnnotatedElementUtil.isAnnotated(Foo.class, Annotation1.class));
|
||||
|
@@ -19,6 +19,9 @@ public class AnnotationUtilTest {
|
||||
Annotation[] annotations = AnnotationUtil.getDeclaredAnnotations(ClassForTest.class);
|
||||
Assert.assertArrayEquals(annotations, ClassForTest.class.getDeclaredAnnotations());
|
||||
Assert.assertSame(annotations, AnnotationUtil.getDeclaredAnnotations(ClassForTest.class));
|
||||
|
||||
AnnotationUtil.clearCaches();
|
||||
Assert.assertNotSame(annotations, AnnotationUtil.getDeclaredAnnotations(ClassForTest.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user