Reputation: 569
In my Jmeter script at the beginning of the thread I have defined a class and a list array of those that class:
class TempClass{
String Name;
String Prop1;
}
props.put("TempClass", TempClass);
ArrayList<TempClass> tempList = new ArrayList<TempClass>();
vars.putObject("tempList", tempList);
I would like instantiate that class on one of the HTTP Req. post Processor with Groovy, then add its properties and add that class to an array of those classes.
i.e
//def t1 = new TempClass();
t1 = props.get("TempClass");
t1.Name= "Suzie";
t1.Prop1 = "3";
tempList = vars.getObject("tempList");
tempList.add(t1);
vars.putObject("tempList", tempList);
I get an error when I instantiate the class:
No such property: Name for class: TempClass
Please help thanks
Upvotes: 0
Views: 952
Reputation: 34516
Correct code should be:
class TempClass{
String name;
String prop1;
}
props.put("TempClass", new TempClass());
ArrayList<TempClass> tempList = new ArrayList<TempClass>();
vars.putObject("tempList", tempList);
Then:
def t1 = props.get("TempClass");
t1.name= "Suzie";
t1.prop1 = "3";
tempList = vars.getObject("tempList");
tempList.add(t1);
vars.putObject("tempList", tempList);
Few notes about JMeter as I am not sure what you are trying to do:
Upvotes: 1