/*
* LoadRunner Java script. (Build: _build_number_)
*
* Script Description:
*
*/
import lrapi.lr;
import com.ytinf.service.lrTest.GetRequest;
import com.alibaba.fastjson.JSONObject;
public class Actions
{
public int init() throws Throwable {
return 0;
}//end of init
public int action() throws Throwable {
String url="http://XX.XX.XX.XX:8089/databridge_dg/hbase/lottery";
GetRequest getRequest=new GetRequest();
getRequest.addParameter("lotterysn","{lotterySn_lottery}");
lr.think_time(1);
lr.start_transaction("票明细查询");
JSONObject jsonObject=null;
try{
jsonObject=getRequest.get(url);
}catch(Exception e){
lr.end_transaction("票明细查询",lr.FAIL);//如果超时报错,事务失败
lr.output_message("获取响应报错了");
}
if (jsonObject!=null){
if (jsonObject.get("status").equals(0)){
lr.end_transaction("票明细查询",lr.PASS);//解析响应结果,事务成功
}else{
lr.end_transaction("票明细查询",lr.FAIL);
lr.output_message("响应信息的status字段不为 0 。");//解析响应结果失败,事务失败
}
}else{
lr.end_transaction("票明细查询",lr.FAIL);//响应结果 为 null,响应失败
lr.output_message("获取的响应信息为 null");
}
return 0;
}//end of action
public int end() throws Throwable {
return 0;
}//end of end
}
hmoban主题是根据ripro二开的主题,极致后台体验,无插件,集成会员系统
自学咖网 »
loadrunner get请求的一个java vuser 脚本