/*
1、其中自定义部分变量清参考脚本中对变量的设置
*/
import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.protocol.http.control.HeaderManager;
import org.apache.jmeter.protocol.http.control.Header;
import org.apache.commons.codec.digest.DigestUtils;
//获取请求的body部分
Arguments args = sampler.getArguments();
String req_str = args.toString().replace("(", "").replace(")", "");
req_str = req_str.substring(1);
//获取请求的path
String path = sampler.getPath();
//获取请求方法
String method = sampler.getMethod();
//获取自定义变量
String DateTime = "${offlineDateTime}";
//log.info("DateTime = " + DateTime);
String MsgID = "${merchantTransID}";
//进行加密处理并复制authorization
String signString = method+"\n"+path+"\n"+DateTime+"\n"+"${signkey}"+"\n"+MsgID+"\n"+req_str;
//log.info("signString = " + signString);
authorization = DigestUtils.sha256Hex(signString);
//log.info("authorization = " + authorization);
vars.put("authorization",authorization);