jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stromas, Aaron (NIH/OD) [C]" <>
Subject RE: ForEach and BeanShell question
Date Fri, 26 Jun 2009 12:13:02 GMT

-----Original Message-----
From: sebb [] 
Sent: Thursday, June 25, 2009 2:08 PM
To: JMeter Users List
Subject: Re: ForEach and BeanShell question

On 25/06/2009, Stromas, Aaron (NIH/OD) [C] <> wrote:
> Greetings!
>  I have a test plan that uses a RE Extractor to convert the values of the HTML select
element to the input values of the ForEach controller. These values are of the form X,M,N~Y,A,B~...~Z,C,D,
and I can see from the log that they are properly generated. The reference name for these
values is tuple. The ForEach controller Input variable prefix is tuple, and the Output variable
name is threetuple.
>  I am emulating Javascript which breaks up the value of selected option and submits an
HTTP request with the values of each of thre-tuple as parameter. To that end, I have another
ForEach controller as a child of the first one with the BeanShell preprocessor:
>  String[] tuples = vars.get("threetuple_1").split("~");
>  List list = new ArrayList();
>  for (int i = 0; i < tuples.length; i++) {
>     list.add(tuples[i].split(","));
>  }
>  vars.put("params", list);
>  The inner ForEach controller has a HTTP Request sampler with a BeanShell preprocessor
whose job is to break up the three-tuple into individual parameters.
>  In short, no HTTP sampler ever executes, and the log shows that the inner ForEach controller
receives null input.
>  I can see in the log, what I presume to be invocation of the outer ForEach:
>  ... jmeter.control.ForEach resultstring isDone=SAR,713,0~RCC,988,343...
>  and the inner ForEach:
>  ... jmeter.control.ForeachController: No entries found - null first entry: params_1
>  The questions are: is there any way of knowing why the BeanShell preprocessor did not
>  Once that problem resolved, I need to tackle the business of the ForEach output variable
which gets loop index appended to it, so how can the BeanShell "know" which variable to use?
>  Any suggestions?

The ForEach Controller needs multiple variables, not a list:

It still isn't working for me. This is the schematic of my test:

ForEach controller 
   Input var prefix: tuple
   Output var name: threetuple
   ForEach controller
      Input var prefix: params
      Output var prefix: reqparams
      BeanShell preprocessor
      |   String packed = vars.get("threetuple") 
      |   String[] tuples =packed.split("~");
      |   for (int i = i; i <= tuples.length; i++) {
      |       vars.put("params" + "_" + i, tuples[i-1]);
      HTTP request
      BeanShell preprocessor
           String packed = vars.get("params");
           String[] names = new String[]{"type", "p1", "p2", "p3"};
           for (int i = 0; i < names.length; i++) {
               vars.put(names[i], p[i]);

I have also tried vars.get("threetuple_1") in the first BeanShell. No matter what I try, in
the log I see "jmeter.control.ForeachController: No entries found - null first entry: params_1".
Sorry for badgering, but I must be missing something basic. TIA,


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message