jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1645746 - in /jmeter/trunk: src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/ src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/processor/ src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/sampler/ xdocs/ xdocs/usermanual/
Date Mon, 15 Dec 2014 20:47:22 GMT
Author: pmouawad
Date: Mon Dec 15 20:47:22 2014
New Revision: 1645746

URL: http://svn.apache.org/r1645746
Log:
Bug 57322 - JDBC: add methods to deal with ResultSets(cursors) returned by callable statements
Bugzilla Id: 57322

Modified:
    jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java
    jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/JDBCTestElementBeanInfoSupport.java
    jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/processor/JDBCPostProcessorResources.properties
    jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/processor/JDBCPreProcessorResources.properties
    jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/sampler/JDBCSamplerResources.properties
    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=1645746&r1=1645745&r2=1645746&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
Mon Dec 15 20:47:22 2014
@@ -108,6 +108,10 @@ public abstract class AbstractJDBCTestEl
     static final String AUTOCOMMIT_FALSE = "AutoCommit(false)"; // $NON-NLS-1$
     static final String AUTOCOMMIT_TRUE  = "AutoCommit(true)"; // $NON-NLS-1$
 
+    static final String RS_STORE_AS_STRING = "Store as String"; // $NON-NLS-1$
+    static final String RS_STORE_AS_OBJECT = "Store as Object"; // $NON-NLS-1$
+    static final String RS_COUNT_RECORDS = "Count Records"; // $NON-NLS-1$
+
     private String query = ""; // $NON-NLS-1$
 
     private String dataSource = ""; // $NON-NLS-1$
@@ -116,6 +120,7 @@ public abstract class AbstractJDBCTestEl
     private String queryArguments = ""; // $NON-NLS-1$
     private String queryArgumentsTypes = ""; // $NON-NLS-1$
     private String variableNames = ""; // $NON-NLS-1$
+    private String resultSetHandler = RS_STORE_AS_STRING; 
     private String resultVariable = ""; // $NON-NLS-1$
     private String queryTimeout = ""; // $NON-NLS-1$
 
@@ -242,6 +247,9 @@ public abstract class AbstractJDBCTestEl
                     sb.append(i+1);
                     sb.append("] ");
                     sb.append(o);
+                    if( o instanceof java.sql.ResultSet && RS_COUNT_RECORDS.equals(resultSetHandler))
{
+                        sb.append(" ").append(countRows((ResultSet) o)).append(" rows");
+                    }
                     sb.append("\n");
                 }
             }
@@ -252,14 +260,37 @@ public abstract class AbstractJDBCTestEl
                     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());
+                        if( o instanceof java.sql.ResultSet ) { 
+                            ResultSet resultSet = (ResultSet) o;
+                            if(RS_STORE_AS_OBJECT.equals(resultSetHandler)) {
+                                jmvars.putObject(name, o);
+                            }
+                            else if( RS_COUNT_RECORDS.equals(resultSetHandler)) {
+                                jmvars.put(name,o.toString()+" "+countRows(resultSet)+" rows");
+                            }
+                            else {
+                                jmvars.put(name, o.toString());
+                            }
+                        }
+                        else {
+                            jmvars.put(name, o == null ? null : o.toString());
+                        }
                     }
                 }
             }
         }
         return sb.toString();
     }
-
+    
+    /**
+     * Count rows in result set
+     * @param resultSet {@link ResultSet}
+     * @return number of rows in resultSet
+     * @throws SQLException
+     */
+    private static final int countRows(ResultSet resultSet) throws SQLException {
+        return resultSet.last() ? resultSet.getRow() : 0;
+    }
 
     private int[] setArguments(PreparedStatement pstmt) throws SQLException, IOException
{
         if (getQueryArguments().trim().length()==0) {
@@ -596,6 +627,20 @@ public abstract class AbstractJDBCTestEl
     }
 
     /**
+     * @return the resultSetHandler
+     */
+    public String getResultSetHandler() {
+        return resultSetHandler;
+    }
+
+    /**
+     * @param resultSetHandler the resultSetHandler to set
+     */
+    public void setResultSetHandler(String resultSetHandler) {
+        this.resultSetHandler = resultSetHandler;
+    }
+
+    /**
      * @return the resultVariable
      */
     public String getResultVariable() {

Modified: jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/JDBCTestElementBeanInfoSupport.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/JDBCTestElementBeanInfoSupport.java?rev=1645746&r1=1645745&r2=1645746&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/JDBCTestElementBeanInfoSupport.java
(original)
+++ jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/JDBCTestElementBeanInfoSupport.java
Mon Dec 15 20:47:22 2014
@@ -43,7 +43,8 @@ public abstract class JDBCTestElementBea
                 "queryArgumentsTypes", // $NON-NLS-1$
                 "variableNames", // $NON-NLS-1$
                 "resultVariable", // $NON-NLS-1$
-                "queryTimeout" // $NON-NLS-1$
+                "queryTimeout", // $NON-NLS-1$
+                "resultSetHandler" // $NON-NLS-1$
                 });
 
         PropertyDescriptor p = property("dataSource"); // $NON-NLS-1$
@@ -62,6 +63,16 @@ public abstract class JDBCTestElementBea
         p.setValue(NOT_UNDEFINED, Boolean.TRUE);
         p.setValue(DEFAULT, ""); // $NON-NLS-1$
 
+        p = property("resultSetHandler"); // $NON-NLS-1$
+        p.setValue(NOT_UNDEFINED, Boolean.TRUE);
+        p.setValue(DEFAULT, AbstractJDBCTestElement.RS_STORE_AS_STRING);
+        p.setValue(NOT_OTHER, Boolean.TRUE);
+        p.setValue(TAGS,new String[]{
+                AbstractJDBCTestElement.RS_STORE_AS_STRING,
+                AbstractJDBCTestElement.RS_STORE_AS_OBJECT,
+                AbstractJDBCTestElement.RS_COUNT_RECORDS
+                });       
+
         p = property("resultVariable"); // $NON-NLS-1$
         p.setValue(NOT_UNDEFINED, Boolean.TRUE);
         p.setValue(DEFAULT, ""); // $NON-NLS-1$

Modified: jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/processor/JDBCPostProcessorResources.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/processor/JDBCPostProcessorResources.properties?rev=1645746&r1=1645745&r2=1645746&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/processor/JDBCPostProcessorResources.properties
(original)
+++ jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/processor/JDBCPostProcessorResources.properties
Mon Dec 15 20:47:22 2014
@@ -28,6 +28,8 @@ queryArgumentsTypes.displayName=Paramete
 queryArgumentsTypes.shortDescription=JDBC Type names from java.sql.Types. VARCHAR, INTEGER,
etc. (comma separated)
 variableNames.displayName=Variable names
 variableNames.shortDescription=Output variable names for each column  (comma separated)
+resultSetHandler.displayName=Handle ResultSet
+resultSetHandler.shortDescription=How should return values of type ResultSet be handled
 resultVariable.displayName=Result variable name
 resultVariable.shortDescription=Name of the JMeter variable that stores the result set objects
in a list of maps for looking up results by column name.
 queryTimeout.displayName=Query timeout

Modified: jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/processor/JDBCPreProcessorResources.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/processor/JDBCPreProcessorResources.properties?rev=1645746&r1=1645745&r2=1645746&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/processor/JDBCPreProcessorResources.properties
(original)
+++ jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/processor/JDBCPreProcessorResources.properties
Mon Dec 15 20:47:22 2014
@@ -28,6 +28,8 @@ queryArgumentsTypes.displayName=Paramete
 queryArgumentsTypes.shortDescription=JDBC Type names from java.sql.Types. VARCHAR, INTEGER,
etc. (comma separated)
 variableNames.displayName=Variable names
 variableNames.shortDescription=Output variable names for each column  (comma separated)
+resultSetHandler.displayName=Handle ResultSet
+resultSetHandler.shortDescription=How should return values of type ResultSet be handled
 resultVariable.displayName=Result variable name
 resultVariable.shortDescription=Name of the JMeter variable that stores the result set objects
in a list of maps for looking up results by column name.
 queryTimeout.displayName=Query timeout

Modified: jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/sampler/JDBCSamplerResources.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/sampler/JDBCSamplerResources.properties?rev=1645746&r1=1645745&r2=1645746&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/sampler/JDBCSamplerResources.properties
(original)
+++ jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/sampler/JDBCSamplerResources.properties
Mon Dec 15 20:47:22 2014
@@ -28,6 +28,8 @@ queryArgumentsTypes.displayName=Paramete
 queryArgumentsTypes.shortDescription=JDBC Type names from java.sql.Types. VARCHAR, INTEGER,
etc. (comma separated)
 variableNames.displayName=Variable names
 variableNames.shortDescription=Output variable names for each column  (comma separated)
+resultSetHandler.displayName=Handle ResultSet
+resultSetHandler.shortDescription=How should return values of type ResultSet be handled
 resultVariable.displayName=Result variable name
 resultVariable.shortDescription=Name of the JMeter variable that stores the result set objects
in a list of maps for looking up results by column name.
 queryTimeout.displayName=Query timeout (s)

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1645746&r1=1645745&r2=1645746&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Mon Dec 15 20:47:22 2014
@@ -186,6 +186,7 @@ See  <bugzilla>56357</bugzilla> for deta
 
 <h3>Other samplers</h3>
 <ul>
+    <li><bug>57322</bug>JDBC Test elements: add ResultHandler to deal with
ResultSets(cursors) returned by callable statements</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=1645746&r1=1645745&r2=1645746&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jmeter/trunk/xdocs/usermanual/component_reference.xml Mon Dec 15 20:47:22 2014
@@ -589,6 +589,13 @@ the additional variables for rows 4, 5 a
         Each map contains the column name as the key and the column data as the value. Usage:<br></br>
         <code>columnValue = vars.getObject("resultObject").get(0).get("Column Name");</code>
         </property>
+        <property name="Handle ResultSet" required="No">Defines how ResultSet returned
from callable statements be handled:
+            <ul>
+                <li>Store As String (default) - All variables on Variable Names list
are stored as strings, will not iterate through a ResultSets when present on the list.</li>
+                <li>Store As Object - Variables of ResultSet type on Variables Names
list will be stored as Object and can be accessed in subsequent tests/scripts and iterated,
will not iterate through the ResultSet </li>
+                <li>Count Records - Variables of ResultSet types will be iterated through
showing the count of records as result. Variables will be stored as Strings.</li>
+            </ul>
+        </property>
 </properties>
 
 <links>



Mime
View raw message