Reputation: 1
Is it possible ? Can someone provide us with a sample code? We have a beanshell preprocessor returning a set of variables to the JMX script. Can we return a array instead?
Upvotes: 0
Views: 2867
Reputation: 168122
Following options are available:
vars.putObject() - stores an arbitrary Java Object into a JMeter Variable like below:
List myList = new ArrayList();
myList.add("something");
myList.add("something else");
vars.putObject("myList", myList);
props.put() or props.putAll() - the same but for JMeter Properties instead of JMeter Variables
Use bsh.shared namespace like:
In one sampler:
int [] array = new int {1,2,3};
bsh.shared.myArray = array;
In another sampler:
int [] array = bsh.shared.myArray;
See How to use BeanShell: JMeter's favorite built-in component for additional information on Beanshell scripting in Apache JMeter.
Upvotes: 2