mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -3,6 +3,8 @@ package cn.hutool.core.bean;
|
||||
import cn.hutool.core.lang.test.bean.ExamInfoDict;
|
||||
import cn.hutool.core.lang.test.bean.UserInfoDict;
|
||||
import cn.hutool.core.map.Dict;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import lombok.Data;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -152,4 +154,36 @@ public class BeanPathTest {
|
||||
BeanPath.of("aa.bb").set(dict, "BB");
|
||||
Assert.assertEquals("{aa={bb=BB}}", dict.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void appendArrayTest(){
|
||||
// issue#3008@Github
|
||||
final MyUser myUser = new MyUser();
|
||||
BeanPath.of("hobby[0]").set(myUser, "LOL");
|
||||
BeanPath.of("hobby[1]").set(myUser, "KFC");
|
||||
BeanPath.of("hobby[2]").set(myUser, "COFFE");
|
||||
|
||||
Assert.assertEquals("[LOL, KFC, COFFE]", ArrayUtil.toString(myUser.getHobby()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void appendArrayTest2(){
|
||||
// issue#3008@Github
|
||||
final MyUser2 myUser = new MyUser2();
|
||||
BeanPath.of("myUser.hobby[0]").set(myUser, "LOL");
|
||||
BeanPath.of("myUser.hobby[1]").set(myUser, "KFC");
|
||||
BeanPath.of("myUser.hobby[2]").set(myUser, "COFFE");
|
||||
|
||||
Assert.assertEquals("[LOL, KFC, COFFE]", ArrayUtil.toString(myUser.getMyUser().getHobby()));
|
||||
}
|
||||
|
||||
@Data
|
||||
static class MyUser {
|
||||
private String[] hobby;
|
||||
}
|
||||
|
||||
@Data
|
||||
static class MyUser2 {
|
||||
private MyUser myUser;
|
||||
}
|
||||
}
|
||||
|
@@ -78,10 +78,17 @@ public class NetUtilTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void getLocalHostNameTest() {
|
||||
// 注意此方法会触发反向DNS解析,导致阻塞,阻塞时间取决于网络!
|
||||
Assert.assertNotNull(NetUtil.getLocalHostName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLocalHostTest() {
|
||||
Assert.assertNotNull(NetUtil.getLocalhost());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pingTest(){
|
||||
Assert.assertTrue(NetUtil.ping("127.0.0.1"));
|
||||
|
Reference in New Issue
Block a user