Loadrunner??java???
???????????? ???????[ 2015/10/28 14:25:00 ] ?????????????????? ??????????
/*
* LoadRunner Java script. (Build: _build_number_)
*
* Script Description:
*
*/
package com.trunkbow.comm.serviceTest;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.trunkbow.comm.service.impl.XmlSignature;
import com.trunkbow.comm.util.HttpClientHelper;
import lrapi.lr;
public class Actions
{
public int init() throws Throwable {
return 0;
}//end of init
public int action() throws Throwable {
testPay();
return 0;
}//end of action
public int end() throws Throwable {
return 0;
}//end of end
Log log = LogFactory.getLog(PayTest.class);
public void testPay() throws Exception {
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd HH:mm:ss");
String date = formatter.format(currentTime);
SimpleDateFormat orderId = new SimpleDateFormat("yyyyMMddHHmmss");
String orderTime = orderId.format(currentTime);
String order=orderTime+String.valueOf(randInt(10000??99999));
String xml = "<Finance><Message id="0000">" + "<CPReq id="CPReq">"
+ "<version>6.0.1</version>" + "<instId>12345</instId>"
+ "<certId>13389743053847134210</certId>"
//+ "<serialNo>"+lr.eval_string("{serialNo}")+"</serialNo>"
+ "<serialNo>"+order+"</serialNo>"
+ "<date>"+date+"</date>"
+ "<accountName></accountName>"
+ "<bankCardNo>"+lr.eval_string("{???????}")+"</bankCardNo>"
+ "<bankCardType>C</bankCardType>"
+ "<bankCardAreaCode></bankCardAreaCode>"
+ "<certType></certType>" + "<certNo></certNo>"
+ "<mobilePhone></mobilePhone>"
+ "<charge></charge>"
+ "<amount>1</amount>"
+ "<useCode>K00</useCode>" + "<currency>156</currency>"
+ "<limitType></limitType>" + "<remark></remark>"
+ "<sellerName></sellerName>"
+ "<installmentCount></installmentCount>"
+ "<originalAmount></originalAmount>"
+ "<expiryDate></expiryDate>" + "<cvv2></cvv2>"
+ "<channelSystemId>0000</channelSystemId>" + "</CPReq>"
+ "</Message></Finance>";
XmlSignature xmlSignature = new XmlSignature();
String result = xmlSignature.sign(xml?? "CPReq");
HttpClientHelper http = new HttpClientHelper();
String postUrl = "http://195.203.56.22/online/alipay.action";
String resultXml = null;
lr.start_transaction("???");//?????
if(postUrl.indexOf("https://") != -1){
resultXml = HttpsHelper.sendHTTPS(postUrl??result);
}else{
resultXml = http.send(result?? postUrl);
}
log.info("???????" + result);
if (xmlSignature.signVerification(resultXml)) {
lr.end_transaction("???"??lr.PASS);//??????
log.info("??????");
} else {
lr.end_transaction("???"??lr.FAIL);//??????
log.error("??????");
}
log.info("????????" + resultXml);
}
public int randInt(int min?? int max) throws Exception{
Random rand = new Random();
int randomNum = rand.nextInt((max - min) + 1) + min;
return randomNum;
}
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11