You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by se...@apache.org on 2008/11/03 13:42:17 UTC

svn commit: r710045 - in /jakarta/jmeter/trunk: src/functions/org/apache/jmeter/functions/JexlFunction.java xdocs/changes.xml xdocs/usermanual/functions.xml

Author: sebb
Date: Mon Nov  3 04:42:16 2008
New Revision: 710045

URL: http://svn.apache.org/viewvc?rev=710045&view=rev
Log:
Allow jexl() function to have multiple statements

Modified:
    jakarta/jmeter/trunk/src/functions/org/apache/jmeter/functions/JexlFunction.java
    jakarta/jmeter/trunk/xdocs/changes.xml
    jakarta/jmeter/trunk/xdocs/usermanual/functions.xml

Modified: jakarta/jmeter/trunk/src/functions/org/apache/jmeter/functions/JexlFunction.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/functions/org/apache/jmeter/functions/JexlFunction.java?rev=710045&r1=710044&r2=710045&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/functions/org/apache/jmeter/functions/JexlFunction.java (original)
+++ jakarta/jmeter/trunk/src/functions/org/apache/jmeter/functions/JexlFunction.java Mon Nov  3 04:42:16 2008
@@ -21,10 +21,10 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.commons.jexl.Expression;
-import org.apache.commons.jexl.ExpressionFactory;
 import org.apache.commons.jexl.JexlContext;
 import org.apache.commons.jexl.JexlHelper;
+import org.apache.commons.jexl.Script;
+import org.apache.commons.jexl.ScriptFactory;
 import org.apache.jmeter.engine.util.CompoundVariable;
 import org.apache.jmeter.samplers.SampleResult;
 import org.apache.jmeter.samplers.Sampler;
@@ -73,7 +73,7 @@
 
         try
         {
-            Expression e = ExpressionFactory.createExpression(exp);
+            Script script = ScriptFactory.createScript(exp);
             JexlContext jc = JexlHelper.createContext();
             final Map jexlVars = jc.getVars();
             jexlVars.put("ctx", jmctx); //$NON-NLS-1$
@@ -84,8 +84,8 @@
             jexlVars.put("sampleResult", previousResult); //$NON-NLS-1$ (may be null)
             jexlVars.put("OUT", System.out);//$NON-NLS-1$
 
-            // Now evaluate the expression, getting the result
-            Object o = e.evaluate(jc);
+            // Now evaluate the script, getting the result
+            Object o = script.execute(jc);
             if (o != null)
             {
                 str = o.toString();

Modified: jakarta/jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=710045&r1=710044&r2=710045&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/changes.xml (original)
+++ jakarta/jmeter/trunk/xdocs/changes.xml Mon Nov  3 04:42:16 2008
@@ -162,6 +162,7 @@
 <li>Trim spaces from While Controller condition before comparing against LAST, blank or false</li>
 <li>Add classname field to TCP Sampler GUIs</li>
 <li>Apache SOAP 2.3.1 does not give access to HTTP response code/message, so WebService sampler now treats an empty response as an error</li>
+<li>Use Script to evaluate __jexl() function so can have multiple statements.</li>
 </ul>
 
 <h3>Non-functional changes</h3>

Modified: jakarta/jmeter/trunk/xdocs/usermanual/functions.xml
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/usermanual/functions.xml?rev=710045&r1=710044&r2=710045&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/usermanual/functions.xml (original)
+++ jakarta/jmeter/trunk/xdocs/usermanual/functions.xml Mon Nov  3 04:42:16 2008
@@ -904,7 +904,17 @@
     Systemclass=log.class.forName("java.lang.System");<br></br>
     now=Systemclass.currentTimeMillis();
     </code>
+    Note that the Jexl documentation on the web-site wrongly suggests that "div" does integer division.
+    In fact "div" and "/" both perform normal division. One can get the same effect
+    as follows:
+    <code>
+    i= 5 / 2;
+    i.intValue(); // or use i.longValue()
+    </code>
     </p>
+    <note>Versions of JMeter after 2.3.2 allow the expression to contain multiple statements.
+    JMeter 2.3.2 and earlier only processed the first statement (if there were multiple statements a warning was logged).
+    </note>
 </component>
 
 <component index="&sect-num;.5.19" name="__V">



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