溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Loadrunner進行http接口壓力測試

發布時間:2020-07-31 14:08:57 來源:網絡 閱讀:2644 作者:cvv54 欄目:軟件技術

附件來自百度。



腳本正文:

/*

 * 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
向AI問一下細節
推薦閱讀:
  1. LoadRunner
  2. LR測試HTTP接口

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女