Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Loadrunner conducts pressure test of http interface

Shulou Source: shulou.com Published: 2022-06-03 02:54:18 11月15日 Update

The attachment is from Baidu.

Script body:

/ *

* LoadRunner Javascript. (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

}

Contents of the jar package:

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); / / 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 ();}}

Attachment: http://down.51cto.com/data/2367948

Tags: Attachments content body script pressure Interface Test Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Linux NVidia MariaDB vpn