Jmeter ExcelDataPreProcessor
Jmeter的预处理器主要是用来在采样器(sample)被执行之前做一些额外的工作,比如参数化等等。
本文写一个例子来说明如何增加一个预处理器,需求如下:我们想在执行采样器前读取Excel文件中的数据作为参数,此预处理器可以配合While循环控制器使用,每次循环读取excel中的一行数据。
@GUIMenuSortOrder(5)
public class ExcelDataPreProcessor extends AbstractTestElement implements
Cloneable, PreProcessor, TestBean {
private static final Logger log = LoggerFactory
.getLogger(ExcelDataPreProcessor.class); private String filename = ""; // file to source (overrides script) private static final long serialVersionUID = 233L; @Override
public void process() {
//做你想做的一些逻辑
System.out.println(this.getFilename());
} public String getFilename() {
return filename;
} public void setFilename(String filename) {
this.filename = filename;
} @Override
public Object clone() {
return super.clone();
}
}
2、写一个对应的Bean
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
*/ package org.apache.jmeter.modifiers; import java.beans.PropertyDescriptor;
import java.util.ResourceBundle; import org.apache.jmeter.testbeans.BeanInfoSupport;
import org.apache.jmeter.testbeans.TestBean;
import org.apache.jmeter.testbeans.gui.FileEditor; public class ExcelDataPreProcessorBeanInfo extends BeanInfoSupport { public ExcelDataPreProcessorBeanInfo() {
this(ExcelDataPreProcessor.class,null);
} public ExcelDataPreProcessorBeanInfo(Class<? extends TestBean> beanClass, String[] languageTags) {
this(beanClass, languageTags, null);
} protected ExcelDataPreProcessorBeanInfo(Class<? extends TestBean> beanClass, String[] languageTags, ResourceBundle rb) {
super(beanClass);
PropertyDescriptor p; p = property("filename"); // $NON-NLS-1$
p.setValue(NOT_UNDEFINED, Boolean.TRUE);
p.setValue(DEFAULT, ""); // $NON-NLS-1$
p.setPropertyEditorClass(FileEditor.class); createPropertyGroup("filenameGroup", // $NON-NLS-1$
new String[] { "filename" }); // $NON-NLS-1$ } }
这个是描述界面布局和相关元素的的
3,在saveservice.properties文件中增加配置:
ExcelDataPreProcessor=org.apache.jmeter.modifiers.ExcelDataPreProcessor
4、增加一个(ExcelDataPreProcessorResources.properties)多语言支持:
Jmeter ExcelDataPreProcessor的更多相关文章
- jmeter之线程组的使用
线程组 在使用jmeter性能测试时,我们都得先添加个线程组,右键testplan-->添加-->Threads-->线程组.在线程组下执行. 问题:为了能够让jmeter在做性能测 ...
- 从Fiddler抓包到Jmeter接口测试(简单的思路)
备注:本文为博主的同事总结的文章,未经博主允许不得转载. Fiddler下载和配置安装 从网上下载fiddler的安装包即可,直接默认,一直点击下一步,直至安装完成. 安装完成后直接打开Fiddler ...
- Jmeter正则表达式
Jmeter正则表达式 文章转自:http://www.cnblogs.com/jamesping/articles/2252675.html 正则表达式可以帮助我们更好的描述复杂的文本格式.一旦你描 ...
- Jmeter安装与环境部署
Jmeter安装与环境部署 版权声明:本文为博主原创文章,未经博主允许不得转载. 博主:海宁 联系:whnsspu@163.com
- JMeter压力测试
Apache JMeter是Apache组织开发的基于Java的压力测试工具.用于对软件做压力测试,它最初被设计用于Web应用测试但后来扩展到其他测试领域. 它可以用于测试静态和动态资源例如静态文件. ...
- 压力测试之badboy和Jmeter的简单使用方法
文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/ 1.背景 所谓压力测试是指,通过确定一个系统的瓶颈或者不能接收的性能点, ...
- 用jmeter通过ssl验证访问https
找了一个支付宝的网站尝试.https://memberprod.alipay.com/account/reg/index.htm 我用的是chrome,点这个小锁 如果是IE也可以在网页上右键,属性, ...
- JMeter使用文档
JMeter使用文档 1.JMeter安装步骤 1.1Windows环境 a.安装jdk(对应windows系统位数) http://www.oracle.com/technetwork/java/j ...
- jmeter之连接mysql和SQL Server配置
下载jdbc驱动 在使用jmeter做性能或自动化测试的时候,往往需要直接对数据库施加压力,或者某些参数只能从数据库获取,这时候就必须使用jmeter连接数据库. 1.下载对应的驱动包 mysql驱动 ...
随机推荐
- Handler的另外一种用法(HandlerThread)
直接上代码: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Handler ...
- 【遍历二叉树】01二叉树的前序遍历【Binary Tree Preorder Traversal】
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 给定一个二叉树,返回他的前序遍历的 ...
- C++ 播放音频流(PCM裸流)
直接上代码,如果有需要可以直接建一个win32控制台程序然后将代码拷过去改个文件名就可以用了(注意将声道和频率与你自己的文件对应哦).当然我自己也用VS2008(VS2013好用太多,强烈推荐还是用V ...
- 51Nod1766 树上的最远点对
1766 树上的最远点对 n个点被n-1条边连接成了一颗树,给出a~b和c~d两个区间,表示点的标号请你求出两个区间内各选一点之间的最大距离,即你需要求出max{dis(i,j) |a<=i&l ...
- Parallel Programming-使用CancellationTokenSource调度并行运行的Task
本文主要介绍使用CancellationTokenSource调度并行运行的Task. 一.使用场景 有多个Task并行运行时,如果其中一个Task所运行的程序出现异常,我们想马上终止所有待执行的Ta ...
- HDOJ1671(字符串前缀匹配)
#include<iostream> #include<cstdio> #include<string> #include<vector> #inclu ...
- .NET生成ICO图标
using System; using System.Collections.Generic; using System.Web; using System.Drawing; using System ...
- Learning Python 005 字符串和编码
Python 字符串和编码 介绍 计算机是美国人发明的,最早只有127个字母被编码到计算机,这个编码表被称为ASCII编码,比如大写字母A的编码是65,小写字母z的编码是122. 处理中文一个字节显然 ...
- servlet与filter的加载顺序详解
项目:3个filter,3个servlet,匹配的url路径/hello. 情况1:servlet没加<load-on-startup></load-on-startup>情 ...
- 5.Windows应急响应:挖矿病毒
0x00 前言 随着虚拟货币的疯狂炒作,挖矿病毒已经成为不法分子利用最为频繁的攻击方式之一.病毒 传播者可以利用个人电脑或服务器进行挖矿,具体现象为电脑CPU占用率高,C盘可使用空间骤降, 电脑温度升 ...