1、BeanUtil本地简单测试
在项目中由于需要对某些对象进行深度拷贝然后进行持久化操作,想到了apache和spring都提供了BeanUtils的深度拷贝工具包,自己写了几个Demo做测试,定义了两个类User和Person,其中User的属性引用了Person类。
public classUser {private intid;private String username;//用户姓名
private String sex;//性别
private Date birthday;//生日
private String address;//地址
private Person person; //包装类//get set方法此处省略
}
//Person类
public classPerson {private intid;privateString userName ;private intage ;privateString mobilePhone ;publicPerson(){}public Person(int id,String userName, intage, String mobilePhone) {this.id =id;this.userName =userName;this.age =age;this.mobilePhone =mobilePhone;
}//get set方法此处省略
}
编写测试方法进行调研,主要是查看对象中包装的对象是否引用了同一个地址,从而判断是否是深度拷贝还是浅拷贝
@Testpublic voidCopyTest(){
User user=newUser();
user.setId(1);
user.setSex(