使用IDEA打jar包

IDEA打包

C_S_A+s打开工程结构页,在Artifacts中添加一个JAR,选择From Modules,选择MainClass并设置MANIFEST.MF文件到src\main\resources下。
最后通过Build->Build Artifacts->Build,在out中生成jar即可。

取值

import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.protocol.http.control.HeaderManager;
import org.apache.jmeter.protocol.http.control.Header;
import java.util.*;
import com.google.gson.Gson;
import org.apache.commons.codec.digest.DigestUtils;
import java.security.NoSuchAlgorithmException;
//生成签名的方法
String signURLAndRequestParams() throws NoSuchAlgorithmException {

省略。。。

return sign;
}

params = new ArrayList();
//获取请求的参数
Arguments args = sampler.getArguments();
//获取header中token
String token = null;
HeaderManager headerManager = sampler.getHeaderManager();
headerMap = new HashMap();
try{
if(headerManager != null){
for(int i=0;i<headerManager.size();i++){
Header header = headerManager.get(i);
headerMap.put(header.getName(),header.getValue());
}
}

}
catch(Exception e){
log.info(e.getMessage());
}
if(headerMap.containsKey("Authorization")){
token = headerMap.get("Authorization");
}
//参数转换,添加到params
it = args.iterator();
while(it.hasNext()){
argument = it.next();
String pair = argument.toString();
if(pair.startsWith("=")){
params.add("jsonBody"+pair);
}
else{
params.add(pair);
}
}

//获取path
String path = sampler.getPath();
//从变量获取timestamp、app_id,secret_key
String timestamp = vars.get("timestamp");
String app_id = vars.get("app_id");
String appSecret = vars.get("secretKey");
//把app_id,timestamp添加到params中
String timestamp_param = "timestamp="+timestamp;
String app_id_param = "app_id="+app_id;
params.add(timestamp_param);
params.add(app_id_param);
//获取method
String method = sampler.getMethod();
//获取签名
String sign = signURLAndRequestParams(path,params,appSecret,method,token);
//把app_id、timestamp、sign加到path
String path_send = path+"?"+app_id_param+"&"+timestamp_param+"&sign="+sign;
//reset path
sampler.setPath(path_send);

Refer to

https://www.cnblogs.com/Eric-zhao/p/9953353.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值