zoukankan      html  css  js  c++  java
  • 使用IDEA打jar包

    IDEA打包

    C_S_A+s打开工程结构页,在Artifacts中添加一个JAR,选择From Modules,选择MainClass并设置MANIFEST.MF文件到srcmain esources下。
    最后通过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

  • 相关阅读:
    锤子科技官网:问题整理及注意事项
    springboot中文文档
    Spring Framework 开发参考手册中文(在线HTML)
    .is() 全选复选的判断
    c:forEach用法
    SSM框架——详细整合教程(Spring+SpringMVC+MyBatis)
    火狐浏览器下载文件保存文件名的乱码问题
    多线程安全的解决方法
    MySQL的concat以及group_concat的用法
    mysql 将时间转换成时间戳
  • 原文地址:https://www.cnblogs.com/liehen2046/p/12143389.html
Copyright © 2011-2022 走看看