码迷,mamicode.com
首页 > 其他好文 > 详细

[LoadRunner]Hessian接口性能测试简单实践

时间:2016-04-25 14:51:49      阅读:1060      评论:0      收藏:0      [点我收藏+]

标签:

 

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

技术分享

第二步,编写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类(这步很关键):

技术分享

[LoadRunner]Hessian接口性能测试简单实践

标签:

原文地址:http://www.cnblogs.com/whylaughing/p/5430821.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!