如何在Jmeter的变量/属性中存储/更新hashmap对象 [英] How to store/update a hashmap object in a variable/property in Jmeter

查看:158
本文介绍了如何在Jmeter的变量/属性中存储/更新hashmap对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在 JSR233采样器内创建一个哈希映射,它将包含某些外部Java实用程序的某些头文件和属性元素,我将使用 Java请求采样器。我将需要创建许多hashmaps,因为键值对将根据我测试的系统而有所不同。例如,我将不得不更改 JMSReplyTo JMSCorrelationID $ TextBody :每个哈希映射的字段。所有这些都是在一个线程组内完成的,但我也可能想在其他线程组中实现它。

I need to create a hash-map inside of a JSR233 sampler that will contain certain headers and properties elements for an external java utility that I will call using a Java Request Sampler. I am going to need to create many hashmaps as the key-value pairs will vary based on the systems I am testing. For example, I am going to have to change the JMSReplyTo, the JMSCorrelationID, $TextBody: fields for every hash-map. All of this is done inside one thread group, but I may also want to implement it in other thread groups down the road.


我应该如何构建我的测试计划?是否有可能创建一个全局变量来保存哈希映射?然后在相应的 JSR223 Sampler 中,对于每个测试,修改变量的值?

How should I structure my Test Plan? Is it possible to create a global variable that will hold the hash-map? And then inside the respective JSR223 Sampler, for each test, modify the value of the variable?

我对Jmeter还是比较新的,不知道何时使用属性以及何时使用变量。在这种情况下,我希望每当创建一个新的散列映射对象时, 1 var或属性将改变整个测试计划。我想知道这条路线是否可行,或者是否有其他建议。

I am still fairly new to Jmeter and don't know when to use properties and when to use variables. In this case I would like 1 var or property that will change throughout my test-plan whenever I create a new hash-map object. I would like to know if this route is feasible, or if an alternative is advised.

我想在Jmeter中创建一个HashMap对象的原因是因为我不' t希望拥有数千个txt文件,Java实用程序将读取并解析键值对(这些值在每个 txt文件中都有所不同)。

The reason I would like to create a HashMap object in Jmeter is because I don't want to have thousands of txt files that the Java utility will read and parse for the key-value pairs (those values vary in every txt file).


相反,我想知道是否有方法在Jmeter中创建HashMap
对象并将其存储在变量/属性中可以
的对象作为参数在我的 Java请求中传递

注意:我不希望您为我制定测试计划,但是如果有Jmeter经验的人指引我朝着正确的方向发展,我将不胜感激。

Note: I do not want you to create the test plan for me, but rather I would appreciate it if someone with Jmeter experience guide me in the right direction.

推荐答案

不使用常规的get put操作

Instead of using regular get put operations

 vars.get("map"); vars.put("map", map);

您可以对字符串以外的对象使用get put操作:

You can use get put operations on Objects other than string:

 vars.putObject("map", map);

稍后获取地图:

And get map later:

 map = vars.getObject("map");

这篇关于如何在Jmeter的变量/属性中存储/更新hashmap对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆