Author: pmouawad Date: Wed Jul 18 18:46:32 2018 New Revision: 1836220 URL: http://svn.apache.org/viewvc?rev=1836220&view=rev Log: Bug 62541: Allow __jexl3, __jexl2 function to support new syntax as 'var x;'. Contributed by orimarko Bugzilla Id: 62541
Modified: jmeter/trunk/src/functions/org/apache/jmeter/functions/Jexl2Function.java jmeter/trunk/src/functions/org/apache/jmeter/functions/Jexl3Function.java jmeter/trunk/test/src/org/apache/jmeter/functions/TestJexl2Function.java jmeter/trunk/xdocs/changes.xml Modified: jmeter/trunk/src/functions/org/apache/jmeter/functions/Jexl2Function.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/functions/org/apache/jmeter/functions/Jexl2Function.java?rev=1836220&r1=1836219&r2=1836220&view=diff ============================================================================== --- jmeter/trunk/src/functions/org/apache/jmeter/functions/Jexl2Function.java (original) +++ jmeter/trunk/src/functions/org/apache/jmeter/functions/Jexl2Function.java Wed Jul 18 18:46:32 2018 @@ -20,10 +20,10 @@ import java.util.Collection; import java.util.LinkedList; import java.util.List; -import org.apache.commons.jexl2.Expression; import org.apache.commons.jexl2.JexlContext; import org.apache.commons.jexl2.JexlEngine; import org.apache.commons.jexl2.MapContext; +import org.apache.commons.jexl2.Script; import org.apache.jmeter.engine.util.CompoundVariable; import org.apache.jmeter.samplers.SampleResult; import org.apache.jmeter.samplers.Sampler; @@ -90,8 +90,8 @@ public class Jexl2Function extends Abstr jc.set("OUT", System.out);//$NON-NLS-1$ // Now evaluate the script, getting the result - Expression e = getJexlEngine().createExpression( exp ); - Object o = e.evaluate(jc); + Script e = getJexlEngine().createScript( exp ); + Object o = e.execute(jc); if (o != null) { str = o.toString(); Modified: jmeter/trunk/src/functions/org/apache/jmeter/functions/Jexl3Function.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/functions/org/apache/jmeter/functions/Jexl3Function.java?rev=1836220&r1=1836219&r2=1836220&view=diff ============================================================================== --- jmeter/trunk/src/functions/org/apache/jmeter/functions/Jexl3Function.java (original) +++ jmeter/trunk/src/functions/org/apache/jmeter/functions/Jexl3Function.java Wed Jul 18 18:46:32 2018 @@ -23,7 +23,7 @@ import java.util.List; import org.apache.commons.jexl3.JexlBuilder; import org.apache.commons.jexl3.JexlContext; import org.apache.commons.jexl3.JexlEngine; -import org.apache.commons.jexl3.JexlExpression; +import org.apache.commons.jexl3.JexlScript; import org.apache.commons.jexl3.MapContext; import org.apache.jmeter.engine.util.CompoundVariable; import org.apache.jmeter.samplers.SampleResult; @@ -91,8 +91,8 @@ public class Jexl3Function extends Abstr jc.set("OUT", System.out);//$NON-NLS-1$ // Now evaluate the script, getting the result - JexlExpression e = getJexlEngine().createExpression( exp ); - Object o = e.evaluate(jc); + JexlScript e = getJexlEngine().createScript(exp); + Object o = e.execute(jc); if (o != null) { str = o.toString(); Modified: jmeter/trunk/test/src/org/apache/jmeter/functions/TestJexl2Function.java URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/functions/TestJexl2Function.java?rev=1836220&r1=1836219&r2=1836220&view=diff ============================================================================== --- jmeter/trunk/test/src/org/apache/jmeter/functions/TestJexl2Function.java (original) +++ jmeter/trunk/test/src/org/apache/jmeter/functions/TestJexl2Function.java Wed Jul 18 18:46:32 2018 @@ -98,4 +98,12 @@ public class TestJexl2Function extends J assertEquals("/query.cgi?s1=1&s2=2&s3=3", ret); assertEquals(ret,vars.getObject("URL")); } + + @Test + public void testSumWithVar() throws Exception { + params.add(new CompoundVariable("var a = 1+2+3")); + function.setParameters(params); + String ret = function.execute(result, null); + assertEquals("6", ret); + } } Modified: jmeter/trunk/xdocs/changes.xml URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1836220&r1=1836219&r2=1836220&view=diff ============================================================================== --- jmeter/trunk/xdocs/changes.xml [utf-8] (original) +++ jmeter/trunk/xdocs/changes.xml [utf-8] Wed Jul 18 18:46:32 2018 @@ -124,6 +124,7 @@ this behaviour, set <code>httpclient.res <li><bug>62178</bug>Add default value to <code>__V</code> function. Contributed by orimarko at gmail.com</li> <li><bug>62178</bug>Add function <code>__threadGroupName</code> function to obtain ThreadGroup name. Mainly contributed by orimarko at gmail.com</li> <li><bug>62533</bug>Allow use epoch time as Date String value in function <code>__dateTimeConvert</code> </li> + <li><bug>62541</bug>Allow <code>__jexl3</code>,<code>__jexl2</code> functions to support new syntax as <code>var x;</code>. Contributed by orimarko at gmail.com</li> </ul> <h3>I18N</h3> <ul>