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. 关于在eclipse中配置tomcat的各种坑

    先说在windows下的,java环境什么的就不再记录了,记住装java ee之前,先要装好java se这样java ee才能顺利安装. 主要是安装好tomcat之后,在eclipse中进行配置的时 ...

  2. Node.js实战2:模块使用入门。

    NodeJS有丰富的三方模块,借助这些模块,可以快速的开发各类应用.这使用Nodejs可以进行很便捷.快速的开发. 1.安装与加载模块内核.三方 使用npm可以搜索.安装.卸载模块. 例: 搜索模块 ...

  3. Lua中C API栈操作

    向栈中压入数据: lua_pushnil(lua_State*); lua_pushboolean(lua_State*, bool); lua_pushnumber(lua_State*, lua_ ...

  4. c#批量插入

    一.创建一个用来测试的数据库和表 USE [Test] GO /****** Object: Table [dbo].[student] Script Date: 2019/4/11 15:38:59 ...

  5. ubuntu下修改子网掩码

    1.修改网络配置 修改 /etc/netplan/01-network-manager-all.yaml 文件 vi /etc/netplan/01-network-manager-all.yaml ...

  6. 洛谷 P1886 滑动窗口(单调队列)

    题目链接 https://www.luogu.org/problemnew/show/P1886 题目描述 现在有一堆数字共N个数字(N<=10^6),以及一个大小为k的窗口.现在这个从左边开始 ...

  7. javascript的继承模式

    在javascript里面看到javascript的继承模式和传统的继承模式是有区别的,就想查资料看一下到底有区别,就看到了这篇文章,觉得讲得还可以,暂时先放上来,以后有别的东西再补充: http:/ ...

  8. shell变量的声明和使用

  9. Thymeleaf入门——入门与基本概述

    https://www.cnblogs.com/jiangbei/p/8462294.html 一.概述 1.是什么 简单说, Thymeleaf 是一个跟 Velocity.FreeMarker 类 ...

  10. rsync之expect脚本shell

    r_expect.sh: #!/bin/expect -f set timeout 30 #spawn rsync -avz --delete --exclude-from=exclude.list ...