net.sf.jbenchmark.sql
Class StoredProcedureTest

java.lang.Object
  extended bynet.sf.jbenchmark.TestFeature
      extended bynet.sf.jbenchmark.Test
          extended bynet.sf.jbenchmark.sql.AbstractSQLCallTest
              extended bynet.sf.jbenchmark.sql.StoredProcedureTest
All Implemented Interfaces:
java.lang.Runnable

public class StoredProcedureTest
extends AbstractSQLCallTest

Encapsulates a single test that executes a stored procedure. A benchmark test for a stored procedure can operate in two different modes or types. These are:

A stored procedure may have a list of arguments which should be added and should be wrapped around a test group such as a loop. At the moment, out parameters are ignored. Future Enhancements: Expand this to support named parameters, not just ordered arguments for now.

Version:
$Id: StoredProcedureTest.java,v 1.5 2004/07/02 02:40:23 twpatkua Exp $
Author:
Patrick Kua

Field Summary
static java.lang.String MODIFY_TYPE
          Indicates that the stored procedure will modify something in the database.
static java.lang.String QUERY_TYPE
          Indicates that the stored procedure will only query from the DB and does not require a clean up script.
 
Fields inherited from class net.sf.jbenchmark.sql.AbstractSQLCallTest
connection, LOG, sqlArguments
 
Constructor Summary
StoredProcedureTest()
           
 
Method Summary
protected  void doCleanup()
          Run the clean up script if this is a modify type of stored procedure.
protected  void doValidate()
          Validate that the name of the stored procedure is not empty.
 java.lang.String getCleanupScript()
          Script for restoring the db to a clean state.
 java.lang.String getName()
          Name of the stored procedure.
protected  java.sql.PreparedStatement getPreparedStatement()
          Return the stored procedure SQL statement as a prepared statement.
 java.lang.String getType()
          Type of the stored procedure.
static void registerBenchmarkTest(org.apache.commons.digester.Digester digester)
          Register this benchmark test with the digester.
protected  void runCleanupScript()
          The clean up script is executed at the end.
 void setCleanupScript(java.lang.String cleanupScript)
          Script for restoring the db to a clean state.
 void setName(java.lang.String name)
          Name of the stored procedure.
 void setType(java.lang.String type)
          Type of the stored procedure.
 
Methods inherited from class net.sf.jbenchmark.sql.AbstractSQLCallTest
addSqlCallArgument, doInitialise, doRun, executeResult, getSqlArguments, setSqlArguments
 
Methods inherited from class net.sf.jbenchmark.Test
addAssertion, addFeature, addResource, finish, getFeatureContext, getResource, run, setContext
 
Methods inherited from class net.sf.jbenchmark.TestFeature
getContext, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MODIFY_TYPE

public static final java.lang.String MODIFY_TYPE
Indicates that the stored procedure will modify something in the database. A clean up script must be specified.

See Also:
Constant Field Values

QUERY_TYPE

public static final java.lang.String QUERY_TYPE
Indicates that the stored procedure will only query from the DB and does not require a clean up script.

See Also:
Constant Field Values
Constructor Detail

StoredProcedureTest

public StoredProcedureTest()
Method Detail

getType

public java.lang.String getType()
Type of the stored procedure.


setType

public void setType(java.lang.String type)
Type of the stored procedure.


getCleanupScript

public java.lang.String getCleanupScript()
Script for restoring the db to a clean state.


setCleanupScript

public void setCleanupScript(java.lang.String cleanupScript)
Script for restoring the db to a clean state.


doValidate

protected void doValidate()
Validate that the name of the stored procedure is not empty.

Specified by:
doValidate in class AbstractSQLCallTest

doCleanup

protected void doCleanup()
                  throws java.lang.Exception
Run the clean up script if this is a modify type of stored procedure.

Overrides:
doCleanup in class AbstractSQLCallTest
Throws:
java.lang.Exception

runCleanupScript

protected void runCleanupScript()
                         throws java.lang.Exception
The clean up script is executed at the end. Each of the statements should be separated either by a new line character or a semi colon. Each of these will be executed separately and then a commit will be called on the connection.

Throws:
java.lang.Exception

getPreparedStatement

protected java.sql.PreparedStatement getPreparedStatement()
                                                   throws java.sql.SQLException
Return the stored procedure SQL statement as a prepared statement.

Specified by:
getPreparedStatement in class AbstractSQLCallTest
Throws:
java.sql.SQLException

getName

public java.lang.String getName()
Name of the stored procedure.

Overrides:
getName in class TestFeature

setName

public void setName(java.lang.String name)
Name of the stored procedure.

Overrides:
setName in class TestFeature

registerBenchmarkTest

public static final void registerBenchmarkTest(org.apache.commons.digester.Digester digester)
Register this benchmark test with the digester. TODO: Make this autoomatically handle. Perhaps a Registerable Benchmark interface.