jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: How to set a javascript value as a JMeter property
Date Mon, 19 Mar 2012 16:10:16 GMT
On 19 March 2012 15:38, Pulkit Singhal <pulkitsinghal@gmail.com> wrote:
> Thanks for the explanation sebb!
>
> But I think I need a little more clarification as for the following 3
> statements:
> vars.put("upcArray", upcArray);

vars is of class JMeterVariables.

> props.put("upcArray1", upcArray.toString());

props is of class java.util.Properties

> props.put("upcArray2", upcArray);
> props.putObject("upcArray3", upcArray);
>
> Debug Sampler yields:
>
> JMeterVariables:
> upcArray="024543069706","025101200326","815849010697","083616276748","602498458433","037429040331","617917817128","021823511290","015095538741","075678164743"
>
> JMeterProperties:
> upcArray1="024543069706","025101200326","815849010697","083616276748","602498458433","037429040331","617917817128","021823511290","015095538741","075678164743"
> upcArray2=org.mozilla.javascript.NativeArray@246af18d
>
> So upcArray1 and upcArray2 don't really get the same value to be stored in
> properties ... and using putObject does not store anything in the
> JMeterProperties :(
>
> On Mon, Mar 19, 2012 at 10:23 AM, sebb <sebbaz@gmail.com> wrote:
>
>> On 19 March 2012 14:58, Pulkit Singhal <pulkitsinghal@gmail.com> wrote:
>> > Using:
>> > props.put("nameArray", nameArray.toString());
>> > did the trick instead of:
>> > *${__setProperty("nameArray", nameArray)};*
>>
>> That is  resolved by JMeter before the script is passed to the BSF sampler.
>>
>> >
>> > Using:
>> > props.put("nameArray", nameArray);
>> > also looks promising but it puts an object instead of a comma separated
>> > string into properties and I'm not quite sure if that object is actually
>> > usable later on, will post back later with that.
>>
>> It should work the same as
>>
>> props.put("nameArray", nameArray.toString)
>>
>> because the JMeterVariables method signature is:
>>
>> public void put(String key,
>>                String value)
>>
>> Use putObject to store an Object.
>>
>> See:
>>
>> http://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterVariables.html
>>
>> > On Mon, Mar 19, 2012 at 8:57 AM, Pulkit Singhal <pulkitsinghal@gmail.com
>> >wrote:
>> >
>> >> I'm using the BSF PostProcessor to put together an array of names.
>> >>
>> >> I can store it in JMeter variables as a comma,separated list just fine -
>> >> *vars.put("nameArray", nameArray); // works :)
>> >>
>> >> *Results in Debug Sampler show -
>> >> *JMeterVariables:
>> >> nameArray="Let It Go (Japan)","Deskkontrolados","Caillou: Dr. Caillou -
>> >> VHS","Where Did You Sleep Last Night: Lead... [LP]","20 More Explosive
>> >> Fantastic Rockin' Mega...","The Secret NASA Transmissions: The Raw
>> Footage
>> >> - DVD","L'Etang De Kukufah","Arias (CD+DVD) (Limited Edition) (Deluxe
>> >> Edition) (Spkg)","Don't You Want to Rock","Talk On Corners: Special
>> Edition"
>> >> *
>> >>
>> >> But for some reason (in the next line) the same value is not being
>> >> accepted into the JMeter properties -
>> >> *${__setProperty("nameArray", nameArray)}; // does not work :(
>> >> *
>> >> Results in Debug Sampler show -
>> >> *JMeterProperties:
>> >> "nameArray"= nameArray*
>> >>
>> >> Can anyone tell me what I may be doing wrong here?
>> >>
>>
>> ---------------------------------------------------------------------
>> 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


Mime
View raw message