• loadrunner压测java请求


    1、把应用jar包放到一个目录下,在lr中,引用导入系统里

    2、新建java vuser,写入脚本
    import com.alibaba.fastjson.JSONArray;
    import com.jd.jmi.order.api.domain.JmiOrderDetail;
    import com.jd.jmi.order.api.service.JmiOrderQueryService;
    import com.jd.jmi.order.client.jsf.exceptions.JmiException;
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlApplicationContext;
    import lrapi.lr;
    public class Actions
    {
            static JmiOrderQueryService jmiOrderQueryService;
        private static ApplicationContext act;
         static {
             act = new ClassPathXmlApplicationContext("spring-config-jsf.xml");
             jmiOrderQueryService = act.getBean("jmiOrderQueryService",JmiOrderQueryService.class);
             }
        public int init() throws Throwable { 
            return 0;
        }//end of init
        public int action() throws Throwable {
        lr.start_transaction("QueryByOrderId");
         try {
        JmiOrderDetail detail = this.jmiOrderQueryService.queryByOrderId(Long.valueOf(lr.eval_string("<OrderId>")), "eeeee");
        if (detail != null) {   
        lr.end_transaction("QueryByOrderId", lr.PASS);
        //System.out.println(JSONArray.toJSONString("++++++++++++++++"+detail));
        }else{
        lr.end_transaction("QueryByOrderId", lr.FAIL);
        }
        } catch (JmiException e) {
                e.printStackTrace();
            }
        return 0;
        }
        public int end() throws Throwable {
            return 0;
        }//end of end
    }

  • 相关阅读:
    ubuntu18.04管理redis
    Mac Vmware虚拟机重启后没有网络
    记Spark写数据到Elasticsearch的报错
    Spark基础和RDD
    PHP日期处理
    集群命令
    hadoop集群时间同步
    HBase读写流程
    Flume简介
    Linux 常用快捷键
  • 原文地址:https://www.cnblogs.com/upcgg/p/5220078.html
Copyright © 2020-2023  润新知