You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by frank <hw...@windowslive.com> on 2012/11/08 04:50:13 UTC

setProperty doesn't work

using jmeter 2.6, and i have 2 thread groups like next : 

-group1
     |_request1
             |_beanshell postprocessor1
     |_request2
-group2
     |_request3
             |_beanshell postprocessor2
     |_request4

beanshell postprocessor1 like next : 

${__setProperty("rootObjectId", ${rootObjectId})};
String s = "${bookingNo}";
if(!s.equals("")){

${__setProperty(vari1,abc,)};

}else{

${__setProperty(vari1,,)};
}

it'll execute 'else' statement

and in request2 , it will use ${__property(vari1,,)} to get the property
value, and the property value is empty.

for beansehll processor2, its beanshell script is the same as beanshell
processor1, but now it'll execute 'if' statement, that is i want to set
value 'abc' for the property

the problem is : in request4, ${__property(vari1,,)} still return empty
string, but not abc.

and the most confused is : if i add double quote for property name vari1,
that is in group2, if i changed the beanshell script to : 

if(!s.equals("")){

${__setProperty("vari1",abc,)};

}else{

${__setProperty("vari1",,)};
}

${__property("vari1",,)}

then it works, the ${__property("vari1",,)} of request4 will return abc.

or if i add double quote for property vari1 in group1, but NOT add in
group2, it also works, in request4, i can get the value abc.

so what's the problem?  
Thanks in advance.



--
View this message in context: http://jmeter.512774.n5.nabble.com/setProperty-doesn-t-work-tp5715260.html
Sent from the JMeter - User mailing list archive at Nabble.com.

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


Re: setProperty doesn't work

Posted by Deepak Shetty <sh...@gmail.com>.
In beanshell use the props object to set a property and follow java rules
for when to quote or not quote a string.

Its likely you are getting syntax errors (And should be in the log)
On Nov 7, 2012 7:50 PM, "frank" <hw...@windowslive.com> wrote:

> using jmeter 2.6, and i have 2 thread groups like next :
>
> -group1
>      |_request1
>              |_beanshell postprocessor1
>      |_request2
> -group2
>      |_request3
>              |_beanshell postprocessor2
>      |_request4
>
> beanshell postprocessor1 like next :
>
> ${__setProperty("rootObjectId", ${rootObjectId})};
> String s = "${bookingNo}";
> if(!s.equals("")){
>
> ${__setProperty(vari1,abc,)};
>
> }else{
>
> ${__setProperty(vari1,,)};
> }
>
> it'll execute 'else' statement
>
> and in request2 , it will use ${__property(vari1,,)} to get the property
> value, and the property value is empty.
>
> for beansehll processor2, its beanshell script is the same as beanshell
> processor1, but now it'll execute 'if' statement, that is i want to set
> value 'abc' for the property
>
> the problem is : in request4, ${__property(vari1,,)} still return empty
> string, but not abc.
>
> and the most confused is : if i add double quote for property name vari1,
> that is in group2, if i changed the beanshell script to :
>
> if(!s.equals("")){
>
> ${__setProperty("vari1",abc,)};
>
> }else{
>
> ${__setProperty("vari1",,)};
> }
>
> ${__property("vari1",,)}
>
> then it works, the ${__property("vari1",,)} of request4 will return abc.
>
> or if i add double quote for property vari1 in group1, but NOT add in
> group2, it also works, in request4, i can get the value abc.
>
> so what's the problem?
> Thanks in advance.
>
>
>
> --
> View this message in context:
> http://jmeter.512774.n5.nabble.com/setProperty-doesn-t-work-tp5715260.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>
>

Re: setProperty doesn't work

Posted by Deepak Shetty <sh...@gmail.com>.
Use the props object in beanshell
On Nov 19, 2012 11:25 PM, "frank" <hw...@windowslive.com> wrote:

> i found that ${_setProperty()} will be called before beanshell script, even
> it won't be executed in beanshell script, right?
>
>
>
> --
> View this message in context:
> http://jmeter.512774.n5.nabble.com/setProperty-doesn-t-work-tp5715260p5715354.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>
>

Re: setProperty doesn't work

Posted by frank <hw...@windowslive.com>.
i found that ${_setProperty()} will be called before beanshell script, even
it won't be executed in beanshell script, right?



--
View this message in context: http://jmeter.512774.n5.nabble.com/setProperty-doesn-t-work-tp5715260p5715354.html
Sent from the JMeter - User mailing list archive at Nabble.com.

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


Re: setProperty doesn't work

Posted by sebb <se...@gmail.com>.
On 8 November 2012 03:50, frank <hw...@windowslive.com> wrote:
> using jmeter 2.6, and i have 2 thread groups like next :
>
> -group1
>      |_request1
>              |_beanshell postprocessor1
>      |_request2
> -group2
>      |_request3
>              |_beanshell postprocessor2
>      |_request4
>
> beanshell postprocessor1 like next :
>
> ${__setProperty("rootObjectId", ${rootObjectId})};

Won't work - function references are resolved before BSH sees the script.

You need to use commands like

props.get("START.HMS");
props.put("PROP1","1234");

This is documented briefly here:

http://jmeter.apache.org/usermanual/component_reference.html#BeanShell_Sampler

> String s = "${bookingNo}";
> if(!s.equals("")){
>
> ${__setProperty(vari1,abc,)};
>
> }else{
>
> ${__setProperty(vari1,,)};
> }
>
> it'll execute 'else' statement
>
> and in request2 , it will use ${__property(vari1,,)} to get the property
> value, and the property value is empty.
>
> for beansehll processor2, its beanshell script is the same as beanshell
> processor1, but now it'll execute 'if' statement, that is i want to set
> value 'abc' for the property
>
> the problem is : in request4, ${__property(vari1,,)} still return empty
> string, but not abc.
>
> and the most confused is : if i add double quote for property name vari1,
> that is in group2, if i changed the beanshell script to :
>
> if(!s.equals("")){
>
> ${__setProperty("vari1",abc,)};
>
> }else{
>
> ${__setProperty("vari1",,)};
> }
>
> ${__property("vari1",,)}
>
> then it works, the ${__property("vari1",,)} of request4 will return abc.
>
> or if i add double quote for property vari1 in group1, but NOT add in
> group2, it also works, in request4, i can get the value abc.
>
> so what's the problem?
> Thanks in advance.
>
>
>
> --
> View this message in context: http://jmeter.512774.n5.nabble.com/setProperty-doesn-t-work-tp5715260.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>

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