日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

loadrunner之java协议脚本编写

發布時間:2025/3/15 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 loadrunner之java协议脚本编写 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.




loadrunnerjava腳本saf?

1.導入相對應的jar包

2.使用java反編譯工具反編譯jar包,了解其中的業務流程,選擇需要的service以及方法。以下以productWrapService服務為例。

3.在saf框架的配置文件中注冊:

  • <?xml?version="1.0"?encoding="UTF-8"?>??
  • <beans?xmlns="http://www.springframework.org/schema/beans"??
  • ????xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"??
  • ????xmlns:saf="http://code.xx.com/schema/saf"??
  • ????xmlns:dubbo="http://code.xx.com/schema/dubbo"??
  • ????xsi:schemaLocation="http://www.springframework.org/schema/beans???
  • ????http://www.springframework.org/schema/beans/spring-beans-2.5.xsd??
  • ????http://code.xx.com/schema/saf?http://code.xx.com/schema/saf/saf.xsd??
  • ????http://code.xxxx.com/schema/dubbo??
  • ????http://code.xxxx.com/schema/dubbo/dubbo.xsd"??
  • ????default-lazy-init="true">??
  • ??????
  • ????????<saf:registry?address="jdZooKeeper://192.168.12.159:2181"?/>??
  • ????????????????<saf:reference??id="productWrapService"??interface="xx.xx.xx.pbim.pbia.dubbo.service.ProductWrapService"?group="xxxx"?version="1.0"??timeout="30000"???/>??
  • ????????????????<saf:reference??id="bookVideoService"??interface="xx.xx.xx.pbim.pbia.dubbo.service.BookVideoService"?group="xxxx"?version="1.0"??timeout="30000"???/>??
  • ????????????????<saf:reference??id="attributeService"??interface="xx.xx.xx.pbim.pbia.dubbo.service.AttributeService"?group="xxxx"?version="1.0"??timeout="30000"???/>??
  • ?</beans>??
  • ?4.編寫loadrunner腳本:

    ?

    Java代碼 ?
  • /*?
  • ?*?LoadRunner?Java?script.?(Build:?_build_number_)?
  • ?*??
  • ?*?Script?Description:??
  • ?*??????????????????????
  • ?*/??
  • ??
  • import?lrapi.lr;??
  • ??
  • import?com.xxx.catagory.pbim.pbia.dubbo.service.ProductWrapService;??
  • import?com.xxx.catagory.pbim.pbia.dubbo.model.ProductSort;??
  • import?java.util.*;??
  • import?java.lang.*;??
  • import?org.springframework.context.support.ClassPathXmlApplicationContext;??
  • ??
  • public?class?Actions??
  • {??
  • ????????ProductWrapService?r?=?null;??
  • ????public?int?init()?throws?Throwable?{??
  • ????????????????int?i?=?0;??
  • ????????????????ClassPathXmlApplicationContext?context?=?new?ClassPathXmlApplicationContext("applicationContext-dubbo.xml");//讀環境配置XML,并注冊SAF和redis認證??
  • ????????r?=?(ProductWrapService)context.getBean("productWrapService",ProductWrapService.class);???
  • ????????return?0;??
  • ????}//end?of?init??
  • ??
  • ??
  • ????public?int?action()?throws?Throwable?{??
  • ????????Integer?skuIdInteger;??
  • ????????Set<Integer>?cids?=?new?HashSet<Integer>();??
  • ????????String?str=lr.eval_string("<P_sortid>");??
  • ????????skuIdInteger?=?Integer.valueOf(str);??
  • ????????cids.add(skuIdInteger);??
  • ??????????
  • ????????List<ProductSort>?retList?=?new?ArrayList<ProductSort>();??
  • ????????ProductSort?ps?=?new?ProductSort();??
  • ????????lr.start_transaction("productWrapService_queryProductSort");??
  • ??
  • ????????try??
  • ????????{??
  • ????????????retList?=?r.queryProductSort(cids);??
  • ????????????????????for?(Iterator?i$?=?retList.iterator();?i$.hasNext();?)?{??
  • ????????????ps?=?(ProductSort)i$.next();??
  • ????????????lr.output_message("+++++++++"?+?ps.getName());??
  • ????????????}??
  • ????????????//lr.output_message("++++++++"?+?retList);??
  • ????????????if?(retList?!=?null)?{??
  • ????????????lr.end_transaction("productWrapService_queryProductSort",?lr.PASS);??
  • ????????????}??
  • ????????????else?{??
  • ????????????lr.end_transaction("productWrapService_queryProductSort",?lr.FAIL);??
  • ????????????}??
  • ??????????????
  • ????????}??
  • ????????catch(Exception?e)?{??
  • ????????????e.printStackTrace();??
  • ????????}??
  • ????????return?0;??
  • ????}//end?of?action??
  • ??
  • ??
  • ????public?int?end()?throws?Throwable?{??
  • ????????return?0;??
  • ????}//end?of?end??
  • }??
  • ?

    總結

    以上是生活随笔為你收集整理的loadrunner之java协议脚本编写的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。