Chinaunix首页 | 论坛 | 博客
  • 博客访问: 670751
  • 博文数量: 53
  • 博客积分: 830
  • 博客等级: 准尉
  • 技术积分: 1089
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-31 18:23
文章存档

2019年(1)

2018年(1)

2016年(1)

2015年(1)

2014年(12)

2013年(4)

2012年(33)

分类: LINUX

2013-06-05 17:48:41

/* * LoadRunner Java script. (Build: _build_number_) *  * Script Description:  * author: dengdagui *                      */ import lrapi.lr; import java.util.*;import java.text.*; import com.emarbox.dsp.api.domain.DspCostReport.DspCostReportInfo;import com.emarbox.dsp.api.domain.DspCostRequest.DspCostRequestInfo;import com.emarbox.dsp.service.PBUtil;import com.emarbox.dsp.service.reportObject;   public class Actions{        //  static String reportAPIUrl = "";    public int init() throws Throwable {  return 0; }//end of init  public int action() throws Throwable {         this.exec();  return 0; }//end of action           public void exec(){    List objList = new ArrayList();    for(int i=0 ; i< 10 ;i++){   Long campaignId = 1L; //活动Id   Long supplierId = 5020L; //广告平台ID : 5020,5020   Long impression = 1L; //展现数   Long click = 1L; //点击数   Double biddingCost = 0d; //消费   Double rtbCost = 0d; //消费      reportObject obj = new reportObject();   obj.setCampaignId(campaignId);   obj.setSupplierId(supplierId);   obj.setImpression(impression);   obj.setClick(click);   obj.setBiddingCost(biddingCost);   obj.setRtbCost(rtbCost);      objList.add(obj);  }    Integer hour = 1; //小时 : 0 - 23  String date = "20130603"; //日期 :yyyymmdd    sendRequest(objList,date,hour); }  public void sendRequest(List objList,String date,long hour) { lr.start_transaction("report_jar");   DspCostRequestInfo result = null;   DspCostRequestInfo.Builder requestBuilder = DspCostRequestInfo.newBuilder();  DspCostReportInfo.Builder builder = null;  DspCostReportInfo dspCampaignInfo = null;    for(reportObject obj : objList){   builder = DspCostReportInfo.newBuilder();     builder.setCampaignId(obj.getCampaignId());   builder.setImpressionCount(obj.getImpression());   builder.setClickCount(obj.getClick());   builder.setSupplierId(obj.getSupplierId());   builder.setBiddingCost(obj.getBiddingCost());   builder.setRtbCost(obj.getRtbCost());   dspCampaignInfo = builder.build();   requestBuilder.addDspCostReport(dspCampaignInfo);  }   requestBuilder.setDataDate(date);  requestBuilder.setDataHour(hour);  result = requestBuilder.build();  PBUtil.sentRequest(result, reportAPIUrl);                   String respondresult = String.valueOf(PBUtil.sentRequest(result, reportAPIUrl));                  //control检查点:      if(this.check("success: true",respondresult)==true){                 lr.end_transaction("report_jar", lr.PASS);      }else{                 lr.end_transaction("report_jar", lr.FAIL);                  lr.error_message("java_jar失败的返回结果:"+respondresult);         }  }        public boolean check(String str,String result){          String result_ok = "Code:200";  String result_error = "2";        if(result.indexOf(str)!=-1){   return true;       }else{          return false;          }        }  public int end() throws Throwable {  return 0; }//end of end}
阅读(1393) | 评论(6) | 转发(0) |
给主人留下些什么吧!~~