mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add test
This commit is contained in:
@@ -6,6 +6,7 @@ import cn.hutool.core.lang.test.bean.ExamInfoDict;
|
|||||||
import cn.hutool.core.text.StrUtil;
|
import cn.hutool.core.text.StrUtil;
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
import cn.hutool.core.util.SystemUtil;
|
import cn.hutool.core.util.SystemUtil;
|
||||||
|
import lombok.Data;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -216,4 +217,33 @@ public class MethodUtilTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
static class TestClass {
|
||||||
|
private int a;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void invokeMethodTest() {
|
||||||
|
final TestClass testClass = new TestClass();
|
||||||
|
final Method method = MethodUtil.getMethod(TestClass.class, "setA", int.class);
|
||||||
|
MethodUtil.invoke(testClass, method, 10);
|
||||||
|
Assert.assertEquals(10, testClass.getA());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void invokeMethodWithParamConvertTest() {
|
||||||
|
final TestClass testClass = new TestClass();
|
||||||
|
final Method method = MethodUtil.getMethod(TestClass.class, "setA", int.class);
|
||||||
|
MethodUtil.invoke(testClass, method, "10");
|
||||||
|
Assert.assertEquals(10, testClass.getA());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void invokeMethodWithParamConvertFailedTest() {
|
||||||
|
final TestClass testClass = new TestClass();
|
||||||
|
final Method method = MethodUtil.getMethod(TestClass.class, "setA", int.class);
|
||||||
|
Assert.assertThrows(IllegalArgumentException.class,
|
||||||
|
() -> MethodUtil.invoke(testClass, method, "NaN"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -479,7 +479,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>QLExpress</artifactId>
|
<artifactId>QLExpress</artifactId>
|
||||||
<version>3.3.0</version>
|
<version>3.3.1</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
Reference in New Issue
Block a user