import com.xxx.EncryptSdk;
String salt = vars.get("salt");
String privateKey = vars.get("privateKey");
String aesKey = vars.get("aesKey");
String data = "{\n" +
"\t'head': {\n" +
"\t\t'platformNo': '${platformNo}',\n" +
"\t\t'merchantNo': '${merchantNo}',\n" +
"\t\t'terminalNo':'${terminalNo}',\n" +
"\t\t'appDownloadChannel': '小米应用商店',\n" +
"\t\t'appProduct': 'kn',\n" +
"\t\t'appVersion': '10.5.4.5',\n" +
"\t\t'channelNo': 'SSJ',\n" +
"\t\t'clientInfo': 'MyMoney/10.5.4.5 (Xiaomi/MI 6; Android/7.0; miui)',\n" +
"\t\t'deviceName': 'MI 6',\n" +
"\t\t'deviceNo': 'device-11234123523456',\n" +
"\t\t'deviceType': '1',\n" +
"\t\t'ip': '111.111.111.111',\n" +
"\t\t'location': '中国-广东-深圳',\n" +
"\t\t'mac': '4e:56:78:5f:56:78',\n" +
"\t\t'platform': 'Android',\n" +
"\t\t'platformVersion': 'Android6.0',\n" +
"\t\t'reqNo': '${__time(,)}${__RandomString(5,0123456789,)}',\n" +
"\t\t'requestTime': '${__time(,)}',\n" +
"\t\t'version': '1.0'\n" +
"\t},\n" +
"\t'body': {\n" +
"\t\t'orderNo': '${__time(,)}${__RandomString(5,0123456789,)}',\n" +
"\t\t'fullName': '${fullName}',\n" +
"\t\t'bankPhone': '${bankPhone}',\n" +
"\t\t'idNo': '${idNo}',\n" +
"\t\t'bankNo': '${bankNo}',\n" +
"\t\t'cardNo': '${cardNo}',\n" +
"\t\t'payAmount': '${payAmount}',\n" +
"\t\t'productName': '${productName}',\n" +
"\t\t'userIdentify': '${userIdentify}'\n" +
"\t}\n" +
"}";
//log.info(salt);
//log.info(privateKey);
//log.info(aesKey);
log.info(data);
String result = EncryptSdk.encryptRequestParams(data, salt, privateKey, aesKey);
log.info(result);
vars.put("data", result);
import com.xxx.xxx.EncryptSdk;
import com.alibaba.fastjson.JSONObject;
String salt = vars.get("salt");
String aesKey = vars.get("aesKey");
String response = prev.getResponseDataAsString();
String responseDecrypt = EncryptSdk.decryptResponseParams(response, aesKey, salt);
JSONObject jsonObject = JSONObject.parseObject(responseDecrypt);
log.info(responseDecrypt);
// 断言返回的code
String code = jsonObject.getString("code");
String msg = jsonObject.getString("msg");
if(!code.equals("000000")){
Failure = true;
FailureMessage = msg;
return;
}
// 断言data中的orderStatus
JSONObject dataJsonObject = jsonObject.getJSONObject("data");
Integer orderStatus = dataJsonObject.getInteger("orderStatus");
String thirdMsg = dataJsonObject.getString("thirdMsg");
if (!(orderStatus.equals(1) || orderStatus.equals(0))){
Failure = true;
FailureMessage = "订单异常:" + thirdMsg;
return;
}
jmeter beanshell生成CSV文件
import java.io.FileWriter;
import java.util.Arrays;
import java.io.Writer;
String param = vars.get("lc");
//System.out.println("lc==="+param);
public static void wr(String file, String conent) {
BufferedWriter out = null;
try {
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, true)));
out.write(conent+",\n");
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if(out != null){
out.flush();
out.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
wr("D://Program Files (x86)//2.csv",param);