| java.lang.Object com.mockrunner.jdbc.AbstractResultSetHandler
All known Subclasses: com.mockrunner.jdbc.StatementResultSetHandler, com.mockrunner.jdbc.AbstractParameterResultSetHandler,
AbstractResultSetHandler | abstract public class AbstractResultSetHandler (Code) | | Abstract base class for all ResultSet handlers.
Used to coordinate ResultSet objects for a
statement. You can use this class to prepare ResultSet
objects and update count values that are returned by the
execute method of a statement, if the current
SQL string matches.
Furthermore it can be used to create ResultSet objects.
Please note that the ResultSet objects you create and
prepare with this handler are cloned when executing statements.
So you cannot rely on object identity. You have to use the id
of the ResultSet to identify it.
The ResultSet objects returned by
AbstractResultSetHandler.getReturnedResultSets are actually the instances the executed statements returned.
|
Method Summary | |
public void | addExecutedStatement(String sql) Collects all SQL strings that were executed. | public void | addReturnedResultSet(MockResultSet resultSet) Collects all ResultSet objects that were returned by
a Statement , PreparedStatement or
CallableStatement . | public void | addReturnedResultSets(MockResultSet[] resultSets) Collects all ResultSet[] objects that were returned by
a Statement , PreparedStatement or
CallableStatement . | public void | clearGeneratedKeys() Clears the list of statements that return generated keys. | public void | clearGlobalGeneratedKeys() Clears the prepared global generated keys ResultSet . | public void | clearGlobalResultSet() Clears the prepared global ResultSet . | public void | clearGlobalUpdateCount() Clears the prepared global update count. | public void | clearResultSets() Clears all prepared ResultSet objects. | public void | clearReturnsResultSet() Clears the definitions if statements return
ResultSet objects or update counts. | public void | clearThrowsSQLException() Clears the list of statements that should throw an exception. | public void | clearUpdateCounts() Clears all prepared update counts. | public MockResultSet | createResultSet() Creates a new ResultSet with a
random id. | public MockResultSet | createResultSet(String id) Creates a new ResultSet with the specified id. | public MockResultSet | createResultSet(ResultSetFactory factory) Returns a new ResultSet created by the specified factory. | public MockResultSet | createResultSet(String id, ResultSetFactory factory) Returns a new ResultSet created by the specified factory. | protected boolean | getCaseSensitive() Returns if specified SQL strings should be handled case sensitive. | public boolean | getContinueProcessingOnBatchFailure() Returns if batch processing should be continued if one of
the commands in the batch fails. | protected boolean | getExactMatch() Returns if specified SQL statements must match exactly. | public List | getExecutedStatements() Returns the List of all executed SQL strings. | public MockResultSet | getGeneratedKeys(String sql) Returns the first generated keys ResultSet that
matches the specified SQL string. | public Map | getGeneratedKeysMap() Returns the Map of all generated keys ResultSet
objects, that were added with
AbstractResultSetHandler.prepareGeneratedKeys(String,MockResultSet) . | public MockResultSet | getGlobalGeneratedKeys() Returns the global generated keys ResultSet . | public MockResultSet | getGlobalResultSet() Returns the global ResultSet . | public MockResultSet[] | getGlobalResultSets() Returns the global ResultSet[] . | public int | getGlobalUpdateCount() Returns the global update count for executeUpdate calls. | public int[] | getGlobalUpdateCounts() Returns the array of global update counts. | public MockResultSet | getResultSet(String sql) Returns the first ResultSet that matches the
specified SQL string. | public Map | getResultSetMap() Returns the Map of all ResultSet
objects, that were added with
AbstractResultSetHandler.prepareResultSet(String,MockResultSet) . | public MockResultSet[] | getResultSets(String sql) Returns the first ResultSet[] that matches the
specified SQL string. | public List | getReturnedResultSets() Returns the List of all returned ResultSet
or ResultSet[] objects. | public Boolean | getReturnsResultSet(String sql) Returns if the specified SQL string is a select that returns
a ResultSet . | public SQLException | getSQLException(String sql) Returns the SQLException the specified SQL string
should throw. | public boolean | getThrowsSQLException(String sql) Returns if the specified SQL string should raise an exception. | public Integer | getUpdateCount(String sql) Returns the first update count that matches the
specified SQL string. | public Map | getUpdateCountMap() Returns the Map of all update counts, that were added
with
AbstractResultSetHandler.prepareUpdateCount(String,int) . | public Integer[] | getUpdateCounts(String sql) Returns the first update count array that matches the
specified SQL string. | protected boolean | getUseRegularExpressions() | public boolean | hasMultipleGlobalResultSets() Returns if multiple global result sets have been prepared, i.e. | public boolean | hasMultipleGlobalUpdateCounts() Returns if multiple global update counts have been prepared, i.e. | public boolean | hasMultipleResultSets(String sql) Returns the if the specified SQL string returns multiple result sets. | public boolean | hasMultipleUpdateCounts(String sql) Returns the if the specified SQL string returns multiple update counts. | public void | prepareGeneratedKeys(String sql, MockResultSet generatedKeysResult) Prepare the generated keys ResultSet
for a specified SQL string. | public void | prepareGlobalGeneratedKeys(MockResultSet generatedKeysResult) Prepare the global generated keys ResultSet . | public void | prepareGlobalResultSet(MockResultSet resultSet) Prepare the global ResultSet . | public void | prepareGlobalResultSets(MockResultSet[] resultSets) Prepare an array of global ResultSet objects. | public void | prepareGlobalUpdateCount(int updateCount) Prepare the global update count for executeUpdate calls. | public void | prepareGlobalUpdateCounts(int[] updateCounts) Prepare an array of global update count values for executeUpdate calls. | public void | prepareResultSet(String sql, MockResultSet resultSet) Prepare a ResultSet for a specified SQL string. | public void | prepareResultSets(String sql, MockResultSet[] resultSets) Prepare an array of ResultSet objects for a specified SQL string. | public void | prepareReturnsResultSet(String sql, boolean returnsResultSet) Prepare if the specified SQL string is a select that returns
a ResultSet . | public void | prepareThrowsSQLException(String sql) Prepare that the specified SQL string should raise an exception.
This can be used to simulate database exceptions. | public void | prepareThrowsSQLException(String sql, SQLException exc) Prepare that the specified SQL string should raise an exception.
This can be used to simulate database exceptions. | public void | prepareUpdateCount(String sql, int updateCount) Prepare the update count for executeUpdate calls
for a specified SQL string. | public void | prepareUpdateCounts(String sql, int[] updateCounts) Prepare an array update count values for executeUpdate calls
for a specified SQL string. | public void | setCaseSensitive(boolean caseSensitive) Set if specified SQL strings should be handled case sensitive.
Defaults to to false , i.e. | public void | setContinueProcessingOnBatchFailure(boolean continueProcessingOnBatchFailure) Set if batch processing should be continued if one of the commands
in the batch fails. | public void | setExactMatch(boolean exactMatch) Set if specified SQL statements must match exactly.
Defaults to false , i.e. | public void | setUseRegularExpressions(boolean useRegularExpressions) Set if regular expressions should be used when matching
SQL statements. |
addExecutedStatement | public void addExecutedStatement(String sql)(Code) | | Collects all SQL strings that were executed.
Parameters: sql - the SQL string |
addReturnedResultSet | public void addReturnedResultSet(MockResultSet resultSet)(Code) | | Collects all ResultSet objects that were returned by
a Statement , PreparedStatement or
CallableStatement .
Parameters: resultSet - the ResultSet |
addReturnedResultSets | public void addReturnedResultSets(MockResultSet[] resultSets)(Code) | | Collects all ResultSet[] objects that were returned by
a Statement , PreparedStatement or
CallableStatement . Called if a statement returns
multiple result sets.
Parameters: resultSets - the ResultSet[] |
clearGeneratedKeys | public void clearGeneratedKeys()(Code) | | Clears the list of statements that return generated keys.
|
clearGlobalGeneratedKeys | public void clearGlobalGeneratedKeys()(Code) | | Clears the prepared global generated keys ResultSet .
|
clearGlobalResultSet | public void clearGlobalResultSet()(Code) | | Clears the prepared global ResultSet .
|
clearGlobalUpdateCount | public void clearGlobalUpdateCount()(Code) | | Clears the prepared global update count.
|
clearResultSets | public void clearResultSets()(Code) | | Clears all prepared ResultSet objects.
|
clearReturnsResultSet | public void clearReturnsResultSet()(Code) | | Clears the definitions if statements return
ResultSet objects or update counts.
|
clearThrowsSQLException | public void clearThrowsSQLException()(Code) | | Clears the list of statements that should throw an exception.
|
clearUpdateCounts | public void clearUpdateCounts()(Code) | | Clears all prepared update counts.
|
createResultSet | public MockResultSet createResultSet()(Code) | | Creates a new ResultSet with a
random id.
the new ResultSet |
createResultSet | public MockResultSet createResultSet(String id)(Code) | | Creates a new ResultSet with the specified id.
Parameters: id - the id the new ResultSet |
getCaseSensitive | protected boolean getCaseSensitive()(Code) | | Returns if specified SQL strings should be handled case sensitive.
is case sensitivity enabled or disabled |
getContinueProcessingOnBatchFailure | public boolean getContinueProcessingOnBatchFailure()(Code) | | Returns if batch processing should be continued if one of
the commands in the batch fails.
if batch processing should be continued |
getExactMatch | protected boolean getExactMatch()(Code) | | Returns if specified SQL statements must match exactly.
is exact matching enabled or disabled |
getExecutedStatements | public List getExecutedStatements()(Code) | | Returns the List of all executed SQL strings.
the List of executed SQL strings |
getGlobalResultSet | public MockResultSet getGlobalResultSet()(Code) | | Returns the global ResultSet .
If an array of global result sets was prepared, the first one will
be returned.
the global MockResultSet |
getGlobalResultSets | public MockResultSet[] getGlobalResultSets()(Code) | | Returns the global ResultSet[] .
If one single ResultSet was prepared, this ResultSet
will be wrapped in an array with one element.
the global MockResultSet[] |
getGlobalUpdateCount | public int getGlobalUpdateCount()(Code) | | Returns the global update count for executeUpdate calls.
If an array of global update counts was prepared, the first one will
be returned.
the global update count |
getGlobalUpdateCounts | public int[] getGlobalUpdateCounts()(Code) | | Returns the array of global update counts.
If one single update count value was prepared, this value
will be wrapped in an array with one element.
the array of global update counts |
getReturnedResultSets | public List getReturnedResultSets()(Code) | | Returns the List of all returned ResultSet
or ResultSet[] objects. The List contains
arrays of result sets, if a query returned multiple result sets.
If a query returned multiple result sets, the list will always contain
the full array of ResultSet objects that were prepared, even
if
com.mockrunner.mock.jdbc.MockStatement.getMoreResults was
not called for all the result sets.
the List of returned ResultSet or ResultSet[] objects |
getUseRegularExpressions | protected boolean getUseRegularExpressions()(Code) | | Returns if regular expression matching is enabled
if regular expression matching is enabled |
hasMultipleGlobalResultSets | public boolean hasMultipleGlobalResultSets()(Code) | | Returns if multiple global result sets have been prepared, i.e. if
an array of global result sets was prepared.
true if an array of global result sets was prepared,false otherwise |
hasMultipleGlobalUpdateCounts | public boolean hasMultipleGlobalUpdateCounts()(Code) | | Returns if multiple global update counts have been prepared, i.e. if
an array of global update counts was prepared.
true if an array of global update counts was prepared,false otherwise |
prepareGlobalGeneratedKeys | public void prepareGlobalGeneratedKeys(MockResultSet generatedKeysResult)(Code) | | Prepare the global generated keys ResultSet .
Parameters: generatedKeysResult - the generated keys MockResultSet |
prepareGlobalResultSets | public void prepareGlobalResultSets(MockResultSet[] resultSets)(Code) | | Prepare an array of global ResultSet objects.
Parameters: resultSets - the corresponding MockResultSet[] |
prepareGlobalUpdateCount | public void prepareGlobalUpdateCount(int updateCount)(Code) | | Prepare the global update count for executeUpdate calls.
Parameters: updateCount - the update count |
prepareGlobalUpdateCounts | public void prepareGlobalUpdateCounts(int[] updateCounts)(Code) | | Prepare an array of global update count values for executeUpdate calls.
Parameters: updateCounts - the update count array |
setCaseSensitive | public void setCaseSensitive(boolean caseSensitive)(Code) | | Set if specified SQL strings should be handled case sensitive.
Defaults to to false , i.e. INSERT is the same
as insert.
Please note that this method controls SQL statement
matching for prepared results and update counts, i.e. what
statements the tested application has to execute to receive
a specified result. Unlike
JDBCTestModule.setCaseSensitive(boolean) it does not control the statement matching of
JDBCTestModule methods.
Parameters: caseSensitive - enable or disable case sensitivity |
setContinueProcessingOnBatchFailure | public void setContinueProcessingOnBatchFailure(boolean continueProcessingOnBatchFailure)(Code) | | Set if batch processing should be continued if one of the commands
in the batch fails. This behaviour is driver dependend. The default is
false , i.e. if a command fails with an exception,
batch processing will not continue and the remaining commands
will not be executed.
Parameters: continueProcessingOnBatchFailure - should batch processing be continued |
setExactMatch | public void setExactMatch(boolean exactMatch)(Code) | | Set if specified SQL statements must match exactly.
Defaults to false , i.e. the SQL string
does not need to match exactly. If the original statement
is insert into mytable values(?, ?, ?)
the string insert into mytable will match this statement.
Usually false is the best choice, so
prepared ResultSet objects do not have
to match exactly the current statements SQL string.
The current SQL string just has to contain the SQL string
for the prepared prepared ResultSet .
Please note that this method controls SQL statement
matching for prepared results and update counts, i.e. what
statements the tested application has to execute to receive
a specified result. Unlike
JDBCTestModule.setExactMatch(boolean) it does not control the statement matching of
JDBCTestModule methods.
Parameters: exactMatch - enable or disable exact matching |
setUseRegularExpressions | public void setUseRegularExpressions(boolean useRegularExpressions)(Code) | | Set if regular expressions should be used when matching
SQL statements. Irrelevant if exactMatch is
true . Default is false , i.e. you
cannot use regular expressions and matching is based
on string comparison.
Please note that this method controls SQL statement
matching for prepared results and update counts, i.e. what
statements the tested application has to execute to receive
a specified result. Unlike
JDBCTestModule.setUseRegularExpressions(boolean) it does not control the statement matching of
JDBCTestModule methods.
Parameters: useRegularExpressions - should regular expressions be used |
|
|