1,打开eclipse,新建maven工程,在pom中引用jmeter核心jar包,具体请看---https://www.cnblogs.com/guanyf/p/10863033.html---,这里就不再赘述

2,代码如下:

package com.mytest.functions;

import org.apache.jmeter.engine.util.CompoundVariable;

import org.apache.jmeter.functions.AbstractFunction;

import org.apache.jmeter.functions.InvalidVariableException;

import org.apache.jmeter.samplers.SampleResult;

import org.apache.jmeter.samplers.Sampler;

import org.apache.jmeter.threads.JMeterVariables;

import java.util.Collection;

import java.util.LinkedList;

import java.util.List;

public class UpperCase extends AbstractFunction {

    private static final List<String> desc = new LinkedList<String>();

    private static final String KEY = "__uppercase";

    static {

        desc.add("String to convert to uppercase");

        desc.add("Name of variable in which to store the result (optional),The author is guanyf");

    }

    private Object[] values;

    /**

     * No-arg constructor.

     */

    public UpperCase() {

    }

    /**

     * {@inheritDoc}

     */

    @Override

    public synchronized String execute(SampleResult previousResult, Sampler currentSampler)

            throws InvalidVariableException {

        JMeterVariables vars = getVariables();

        String res = ((CompoundVariable) values[0]).execute().toUpperCase();

        if (vars != null && values.length > 1) {

            String varName = ((CompoundVariable) values[1]).execute().trim();

            vars.put(varName, res);

        }

        return res;

    }

    /**

     * {@inheritDoc}

     */

    @Override

    public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {

        checkMinParameterCount(parameters, 1);

        values = parameters.toArray();

    }

    /**

     * {@inheritDoc}

     */

    @Override

    public String getReferenceKey() {

        return KEY;

    }

    /**

     * {@inheritDoc}

     */

    @Override

    public List<String> getArgumentDesc() {

        return desc;

    }

}

jmeter添加自定义扩展函数之小写转换大写的更多相关文章

  1. jmeter添加自定义扩展函数之大写转换小写

    1,打开eclipse,新建maven工程,在pom中引用jmeter核心jar包,具体请看---https://www.cnblogs.com/guanyf/p/10863033.html---,这 ...

  2. jmeter添加自定义扩展函数之图片base64编码

    打开eclipse,新建maven工程,在pom中引入jmeter核心jar包: <!-- https://mvnrepository.com/artifact/org.apache.jmete ...

  3. jmeter添加自定义扩展函数之DoubleSum

    1,打开eclipse,新建maven工程,在pom中引用jmeter核心jar包,具体请看---https://www.cnblogs.com/guanyf/p/10863033.html---,这 ...

  4. jmeter添加自定义扩展函数之if判断

    1,打开eclipse,新建maven工程,在pom中引用jmeter核心jar包,具体请看---https://www.cnblogs.com/guanyf/p/10863033.html---,这 ...

  5. jmeter添加自定义扩展函数之MD5加密

    1,打开eclipse,新建maven工程,在pom中引用jmeter核心jar包,具体请看---https://www.cnblogs.com/guanyf/p/10863033.html---,这 ...

  6. jmeter添加自定义扩展函数之Strng---base64解密

    1,打开eclipse,新建maven工程,在pom中引用jmeter核心jar包,具体请看---https://www.cnblogs.com/guanyf/p/10863033.html---,这 ...

  7. jmeter添加自定义扩展函数之String---base64加密

    1,打开eclipse,新建maven工程,在pom中引用jmeter核心jar包,具体请看---https://www.cnblogs.com/guanyf/p/10863033.html---,这 ...

  8. jmeter添加自定义扩展函数之图片base64

    原文连接:---------https://www.cnblogs.com/qiaoyeye/p/7218770.html----------- 打开eclipse,新建maven工程,在pom中引用 ...

  9. eclipse字母大写和小写转换的快捷键

    大写转换小写 ctrl+shift+y        小写转换大写 ctrl+shift+x   

随机推荐

  1. jQuery基础--总结

    <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8& ...

  2. Ubuntu下编译c文件时,遇到math.h头文件不能编译问题

    以前都是在VC或者VS中编写c语言程序,今天尝试在Ubuntu下试着编写了一个简单的画正弦函数的程序,用到了头文件math.h,但是编译的时候报错了: 经查资料后才知道,数学函数位于libm.so库文 ...

  3. JavaScript.convertArray

    function convertArray(nodeList){     var arr = []     if(Array.prototype.slice){         arr = [].sl ...

  4. json字符串格式

    private static final String COMPLEX_JSON_STR = "{" + "\"teacherName\":\&quo ...

  5. 最小生成树基础算法(Prim + Krustal)

    最小生成树问题的引入: 对于一个无向图G(V, E),需要用图中的n - 1条边连接图中的n个顶点并且不产生回路所产生的树就叫做生成树,其中权值总和最小的就是最小生成树. 如何求解最小生成树问题: 譬 ...

  6. 在没有iis的情况下,webApi自托管(转自momo314)

    第一步 新建一个控制台应用程序 并添加WebApi相关引用,注意,添加之后会默认帮你添加 System.Web.Http.WebHost 的引用,不过,折并没有什么鸟用,干掉他,然后手动添加引用 Sy ...

  7. [CF580C]Shortest Cycle(图论,最小环)

    Description: 给 \(n\) 个点的图,点有点权 \(a_i\) ,两点之间有边当且仅当 \(a_i\ \text{and}\ a_j \not= 0\),边权为1,求最小环. Solut ...

  8. python依赖包整体迁移方法(pip)

    做个记录 python依赖包整体迁移方法

  9. Service vs provider vs factory 转自:http://stackoverflow.com/questions/15666048/service-vs-provider-vs-factory

    请看此链接:http://stackoverflow.com/questions/15666048/service-vs-provider-vs-factory

  10. git如何删除远程仓库的某次错误提交

    git如何删除远程仓库的某次错误提交 如果远程仓库,能ssh访问,那就跟本地没什么区别   reset命令有3种方式   git reset --mixed 此为默认方式,不带任何参数的git res ...