jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Schulberg" <David.Schulb...@objectconsulting.com.au>
Subject RE: Beanshell pre-processor
Date Wed, 15 Aug 2007 02:24:09 GMT
Hi,
 
I changed my beanshell script as per the suggestion to 
 
vars.put("Relation") = vars.get("Relation2");
vars.put("Person") = vars.get("Person2");
if (vars.get("Relation2")) >= 6
{
    vars.put("Relation") = vars.get("Relation2");
    vars.put("Person") = vars.get("Person2");
}
else if (vars.get("Relation3")) >= 6
{
    vars.put("Relation") = vars.get("Relation3");
    vars.put("Person") = vars.get("Person3");
}
else if (vars.get("Relation4")) >= 6
{
    vars.put("Relation") = vars.get("Relation4");
    vars.put("Person") = vars.get("Person4");
}
else if (vars.get("Relation5")) >= 6
{
    vars.put("Relation") = vars.get("Relation5");
    vars.put("Person") = vars.get("Person5");
}
else if (vars.get("Relation6")) >= 6
{
    vars.put("Relation") = vars.get("Relation6");
    vars.put("Person") = vars.get("Person6");
}

but that made no difference - same error.
 
Regards,
David Schulberg

Object Consulting | Senior Consultant
email: david.schulberg@objectconsulting.com.au
----------------------------------------------------------------
consulting | development | training | support
our experience makes the difference 

________________________________

From: sebb [mailto:sebbaz@gmail.com]
Sent: Tue 14/08/2007 6:54 PM
To: JMeter Users List
Subject: Re: Beanshell pre-processor



On 14/08/07, David Schulberg <David.Schulberg@objectconsulting.com.au> wrote:
> Hi,
>
> Have added a beanshell preprocessor to a sampler for the purpose of setting variables
to be used in the sampler request.
>
> It doesn't work - get error in jmeter log:

Because you are doing double evaluation of the variables.

> jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline
evaluation of: ``vars.put("") = vars.get("4"); vars.put("${Person}") = vars.get("220780625");
if  . . . '' : Can't assign to prefix.
>
> My preprocessor script is attempting to set user variables Relation and Person:
>
> vars.put("${Relation}") = vars.get("${Relation2}");

Assume Relation="aunt" and Relation2="uncle", then what Beanshell sees is

vars.put("aunt") = vars.get("uncle");

because the variables are textually substituted in the script field
before handing to Beanshell.

You need to use

vars.put("Relation") = vars.get("Relation2");


> vars.put("${Person}") = vars.get("${Person2}");
> if (vars.get("${Relation2}")) >= 6
> {
>    vars.put("${Relation}") = vars.get("${Relation2}");
>    vars.put("${Person}") = vars.get("${Person2}");
> }
> else if (vars.get("${Relation3}")) >= 6
> {
>    vars.put("${Relation}") = vars.get("${Relation3}");
>    vars.put("${Person}") = vars.get("${Person3}");
> }
> else if (vars.get("${Relation4}")) >= 6
> {
>    vars.put("${Relation}") = vars.get("${Relation4}");
>    vars.put("${Person}") = vars.get("${Person4}");
> }
> else if (vars.get("${Relation5}")) >= 6
> {
>    vars.put("${Relation}") = vars.get("${Relation5}");
>    vars.put("${Person}") = vars.get("${Person5}");
> }
> else if (vars.get("${Relation6}")) >= 6
> {
>    vars.put("${Relation}") = vars.get("${Relation6}");
>    vars.put("${Person}") = vars.get("${Person6}");
> }
>
>
> David Schulberg
>
> Object Consulting | Senior Consultant
> email: david.schulberg@objectconsulting.com.au
> ----------------------------------------------------------------
> consulting | development | training | support
> our experience makes the difference
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org





Mime
View raw message