由于在工作中经常会自己DEBUG,根据日志的数据自己经常要写测试类。比如打出的日志有这些信息
OprNumb=015225be6fb17a7, UnsubTime=20130903184734, UnsubCode=RT0131100000002013090300000011, CompanyCode=100, ShopCode=210011400000000, SalesPersonID=cdsc01, OrderCode=SL0110000000002013090200000027。
然后我每次都要自己Set一遍。下面是我的测试方法,每次走自己set 很费时间。
ICrm2CbossRemote icr = new Crm2CbossRemoteImpl();
UnsubVerifyReqDataBean dataBean = new UnsubVerifyReqDataBean();
dataBean.setOprNumb("015225be6fb17a7");
dataBean.setUnsubTime("20130903184734");
dataBean.setUnsubCode("RT0131100000002013090300000011");
dataBean.setCompanyCode("100");
dataBean.setShopCode("210011400000000");
dataBean.setSalesPersonID("cdsc01");
dataBean.setOrderCode("SL0110000000002013090200000027");
icr.doService(dataBean, "N0207");
所以我就想根据日志的信息,自动生成这些set信息。下面是我自己写的方法!
public static void splitManifest(String str){
String str1 = str.replace(" ", "");
StringTokenizer tok = new StringTokenizer( str1 , "," );
while(tok.hasMoreTokens()){
String token = tok.nextToken();
int eq = token.indexOf("=");
String name = (eq > -1) ? token.substring(0, eq) : token;
String value = (eq > -1) ? token.substring(eq + 1) : "";
System.out.println("dataBean"+"."+"set"+name+"(\""+value+"\")");
}