jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marc Chiarini (Tufts)" <marc.chiar...@tufts.edu>
Subject Re: Re: Exception When using the Javascript Function
Date Tue, 07 Apr 2009 14:16:40 GMT
Currently, both of these expressions in my UDVs work properly for me, 
though according to you they shouldn't:

${__javaScript('${__P(delay)}'*'${__P(mythreads)}')}

${__javaScript(Math.floor('${__property(maxcnt,,512)}'/'${__P(mythreads)}'))}


I suspect that Javascript is doing implicit type conversion, because 
both of these contexts are numeric (there is no string concatenation 
operator).  If he were using '+' he would need to watch out.

I'm not saying this is the right way to do things and I agree that we 
should get to the root of the problem, but I believe that if he tries 
it, it will tied him over for the time being.

Regards,
Marc

sebb wrote:
> On 04/04/2009, Marc Chiarini (Tufts) <marc.chiarini@tufts.edu> wrote:
>   
>>  Hi Michael,
>>
>>  Try putting your variables in quotes, for example:
>>  ${__javaScript('${VARONE}'*'${VARTWO}'/'${VARTHREE}')}
>>
>>  I'm not sure why this is necessary, but it's the only thing that worked for
>> me when I had a similar problem.
>>     
>
> That does not apply to numeric values.
>
> 1*2/3 is a valid numeric expression, but '1' * '2' / '3' is not.
>
>   
>>  The relevant reference is in the bottom green box at
>> http://jakarta.apache.org/jmeter/usermanual/functions.html#__javaScript
>>     
>
> Which refers to text strings " ... and JMeter variables."
> That should also say " which represent text strings"
>
>   
>>  Regards,
>>  Marc
>>
>>  --------------------
>>  Marc Chiarini
>>  PhD Candidate
>>  Tufts University
>>  Halligan Hall Extension 003C
>>  Medford, MA 02155
>>
>>
>>  Michael P. McDonnell wrote:
>>  When utilizing the Javascript function in Jmeter 2.3.2 (r665936):
>>
>> I have a Thread Group set up as follows:
>>
>> WebService (SOAP) Request
>>  -XPath Assertion
>>  -Counter
>> Constant Throughput Timer
>>
>> First of all I would like to note that the WebService Sampler rocks. Thank
>> you for making it. The counter + the assertion are also great.
>>
>> The constant throughput timer USUALLY works very well.
>>
>> However today I decided I was going to see if I could adjust my test by
>> passing one new variable from the command line, so I needed to do some
>> calculations within Jmeter.
>> I set the target throughput to:
>>
>>
>>
>> Values of Variables:
>> VARONE = 146.17 (which is set in the "User Defined Variables" for the test
>> plan)
>> VARTWO = 1000 (which is currently set in the "User Defined Variables" for
>> the test plan but will eventually be passed in)
>> VARTHREE = ${__javaScript(16*60)} (which is set in the "User Defined
>> Variables" for the test plan)
>>
>> When I start the test, only one sample goes through and then nothing until I
>> try to stop the test. At this point, I get this exception:
>>
>> Exception in thread "Thread-77"
>> org.mozilla.javascript.EvaluatorException:
>> missing ; before statement (<cmd>#1)
>>  at
>> org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:98)
>>  at
>> org.mozilla.javascript.DefaultErrorReporter.error(DefaultErrorReporter.java:85)
>>  at org.mozilla.javascript.Parser.addError(Parser.java:126)
>>  at
>> org.mozilla.javascript.Parser.reportError(Parser.java:132)
>>  at
>> org.mozilla.javascript.Parser.statementHelper(Parser.java:1175)
>>  at
>> org.mozilla.javascript.Parser.statement(Parser.java:623)
>>  at org.mozilla.javascript.Parser.parse(Parser.java:355)
>>  at org.mozilla.javascript.Parser.parse(Parser.java:293)
>>  at
>> org.mozilla.javascript.Context.compileImpl(Context.java:2238)
>>  at
>> org.mozilla.javascript.Context.compileString(Context.java:1284)
>>  at
>> org.mozilla.javascript.Context.compileString(Context.java:1273)
>>  at
>> org.mozilla.javascript.Context.evaluateString(Context.java:1129)
>>  at
>> org.apache.jmeter.functions.JavaScript.execute(JavaScript.java:94)
>>  at
>> org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:138)
>>  at
>> org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:107)
>>  at
>> org.apache.jmeter.testelement.property.FunctionProperty.getStringValue(FunctionProperty.java:78)
>>  at
>> org.apache.jmeter.testbeans.TestBeanHelper.prepare(TestBeanHelper.java:69)
>>  at
>> org.apache.jmeter.engine.StandardJMeterEngine.notifyTestListenersOfEnd(StandardJMeterEngine.java:248)
>>  at
>> org.apache.jmeter.engine.StandardJMeterEngine$StopTest.run(StandardJMeterEngine.java:326)
>>  at java.lang.Thread.run(Unknown Source)
>>
>> Did I set up my Javascript wrong?
>>
>> Also: if I do this:
>> ${__javaScript((${VARONE}*${VARTWO})/${VARTHREE})} //(Note
>> the extra
>> parenthesis)
>>
>> I will get a similar error at the same place and time (when I go to stop the
>> test):
>> Exception in thread "Thread-77"
>> org.mozilla.javascript.EvaluatorException:
>> missing ) in parenthetical (<cmd>#1)
>>
>> Any help would be greatly appreciated!
>>
>> Thanks!
>>
>> -Michael P.
>>
>>
>>
>>  --
>> Marc Chiarini
>> CompSci PhD Candidate
>> Tufts University
>> Medford, MA 02155
>> http://www.cs.tufts.edu/~mchiar01
>>
>>
>>
>> ---------------------------------------------------------------------
>>  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