mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
@@ -26,4 +26,6 @@ public @interface AnnotationForTest {
|
||||
|
||||
@Alias("value")
|
||||
String retry() default "";
|
||||
|
||||
String[] names() default "";
|
||||
}
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package cn.hutool.core.annotation;
|
||||
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
@@ -34,6 +36,12 @@ public class AnnotationUtilTest {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAnnotationValueTest2() {
|
||||
String[] names = AnnotationUtil.getAnnotationValue(ClassWithAnnotation.class, AnnotationForTest::names);
|
||||
Assert.assertTrue(ArrayUtil.equals(names, new String[]{"测试1", "测试2"}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAnnotationSyncAlias() {
|
||||
// 直接获取
|
||||
@@ -45,7 +53,7 @@ public class AnnotationUtilTest {
|
||||
Assert.assertTrue(AnnotationUtil.isSynthesizedAnnotation(annotation));
|
||||
}
|
||||
|
||||
@AnnotationForTest("测试")
|
||||
@AnnotationForTest(value = "测试", names = {"测试1", "测试2"})
|
||||
@RepeatAnnotationForTest
|
||||
static class ClassWithAnnotation{
|
||||
public void test(){
|
||||
|
Reference in New Issue
Block a user