You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2012/04/24 13:35:35 UTC

svn commit: r1329645 - in /jmeter/trunk: src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java xdocs/changes.xml xdocs/usermanual/component_reference.xml

Author: pmouawad
Date: Tue Apr 24 11:35:34 2012
New Revision: 1329645

URL: http://svn.apache.org/viewvc?rev=1329645&view=rev
Log:
Bug 53073 - Allow to assign the OUT result of a JDBC CALLABLE to JMeter variables 

Modified:
    jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java
    jmeter/trunk/xdocs/changes.xml
    jmeter/trunk/xdocs/usermanual/component_reference.xml

Modified: jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java?rev=1329645&r1=1329644&r2=1329645&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java (original)
+++ jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java Tue Apr 24 11:35:34 2012
@@ -245,17 +245,31 @@ public abstract class AbstractJDBCTestEl
             }
         } while (result || (updateCount != -1));
         if (out!=null && pstmt instanceof CallableStatement){
+            ArrayList<Object> outputValues = new ArrayList<Object>();
             CallableStatement cs = (CallableStatement) pstmt;
             sb.append("Output variables by position:\n");
             for(int i=0; i < out.length; i++){
                 if (out[i]!=java.sql.Types.NULL){
+                    Object o = cs.getObject(i+1);
+                    outputValues.add(o);
                     sb.append("[");
                     sb.append(i+1);
                     sb.append("] ");
-                    sb.append(cs.getObject(i+1));
+                    sb.append(o);
                     sb.append("\n");
                 }
             }
+            String varnames[] = getVariableNames().split(COMMA);
+            if(varnames.length > 0) {
+        	JMeterVariables jmvars = getThreadContext().getVariables();
+                for(int i = 0; i < varnames.length && i < outputValues.size(); i++) {
+                    String name = varnames[i].trim();
+                    if (name.length()>0){ // Save the value in the variable if present
+                        Object o = outputValues.get(i);
+                        jmvars.put(name, o == null ? null : o.toString());
+                    }
+                }
+            }
         }
         return sb.toString();
     }

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1329645&r1=1329644&r2=1329645&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Tue Apr 24 11:35:34 2012
@@ -166,6 +166,7 @@ Graph Full Results Listener has been rem
 <li>Bug 52810 - Enable setting JMS Properties through JMS Publisher sampler</li>
 <li>Bug 52938 - Webservice Sampler : Add a jmeter property soap.document_cache to control size of Document Cache</li>
 <li>Bug 52939 - Webservice Sampler : Make MaintainSession configurable</li>
+<li>Bug 53073 - Allow to assign the OUT result of a JDBC CALLABLE to JMeter variables</li>
 </ul>
 
 <h3>Controllers</h3>

Modified: jmeter/trunk/xdocs/usermanual/component_reference.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=1329645&r1=1329644&r2=1329645&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jmeter/trunk/xdocs/usermanual/component_reference.xml Tue Apr 24 11:35:34 2012
@@ -523,7 +523,10 @@ the additional variables for rows 4, 5 a
         <br></br>
         There must be as many types as there are placeholders in the statement.
         </property>
-        <property name="Variable Names" required="No">Comma-separated list of variable names to hold values returned by Select statements or Prepared Select Statements</property>
+        <property name="Variable Names" required="No">Comma-separated list of variable names to hold values returned by Select statements, Prepared Select Statements or CallableStatement. 
+        Note that when used with CallableStatement, list of variables must be in the same sequence as the OUT parameters returned by the call.
+        If there are less variable names than OUT parameters only as many results shall be stored in the thread-context variables as variable names were supplied. 
+        If more variable names than OUT parameters exist, the additional variables will be ignored</property>
         <property name="Result Variable Name" required="No">
         If specified, this will create an Object variable containing a list of row maps.
         Each map contains the column name as the key and the column data as the value. Usage:<br></br>