On 26/06/2009, Stromas, Aaron (NIH/OD) [C] <[email protected]> wrote:
>
>
> -----Original Message-----
> From: sebb [mailto:[email protected]]
> 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] <[email protected]> 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 execute?
> >
> > 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:
>
>
> http://jakarta.apache.org/jmeter/usermanual/component_reference.html#ForEach_Controller
>
>
>
> It still isn't working for me. This is the schematic of my test:
>
> ForEach controller
> Input var prefix: tuple
What sets "tuple_1" etc?
> Output var name: threetuple
> |
> |
> ForEach controller
> Input var prefix: params
These need to be set BEFORE the controller is executed.
> Output var prefix: reqparams
> |
> |
> BeanShell preprocessor
> | String packed = vars.get("threetuple")
> | String[] tuples =packed.split("~");
> | for (int i = i; i <= tuples.length; i++) {
I presume that is int i = 1; ...
> | vars.put("params" + "_" + i, tuples[i-1]);
> |
> |
This is all too late.
> HTTP request
> |
> BeanShell preprocessor
Did you mean post-processor?
> 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".
That's because it is null.
> Sorry for badgering, but I must be missing something basic. TIA,
Use the Debug Sampler to show what variables are set at that point in
the test plan.
> -a
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]