mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
Merge pull request #3377 from yesh385/flaky-fix
Fixed 2 flaky tests in `hutool-core`
This commit is contained in:
commit
2de4a5ced2
@ -4,6 +4,7 @@ import cn.hutool.core.util.ReflectUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@ -11,6 +12,7 @@ import java.lang.annotation.Target;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* 合成注解{@link GenericSynthesizedAggregateAnnotation}的测试用例
|
||||
@ -36,9 +38,11 @@ public class GenericSynthesizedAggregateAnnotationTest {
|
||||
Assert.assertEquals(grandParentAnnotation, syntheticMetaAnnotation.getAnnotation(GrandParentAnnotation.class));
|
||||
Assert.assertEquals(parentAnnotation, syntheticMetaAnnotation.getAnnotation(ParentAnnotation.class));
|
||||
Assert.assertEquals(childAnnotation, syntheticMetaAnnotation.getAnnotation(ChildAnnotation.class));
|
||||
Annotation[] synthesizedAnnotations = syntheticMetaAnnotation.getAnnotations();
|
||||
Arrays.sort(synthesizedAnnotations, Comparator.comparing(Annotation::toString));
|
||||
Assert.assertEquals(
|
||||
Arrays.asList(childAnnotation, grandParentAnnotation, parentAnnotation),
|
||||
Arrays.asList(syntheticMetaAnnotation.getAnnotations())
|
||||
Arrays.asList(synthesizedAnnotations)
|
||||
);
|
||||
|
||||
// 扩展方法
|
||||
|
@ -15,6 +15,7 @@ import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -225,8 +226,10 @@ public class ReflectUtilTest {
|
||||
final Method[] methods = ReflectUtil.getMethods(TestInterface3.class);
|
||||
Assert.assertEquals(4, methods.length);
|
||||
|
||||
Arrays.sort(methods, Comparator.comparing(Method::toString));
|
||||
// 接口里,调用getMethods和getPublicMethods效果相同
|
||||
final Method[] publicMethods = ReflectUtil.getPublicMethods(TestInterface3.class);
|
||||
Arrays.sort(publicMethods, Comparator.comparing(Method::toString));
|
||||
Assert.assertArrayEquals(methods, publicMethods);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user