Loadrunner进行http接口压力测试
2016-07-21 12:26
316 查看
附件来自百度。
脚本正文:
/*
* LoadRunner Java script. (Build: _build_number_)
*
* Script Description:
*
*/
import lrapi.lr;
public class Actions
{
public int init() throws Throwable {
return 0;
}//end of init
public int action() throws Throwable {
com.CTLPTest ct1 = new com.CTLPTest();
ct1.main(null);
return 0;
}//end of action
public int end() throws Throwable {
return 0;
}//end of end
}
jar包内容:
附件:http://down.51cto.com/data/2367948
脚本正文:
/*
* LoadRunner Java script. (Build: _build_number_)
*
* Script Description:
*
*/
import lrapi.lr;
public class Actions
{
public int init() throws Throwable {
return 0;
}//end of init
public int action() throws Throwable {
com.CTLPTest ct1 = new com.CTLPTest();
ct1.main(null);
return 0;
}//end of action
public int end() throws Throwable {
return 0;
}//end of end
}
jar包内容:
package com; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; import java.security.cert.X509Certificate; import java.util.Properties; import java.util.Random; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLSession; import javax.net.ssl.X509TrustManager; public class CTLPTest { public static void main(String[] args) { CTLPTest lbs = new CTLPTest(); String ltpUrl = lbs.ltpRequestUrl(); System.out.println("ltpUrl:"+ltpUrl); System.out.println("lbs.ltpRequestUrl(ltpUrl):"+lbs.ltpRequestUrl(ltpUrl)); } public int ltpRequestUrl(String ltpRequestUrl) { int returnCount = -1; try { URL url = new URL(ltpRequestUrl); Properties prop = System.getProperties(); System.setProperty("http.proxyHost", "proxy.com"); System.setProperty("http.proxyPort", "80"); //http HttpURLConnection http = (HttpURLConnection)url.openConnection(); http.setUseCaches(false); http.connect(); //http InputStream in = http.getInputStream(); // byte[] b = new byte[in.available()]; in.read(b); // String res = new String(b); System.out.println("res:"); System.out.println(res); //ж,÷ int of = res.indexOf("resultCode"); if (of < 0) { System.out.println("***************failure***********************"); returnCount = -1; } else { returnCount = 1; } }catch(Exception e){ System.out.println("Exception"); System.out.println(e); returnCount = -1; } return returnCount; } public String ltpRequestUrl() { StringBuilder param = new StringBuilder("http://xxx.xxx.com"); // param.append("userid-1"); // param.append("&appName=LBS&Apikey=D39hr1FgplZSjV2eNVW71wvbYbl8Mip4"); return param.toString(); } }
附件:http://down.51cto.com/data/2367948
相关文章推荐
- 房产界已上市和IPO路上的难兄难弟:房天下与房多多
- 利用百度地图提供的API做的应用
- 搜狗百度360市值齐跌:搜索引擎们陷入集体焦虑?
- 百度20年:搜索帝国的崛起、式微与重生
- 小白观察:Google 开始清除百度旗下公司开发的 46 款应用程序
- AS3 中的package(包)应用实例代码
- 百度全面恢复网站权重,流量暴涨中
- Orcle的package中访问其它Schema的表报错ORA-00942解决方法
- MySQL压力测试方法 如何使用mysqlslap测试MySQL的压力?
- 百度工程师讲PHP函数的实现原理及性能分析(一)
- C#使用ImitateLogin模拟登录百度
- 百度 popup.js 完美修正版非常的不错 脚本之家推荐
- javascript实现类似百度分享功能的方法
- 仿百度换肤功能的简单实例代码
- 百度空间的popup效果分析第1/3页
- jQuery实现的仿百度分页足迹效果代码
- 模仿百度三维地图的js数据分享
- 使用pcs api往免费的百度网盘上传下载文件的方法
- 教你如何自定义百度分享插件以及bshare分享插件的分享按钮
- 百度最近不收站分析,为什么不收录你的站