首页 > 系统相关 >BeanShell PostProcessor 后置处理器

BeanShell PostProcessor 后置处理器

时间:2024-03-05 14:44:38浏览次数:17  
标签:code String 后置 使用 BeanShell PostProcessor data log

一 主要作用:

     BeanShell PostProcessor 主要用来提取响应数据,对数据做处理分析的。

二 概念:

    作用类似于后置处理器,其中的ctx、vars、props、prev、log都和BeanShell Sampler一样一样
   ![image.png](https://fynotefile.oss-cn-zhangjiakou.aliyuncs.com/fynote/fyfile/16194/1663307082040/f1a46708c4ae40229e892abaf6985a72.png)
 重点解释前面没有的:
**data: 允许beanshell脚本通过data访问当前取样器的数据,映射SamplerResult中的getResponseData,相当于prev.getResponseData**
通过阅读源码可以知道,这个data是使用StringCoding.encoding("UTF-8")生成的,并转化成了字节码,所以使用它需要解码才能使用;
例如可以如下去使用:
``` String s = new String(data); log.info(s); ```

三 基础案例:

需求:
``` 1. 使用log打印当前取样器的响应体数据data String s = new String(data); log.info(s); 2. 使用Java代码提取响应体的数据,并保存到JMeter变量 //提取code值200,并保存在jmeter变量code中 //使用正则 import java.util.regex.Matcher; import java.util.regex.Pattern; String pattern = "\"code\"\":\"(.+?)\""; Pattern p = Pattern.complile(pattern);//创建正则对象 Matcher m = p.matcher(s); // 使用执勤的正则对象p匹配数据s if (m.find(){   String code= m.group(1);   log.info(code);   vars.put("code",code); }   ```

标签:code,String,后置,使用,BeanShell,PostProcessor,data,log
From: https://www.cnblogs.com/yongheng999/p/18054013

相关文章

  • 核心子方法5: invokeBeanFactoryPostProcessors(beanFactory)方法详解
    先总结: 该方法通过指定顺序,遍历调用各种实现了BeanDefinitionRegistryPostProcessor接口或BeanFactoryPostProcessor接口,的beanFactory后处理器注: BeanDefinitionRegistryPostProcessor接口继承了BeanFactoryPostProcessor接口调用顺序: 1.先调用已经提前放入Applicat......
  • spring重点后置处理器
    1.DefaultListableBeanFactory的作用:默认实现了ListableBeanFactory和BeanDefinitionRegistry接口,基于beandefinition对象,是一个成熟的beanfactroy。最典型的应用是:在访问bean前,先注册所有的definition(可能从beandefinition配置文件中)。使用预先建立的bean定义元数......
  • BeanShell Sample 如何使用?
    一引入:eanShellSample主要用于生成一些逻辑复杂的数据,例如用于加解密数据;**每次调用前重置bsh.Interpreter:每个BeanShell副本都有自己的解释器副本(每个线程都有),**在循环内,如果没有勾选重置bs.Interpreter,那么解释器会保留在调用过程中,一些长时间运行的测试就会占用大......
  • 英语形容词后置用法
    问题来源:TheEconomist:  'Ever-strongercopyrightprotectionhaswithheldincalculableamountsofculturefromthepublicdomain,'arguesBenSobelinaguestessay.'Butwewon’trepairthatdamagewithexceptionstailor-madetobenefitthe......
  • jmeter_BeanShell脚本&通过BeanShell进行加解密方法
    BeanShell脚本BeanShell简介:BeanShell是一种完全符合Java语法规范的脚本语言,并且又拥有自己的一些语法和方法;BeanShell是一种松散类型的脚本语言;BeanShell是用Java写成的,一个小型的、免费的、可以下载、嵌入式的Java源代码解释器,具有对象脚本的特性;BeanShell可以执行标准J......
  • jmeter 使用 BeanShell PostProcessor 过程中遇到的一些问题记录
    关于jmeter中使用BeanShellPostProcessor遇到的一些问题记录:1、BeanShellPostProcessor的位置BeanShellPostProcessor要放在获取内容对应的线程的同一个层级,如:2、内容:例如:FileWriterfstream=newFileWriter("E:\aaskNodeId.csv");//,如果要建立文件并追加写入数据,需......
  • Jmeter后置处理器之xpath提取器
    一前言:环境:Jmeter5.3window10简单介绍下后置处理器中的xpath提取器二xpath提取器当接口返回内容是xml格式或者html格式时,可以使用xpath提取器从中提取值参数字段说明:applyto:前面介绍的断言及其他提取器都有这个选项,就不重复了xmlparsingoptions:与前面介绍的xpa......
  • Jmeter前置处理器之beanshell处理加密
    一前言环境:Jmeter5.3window10利用beanshell在前置处理器中加密接口用到的数据,在接口请求之前加密数据例子还是用之前的例子,稍微改造下,加一个beanshell的前置处理器运行-查看结果树,httpbin接口会在响应数据中显示接口请求的数据,看下请求的密码是否加密如上,接口请求......
  • BeanFactory后置处理器之PropertySourcesPlaceholderConfigurer
    有的时候,我们需要读取配置文件中的属性,将其作为成员变量赋给对应的Bean,如下通过xml配置:<beanid="dataSource"class="com.alibaba.druid.pool.DruidDataSource"init-method="init"destroy-method="close"><propertyname="url"val......
  • Spring的BeanDefinitionRegistryPostProcessor接口详解
    BeanDefinitionRegistryPostProcessor介绍BeanDefinitionRegistryPostProcessor它是Spring框架的一个扩展点,用于对Bean定义的注册过程进行干预和定制,例如添加,修改或删除Bean定义等。BeanDefinitionRegistryPostProcessor它继承BeanFactoryPostProcessor接口,并在其基础上扩展了......