Package com.xushouwei.cn;
Import Java.util.HashMap;
Import Java.util.Map;
Import Org.junit.Test;
Import Cn.itcast.commons.CommonUtils;
/**
* Test Commonutils class
* @author Administrator
*
*/
public class Commonutilstest {
/**
* Test: Returns a random 32-bit long string
* Commonutils class-dependent jar package
Use
* 1. Used to make ID, the primary key in the database table can not be duplicated, it is not duplicated
* 2. The activation code is not duplicated.
*
*/
@Test
public void Testuuid ()
{
String S=commonutils.uuid ();
System.out.println (s);
}
/**
* Role: To encapsulate the data in a map into a large JavaBean
* Requirements: Requires that the key name in map is the same as the property name in JavaBean
*/
@Test
public void Testtobean ()
{
1. Create a map
Map<string,object> map=new hashmap<string,object> ();
Map.put ("pid", "123");
Map.put ("PName", "Xushouwei");
Map.put ("Age", 25);
Map.put ("xxx", "male");
Create a JavaBean object of person type with data from map
Person P=commonutils.tobean (map, Person.class);
SYSTEM.OUT.PRINTLN (P);
}
}
Talking about the use of Java tool class Commonutils