mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
ReflectUtilTest增加:测试方法,验证对 final属性的修改
This commit is contained in:
parent
fae97d0d3e
commit
bcfbd28c12
@ -0,0 +1,9 @@
|
||||
package cn.hutool.core.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class JdbcDialects {
|
||||
private static final List<Number> DIALECTS =
|
||||
Arrays.asList(1L, 2L, 3L);
|
||||
}
|
@ -13,7 +13,9 @@ import org.junit.Test;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -268,4 +270,18 @@ public class ReflectUtilTest {
|
||||
int[] intArray = ReflectUtil.newInstanceIfPossible(int[].class);
|
||||
Assert.assertArrayEquals(new int[0], intArray);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setFieldValueTest() {
|
||||
String fieldName = "DIALECTS";
|
||||
final List<Number> dialects =
|
||||
Arrays.asList(
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
99
|
||||
);
|
||||
ReflectUtil.setFieldValue(JdbcDialects.class, fieldName, dialects);
|
||||
Assert.assertEquals(dialects, ReflectUtil.getFieldValue(JdbcDialects.class, fieldName));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user