You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by Danny Lade <D....@bigpoint.net> on 2013/07/01 14:18:32 UTC

It seems that javaScript functions with more than one parameter does not work

When I'm trying to use a javaScript function with more than one parameter (e.g. ${__javaScript(Math.max(2,5))} or with variables ${__javaScript(Math.max(${x},${y}))}), then I get always an exception like:

2013/07/01 12:47:32 ERROR - jmeter.functions.JavaScript: Error processing Javascript: [Math.max(2]
 org.mozilla.javascript.EvaluatorException: missing ) after argument list (<cmd>#1)
	at org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:77)
	at org.mozilla.javascript.DefaultErrorReporter.error(DefaultErrorReporter.java:64)
	at org.mozilla.javascript.Parser.addError(Parser.java:188)
	at org.mozilla.javascript.Parser.addError(Parser.java:166)
	at org.mozilla.javascript.Parser.reportError(Parser.java:223)
	at org.mozilla.javascript.Parser.reportError(Parser.java:217)
	at org.mozilla.javascript.Parser.mustMatchToken(Parser.java:388)
	at org.mozilla.javascript.Parser.mustMatchToken(Parser.java:378)
	at org.mozilla.javascript.Parser.argumentList(Parser.java:2390)
	at org.mozilla.javascript.Parser.memberExprTail(Parser.java:2523)
	at org.mozilla.javascript.Parser.memberExpr(Parser.java:2442)
	at org.mozilla.javascript.Parser.unaryExpr(Parser.java:2304)
	at org.mozilla.javascript.Parser.mulExpr(Parser.java:2229)
	at org.mozilla.javascript.Parser.addExpr(Parser.java:2213)
	at org.mozilla.javascript.Parser.shiftExpr(Parser.java:2194)
	at org.mozilla.javascript.Parser.relExpr(Parser.java:2169)
	at org.mozilla.javascript.Parser.eqExpr(Parser.java:2141)
	at org.mozilla.javascript.Parser.bitAndExpr(Parser.java:2130)
	at org.mozilla.javascript.Parser.bitXorExpr(Parser.java:2119)
	at org.mozilla.javascript.Parser.bitOrExpr(Parser.java:2108)
	at org.mozilla.javascript.Parser.andExpr(Parser.java:2097)
	at org.mozilla.javascript.Parser.orExpr(Parser.java:2086)
	at org.mozilla.javascript.Parser.condExpr(Parser.java:2062)
	at org.mozilla.javascript.Parser.assignExpr(Parser.java:2033)
	at org.mozilla.javascript.Parser.expr(Parser.java:2012)
	at org.mozilla.javascript.Parser.nameOrLabel(Parser.java:1765)
	at org.mozilla.javascript.Parser.statementHelper(Parser.java:1032)
	at org.mozilla.javascript.Parser.statement(Parser.java:901)
	at org.mozilla.javascript.Parser.parse(Parser.java:540)
	at org.mozilla.javascript.Parser.parse(Parser.java:478)
	at org.mozilla.javascript.Context.compileImpl(Context.java:2348)
	at org.mozilla.javascript.Context.compileString(Context.java:1335)
	at org.mozilla.javascript.Context.compileString(Context.java:1324)
	at org.mozilla.javascript.Context.evaluateString(Context.java:1076)
	at org.apache.jmeter.functions.JavaScript.execute(JavaScript.java:88)
	at org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:146)
	at org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:120)
	at org.apache.jmeter.testelement.property.FunctionProperty.getStringValue(FunctionProperty.java:92)
	at org.apache.jmeter.testelement.AbstractTestElement.getPropertyAsString(AbstractTestElement.java:273)
	at org.apache.jmeter.config.Argument.getValue(Argument.java:140)
	at org.apache.jmeter.config.Arguments.getArgumentsAsMap(Arguments.java:93)
	at org.apache.jmeter.engine.PreCompiler.addNode(PreCompiler.java:94)
	at org.apache.jorphan.collections.HashTree.traverseInto(HashTree.java:1001)
	at org.apache.jorphan.collections.HashTree.traverseInto(HashTree.java:1002)
	at org.apache.jorphan.collections.HashTree.traverse(HashTree.java:986)
	at org.apache.jmeter.engine.StandardJMeterEngine.run(StandardJMeterEngine.java:305)
	at java.lang.Thread.run(Unknown Source)

VG Danny


Re: It seems that javaScript functions with more than one parameter does not work

Posted by sebb <se...@gmail.com>.
On 1 July 2013 13:56, Danny Lade <D....@bigpoint.net> wrote:
> I tried hundred different variations and found out, that it works if the comma is escaped by \ (e.g. ${__javaScript(Math.max(${x}\,${y}\,${z}))})
> Yet, don't understand why or maybe missed something in some JMeter documentation ...

http://jmeter.apache.org/usermanual/functions.html

Para starting: "If a function parameter contains a comma, "

> Still confused,
> Danny
>
>> -----Ursprüngliche Nachricht-----
>> Von: Danny Lade [mailto:D.Lade@bigpoint.net]
>> Gesendet: Montag, 1. Juli 2013 14:19
>> An: dev@jmeter.apache.org
>> Betreff: It seems that javaScript functions with more than one parameter does
>> not work
>>
>> When I'm trying to use a javaScript function with more than one parameter (e.g.
>> ${__javaScript(Math.max(2,5))} or with variables
>> ${__javaScript(Math.max(${x},${y}))}), then I get always an exception like:
>>
>> 2013/07/01 12:47:32 ERROR - jmeter.functions.JavaScript: Error processing
>> Javascript: [Math.max(2]
>>  org.mozilla.javascript.EvaluatorException: missing ) after argument list
>> (<cmd>#1)
>>       at
>> org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.j
>> ava:77)
>>       at
>> org.mozilla.javascript.DefaultErrorReporter.error(DefaultErrorReporter.java:64)
>>       at org.mozilla.javascript.Parser.addError(Parser.java:188)
>>       at org.mozilla.javascript.Parser.addError(Parser.java:166)
>>       at org.mozilla.javascript.Parser.reportError(Parser.java:223)
>>       at org.mozilla.javascript.Parser.reportError(Parser.java:217)
>>       at org.mozilla.javascript.Parser.mustMatchToken(Parser.java:388)
>>       at org.mozilla.javascript.Parser.mustMatchToken(Parser.java:378)
>>       at org.mozilla.javascript.Parser.argumentList(Parser.java:2390)
>>       at org.mozilla.javascript.Parser.memberExprTail(Parser.java:2523)
>>       at org.mozilla.javascript.Parser.memberExpr(Parser.java:2442)
>>       at org.mozilla.javascript.Parser.unaryExpr(Parser.java:2304)
>>       at org.mozilla.javascript.Parser.mulExpr(Parser.java:2229)
>>       at org.mozilla.javascript.Parser.addExpr(Parser.java:2213)
>>       at org.mozilla.javascript.Parser.shiftExpr(Parser.java:2194)
>>       at org.mozilla.javascript.Parser.relExpr(Parser.java:2169)
>>       at org.mozilla.javascript.Parser.eqExpr(Parser.java:2141)
>>       at org.mozilla.javascript.Parser.bitAndExpr(Parser.java:2130)
>>       at org.mozilla.javascript.Parser.bitXorExpr(Parser.java:2119)
>>       at org.mozilla.javascript.Parser.bitOrExpr(Parser.java:2108)
>>       at org.mozilla.javascript.Parser.andExpr(Parser.java:2097)
>>       at org.mozilla.javascript.Parser.orExpr(Parser.java:2086)
>>       at org.mozilla.javascript.Parser.condExpr(Parser.java:2062)
>>       at org.mozilla.javascript.Parser.assignExpr(Parser.java:2033)
>>       at org.mozilla.javascript.Parser.expr(Parser.java:2012)
>>       at org.mozilla.javascript.Parser.nameOrLabel(Parser.java:1765)
>>       at org.mozilla.javascript.Parser.statementHelper(Parser.java:1032)
>>       at org.mozilla.javascript.Parser.statement(Parser.java:901)
>>       at org.mozilla.javascript.Parser.parse(Parser.java:540)
>>       at org.mozilla.javascript.Parser.parse(Parser.java:478)
>>       at org.mozilla.javascript.Context.compileImpl(Context.java:2348)
>>       at org.mozilla.javascript.Context.compileString(Context.java:1335)
>>       at org.mozilla.javascript.Context.compileString(Context.java:1324)
>>       at org.mozilla.javascript.Context.evaluateString(Context.java:1076)
>>       at org.apache.jmeter.functions.JavaScript.execute(JavaScript.java:88)
>>       at
>> org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.j
>> ava:146)
>>       at
>> org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.j
>> ava:120)
>>       at
>> org.apache.jmeter.testelement.property.FunctionProperty.getStringValue(Funct
>> ionProperty.java:92)
>>       at
>> org.apache.jmeter.testelement.AbstractTestElement.getPropertyAsString(Abstr
>> actTestElement.java:273)
>>       at org.apache.jmeter.config.Argument.getValue(Argument.java:140)
>>       at
>> org.apache.jmeter.config.Arguments.getArgumentsAsMap(Arguments.java:93)
>>       at
>> org.apache.jmeter.engine.PreCompiler.addNode(PreCompiler.java:94)
>>       at
>> org.apache.jorphan.collections.HashTree.traverseInto(HashTree.java:1001)
>>       at
>> org.apache.jorphan.collections.HashTree.traverseInto(HashTree.java:1002)
>>       at
>> org.apache.jorphan.collections.HashTree.traverse(HashTree.java:986)
>>       at
>> org.apache.jmeter.engine.StandardJMeterEngine.run(StandardJMeterEngine.jav
>> a:305)
>>       at java.lang.Thread.run(Unknown Source)
>>
>> VG Danny
>

AW: It seems that javaScript functions with more than one parameter does not work

Posted by Danny Lade <D....@bigpoint.net>.
I tried hundred different variations and found out, that it works if the comma is escaped by \ (e.g. ${__javaScript(Math.max(${x}\,${y}\,${z}))})
Yet, don't understand why or maybe missed something in some JMeter documentation ...

Still confused, 
Danny

> -----Ursprüngliche Nachricht-----
> Von: Danny Lade [mailto:D.Lade@bigpoint.net]
> Gesendet: Montag, 1. Juli 2013 14:19
> An: dev@jmeter.apache.org
> Betreff: It seems that javaScript functions with more than one parameter does
> not work
> 
> When I'm trying to use a javaScript function with more than one parameter (e.g.
> ${__javaScript(Math.max(2,5))} or with variables
> ${__javaScript(Math.max(${x},${y}))}), then I get always an exception like:
> 
> 2013/07/01 12:47:32 ERROR - jmeter.functions.JavaScript: Error processing
> Javascript: [Math.max(2]
>  org.mozilla.javascript.EvaluatorException: missing ) after argument list
> (<cmd>#1)
> 	at
> org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.j
> ava:77)
> 	at
> org.mozilla.javascript.DefaultErrorReporter.error(DefaultErrorReporter.java:64)
> 	at org.mozilla.javascript.Parser.addError(Parser.java:188)
> 	at org.mozilla.javascript.Parser.addError(Parser.java:166)
> 	at org.mozilla.javascript.Parser.reportError(Parser.java:223)
> 	at org.mozilla.javascript.Parser.reportError(Parser.java:217)
> 	at org.mozilla.javascript.Parser.mustMatchToken(Parser.java:388)
> 	at org.mozilla.javascript.Parser.mustMatchToken(Parser.java:378)
> 	at org.mozilla.javascript.Parser.argumentList(Parser.java:2390)
> 	at org.mozilla.javascript.Parser.memberExprTail(Parser.java:2523)
> 	at org.mozilla.javascript.Parser.memberExpr(Parser.java:2442)
> 	at org.mozilla.javascript.Parser.unaryExpr(Parser.java:2304)
> 	at org.mozilla.javascript.Parser.mulExpr(Parser.java:2229)
> 	at org.mozilla.javascript.Parser.addExpr(Parser.java:2213)
> 	at org.mozilla.javascript.Parser.shiftExpr(Parser.java:2194)
> 	at org.mozilla.javascript.Parser.relExpr(Parser.java:2169)
> 	at org.mozilla.javascript.Parser.eqExpr(Parser.java:2141)
> 	at org.mozilla.javascript.Parser.bitAndExpr(Parser.java:2130)
> 	at org.mozilla.javascript.Parser.bitXorExpr(Parser.java:2119)
> 	at org.mozilla.javascript.Parser.bitOrExpr(Parser.java:2108)
> 	at org.mozilla.javascript.Parser.andExpr(Parser.java:2097)
> 	at org.mozilla.javascript.Parser.orExpr(Parser.java:2086)
> 	at org.mozilla.javascript.Parser.condExpr(Parser.java:2062)
> 	at org.mozilla.javascript.Parser.assignExpr(Parser.java:2033)
> 	at org.mozilla.javascript.Parser.expr(Parser.java:2012)
> 	at org.mozilla.javascript.Parser.nameOrLabel(Parser.java:1765)
> 	at org.mozilla.javascript.Parser.statementHelper(Parser.java:1032)
> 	at org.mozilla.javascript.Parser.statement(Parser.java:901)
> 	at org.mozilla.javascript.Parser.parse(Parser.java:540)
> 	at org.mozilla.javascript.Parser.parse(Parser.java:478)
> 	at org.mozilla.javascript.Context.compileImpl(Context.java:2348)
> 	at org.mozilla.javascript.Context.compileString(Context.java:1335)
> 	at org.mozilla.javascript.Context.compileString(Context.java:1324)
> 	at org.mozilla.javascript.Context.evaluateString(Context.java:1076)
> 	at org.apache.jmeter.functions.JavaScript.execute(JavaScript.java:88)
> 	at
> org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.j
> ava:146)
> 	at
> org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.j
> ava:120)
> 	at
> org.apache.jmeter.testelement.property.FunctionProperty.getStringValue(Funct
> ionProperty.java:92)
> 	at
> org.apache.jmeter.testelement.AbstractTestElement.getPropertyAsString(Abstr
> actTestElement.java:273)
> 	at org.apache.jmeter.config.Argument.getValue(Argument.java:140)
> 	at
> org.apache.jmeter.config.Arguments.getArgumentsAsMap(Arguments.java:93)
> 	at
> org.apache.jmeter.engine.PreCompiler.addNode(PreCompiler.java:94)
> 	at
> org.apache.jorphan.collections.HashTree.traverseInto(HashTree.java:1001)
> 	at
> org.apache.jorphan.collections.HashTree.traverseInto(HashTree.java:1002)
> 	at
> org.apache.jorphan.collections.HashTree.traverse(HashTree.java:986)
> 	at
> org.apache.jmeter.engine.StandardJMeterEngine.run(StandardJMeterEngine.jav
> a:305)
> 	at java.lang.Thread.run(Unknown Source)
> 
> VG Danny