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. thphp(tp5)项目网站从Apache换成nginx报500

    thphp(tp5)项目网站从Apache换成nginx报500 百度了一下,查看资料是Nginx配置fastcgi.conf的问题,打开文件编辑既可,如下图:

  2. zookeeper+dubbo+demo

    zookeeper下载地址 https://archive.apache.org/dist/zookeeper/ zookeeper安装和使用 windows环境 https://blog.csdn. ...

  3. from、includes、indexOf

    from.includes.indexOf:https://blog.csdn.net/j59580/article/details/53897630?utm_source=blogxgwz1 语法 ...

  4. 学python2.7简单还是python3.0简单,两者区别

    学python2.7简单还是python3.0简单,谈谈两者区别 1. 使用__future__模块 Python 3.X 引入了一些与Python 2 不兼容的关键字和特性.在Python 2中,可 ...

  5. Vue PC端图片预览插件

    *手上的项目刚刚搞完了,记录一下项目中遇到的问题,留做笔记: 需求: 在项目中,需要展示用户上传的一些图片,我从后台接口拿到图片url后放在页面上展示,因为被图片我设置了宽度限制(150px),所以图 ...

  6. eclipse 设置注释模板

    window->preference->java->code  styple->code template->Comments Types /** * @author $ ...

  7. protocols - 协议定义文件

    描述 该文件为普通 ASCII 文件,它描述了 TCP/IP 子系统中各类 DARPA internet 协议族.你应该参考这个文件, 而不是使用 ARPA 的 include 文件中的号码, 更不必 ...

  8. SELECT INTO - 从一个查询的结果中创建一个新表

    SYNOPSIS SELECT [ ALL | DISTINCT [ ON ( expression [, ...] ) ] ] * | expression [ AS output_name ] [ ...

  9. regex - POSIX 1003.2 正则表达式

    DESCRIPTION 正则表达式 (``RE''s), 在 POSIX 1003.2 中定义,包含两种类型:新式 REs (基本上指的是 egrep 使用的那些,1003.2 称其为 ``exten ...

  10. ssh-agent - 认证代理

    总览 (SYNOPSIS) ssh-agent [-a bind_address ] [-c | -s ] [-t life ] [-d ] [command [args ... ] ] ssh-ag ...