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驱动 ...
随机推荐
- 微信非全屏播放设置(仅Iphone)
由于微信X5内核强制视频全屏,用X5自带内核播放,一般内嵌视频打开播放就会被全屏. ihpone里面可以通过设置 x-webkit-airplay="true" webkit-pl ...
- Gym - 100851G:Generators(人尽皆知但是WA题)
题意:现在有函数,每一项Xi=(A*X(i-1)+B)%C.现在给定N个函数以及K:X0,A,B,C.然你再每个函数选择一个数,使得其和最大,而且不被K整除. X0,A,B,C<=1e3 :K& ...
- 【LeetCode】023. Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 题 ...
- Oracle RAC TAF 无缝failover
理论背景: TAF( Transparent Application Failover ) allows oracle clients to reconnect to a surviving inst ...
- java多线程编程核心技术——第四章总结
第一节使用ReentrantLock类 1.1使用ReentrantLock实现同步:测试1 1.2使用ReentrantLock实现同步:测试2 1.3使用Condition实现等待/同步错误用法与 ...
- win7下vs2010开发atl服务
问题一: 编译服务后,提示出下错误 Microsoft.CppCommon.targets(113,5): error MSB3073: 命令 " ***.exe " /RegS ...
- C#中DataTable用法
一.select方法1.筛选出男性且名字中带有李的人然后按照生日降序排列(1)DataRow[] rows=DataTable.Select("sex='"+"男&quo ...
- C#中打开文件、目录、保存窗口
打开文件代码: try { OpenFileDialog of = new OpenFileDialog(); of.ShowDialog(); txt_destFilePath.Text = of. ...
- project online get approvals task data 获取审批待办任务接口
调用接口地址:重要 http://xxxx/sites/pwa/_vti_bin/PSI/ProjectServer.svc Header 三个必要参数: 其中SOAPAction写死就行,如果是on ...
- GIF助手激活教程(购买+激活)图文版
GIF助手首页==>设置(右上角) ==>输入激活码会弹出购买或者激活的对话框.(如果不明白操作,可以点击如何购买激活码先查看购买帮助指南再进行购买) 点击复制设备码并购买. 此时会进入到 ...