[LoadRunner]性能测试实践_Hessian协议脚本编写

 

第一步,新建LR的脚本,选择Java Vuser协议:

image

第二步,编写hessian测试脚本,如下:

import lrapi.lr;
import java.net.MalformedURLException;
import kf.ats.gvnsvr.common.service.base.IBaseTimeService;
import com.caucho.hessian.client.HessianProxyFactory;

public class Actions
{
private static final String postUrl = "http://192.168.2.161:18081/test/HS/";
private static final String serverName="BaseTimeService";

public int init() throws Throwable {

  return 0;
}//end of init
 
 
public int action() throws Throwable {

     lr.start_transaction("deal");
    

     HessianProxyFactory factory = new HessianProxyFactory();
     IBaseTimeService service;
     String result=null;
     try {
      service = (IBaseTimeService) factory.create(IBaseTimeService.class, postUrl + serverName);
      result=service.getCurrentTime().toString();
      System.out.println(result);
    } catch (MalformedURLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
        }

     if (result!=null) {
  lr.end_transaction("deal", lr.PASS);
     } else {
  lr.end_transaction("deal", lr.FAIL);
     }
     return 0;
}//end of action
 

public int end() throws Throwable {

  return 0;
}//end of end
}

第三步,导入必要的jar类(这步很关键):

image

转载于:https://www.cnblogs.com/whylaughing/p/5430821.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值