添加获得类直接声明方法的静态方法

This commit is contained in:
huangchengxing
2022-09-21 19:33:12 +08:00
parent 84db7222f0
commit 7932e73395
5 changed files with 35 additions and 17 deletions

View File

@@ -127,7 +127,7 @@ public class AnnotationUtilTest {
@Test
public void testGetAnnotationAttributes() {
Method[] methods = AnnotationUtil.getAnnotationAttributes(AnnotationForTest.class);
Assert.assertSame(methods, AnnotationUtil.getAnnotationAttributes(AnnotationForTest.class));
Assert.assertArrayEquals(methods, AnnotationUtil.getAnnotationAttributes(AnnotationForTest.class));
Assert.assertEquals(1, methods.length);
Assert.assertArrayEquals(AnnotationForTest.class.getDeclaredMethods(), methods);
}

View File

@@ -81,6 +81,18 @@ public class MethodUtilTest {
Assert.assertEquals(10, testClass.getA());
}
@Test
public void getDeclaredMethodsTest() {
Class<?> type = ReflectUtilTest.TestBenchClass.class;
Method[] methods = type.getDeclaredMethods();
Assert.assertArrayEquals(methods, MethodUtil.getDeclaredMethods(type));
Assert.assertSame(MethodUtil.getDeclaredMethods(type), MethodUtil.getDeclaredMethods(type));
type = Object.class;
methods = type.getDeclaredMethods();
Assert.assertArrayEquals(methods, MethodUtil.getDeclaredMethods(type));
}
@Test
@Ignore
public void getMethodBenchTest() {