| com.mockrunner.jdbc.BasicJDBCTestCaseAdapter com.mockrunner.example.jdbc.BookstoreTest
BookstoreTest | public class BookstoreTest extends BasicJDBCTestCaseAdapter (Code) | | Example test for
Bookstore . Demonstrates the usage of
com.mockrunner.jdbc.JDBCTestModule
and
com.mockrunner.jdbc.BasicJDBCTestCaseAdapter .
This is an example for the handling of
com.mockrunner.mock.jdbc.MockResultSet .
The data that the JDBC code should receive when executing the select
statement is specified in the file bookstore.txt. Please note that we
do not pass a filled List to the order method in the
succesful order test, because the choice if a table row should
be in the result is done by SQL. The framework does not execute any
SQL. In the second test, we check the correct SQL string.
In the third test, we specify that the statement should raise an
SQL exception (to simulate a database error) and verify, that
the transaction is rolled back.
This example uses regular expressions. Per default, regular expressions
are disabled, i.e. the preparation of result sets and verification of
executed SQL statements is based on simple string comparison.
With
setUseRegularExpressions(true);
and
getStatementResultSetHandler().setUseRegularExpressions(true);
you enable regular expressions for the preparation of result sets and
verification of executed SQL statements (note that for prepared and
callable statements you would have to enable it seperately).
E.g. prepareResultSet("select.*isbn,.*quantity.*", result)
means that only the words select, isbn,, and quantity
must appear in the specified order, all other characters are irrelevant.
Besides that simple example, you can use any Perl5 compatible expression.
|
testSuccessfulOrder | public void testSuccessfulOrder() throws Exception(Code) | | |
Methods inherited from com.mockrunner.jdbc.BasicJDBCTestCaseAdapter | protected JDBCMockObjectFactory createJDBCMockObjectFactory()(Code)(Java Doc) protected JDBCTestModule createJDBCTestModule()(Code)(Java Doc) protected JDBCTestModule createJDBCTestModule(JDBCMockObjectFactory mockFactory)(Code)(Java Doc) protected MockCallableStatement getCallableStatement(String sql)(Code)(Java Doc) protected MockCallableStatement getCallableStatement(int index)(Code)(Java Doc) protected Object getCallableStatementParameter(String sql, String nameOfParameter)(Code)(Java Doc) protected Object getCallableStatementParameter(int indexOfStatement, String nameOfParameter)(Code)(Java Doc) protected Object getCallableStatementParameter(CallableStatement statement, String nameOfParameter)(Code)(Java Doc) protected Object getCallableStatementParameter(String sql, int indexOfParameter)(Code)(Java Doc) protected Object getCallableStatementParameter(CallableStatement statement, int indexOfParameter)(Code)(Java Doc) protected Object getCallableStatementParameter(int indexOfStatement, int indexOfParameter)(Code)(Java Doc) protected CallableStatementResultSetHandler getCallableStatementResultSetHandler()(Code)(Java Doc) protected List getCallableStatements(String sql)(Code)(Java Doc) protected List getCallableStatements()(Code)(Java Doc) protected Map getExecutedSQLStatementParameter()(Code)(Java Doc) protected Map getExecutedSQLStatementParameterMap()(Code)(Java Doc) protected ParameterSets getExecutedSQLStatementParameterSets(String sql)(Code)(Java Doc) protected List getExecutedSQLStatements()(Code)(Java Doc) protected JDBCMockObjectFactory getJDBCMockObjectFactory()(Code)(Java Doc) protected JDBCTestModule getJDBCTestModule()(Code)(Java Doc) protected MockPreparedStatement getPreparedStatement(String sql)(Code)(Java Doc) protected MockPreparedStatement getPreparedStatement(int index)(Code)(Java Doc) protected Object getPreparedStatementParameter(String sql, int indexOfParameter)(Code)(Java Doc) protected Object getPreparedStatementParameter(int indexOfStatement, int indexOfParameter)(Code)(Java Doc) protected Object getPreparedStatementParameter(PreparedStatement statement, int indexOfParameter)(Code)(Java Doc) protected PreparedStatementResultSetHandler getPreparedStatementResultSetHandler()(Code)(Java Doc) protected List getPreparedStatements(String sql)(Code)(Java Doc) protected List getPreparedStatements()(Code)(Java Doc) protected MockResultSet getReturnedResultSet(String id)(Code)(Java Doc) protected List getReturnedResultSets(String id)(Code)(Java Doc) protected List getReturnedResultSets()(Code)(Java Doc) protected MockStatement getStatement(int index)(Code)(Java Doc) protected StatementResultSetHandler getStatementResultSetHandler()(Code)(Java Doc) protected List getStatements()(Code)(Java Doc) protected void setCaseSensitive(boolean caseSensitive)(Code)(Java Doc) protected void setExactMatch(boolean exactMatch)(Code)(Java Doc) protected void setJDBCMockObjectFactory(JDBCMockObjectFactory jdbcMockObjectFactory)(Code)(Java Doc) protected void setJDBCTestModule(JDBCTestModule jdbcTestModule)(Code)(Java Doc) protected void setUp() throws Exception(Code)(Java Doc) protected void setUseRegularExpressions(boolean useRegularExpressions)(Code)(Java Doc) protected void tearDown() throws Exception(Code)(Java Doc) protected void verifyAllResultSetsClosed()(Code)(Java Doc) protected void verifyAllStatementsClosed()(Code)(Java Doc) protected void verifyCallableStatementClosed(int index)(Code)(Java Doc) protected void verifyCallableStatementClosed(String sql)(Code)(Java Doc) protected void verifyCallableStatementNotPresent(String sql)(Code)(Java Doc) protected void verifyCallableStatementOutParameterRegistered(CallableStatement statement, int indexOfParameter)(Code)(Java Doc) protected void verifyCallableStatementOutParameterRegistered(String sql, int indexOfParameter)(Code)(Java Doc) protected void verifyCallableStatementOutParameterRegistered(int indexOfStatement, int indexOfParameter)(Code)(Java Doc) protected void verifyCallableStatementOutParameterRegistered(CallableStatement statement, String nameOfParameter)(Code)(Java Doc) protected void verifyCallableStatementOutParameterRegistered(String sql, String nameOfParameter)(Code)(Java Doc) protected void verifyCallableStatementOutParameterRegistered(int indexOfStatement, String nameOfParameter)(Code)(Java Doc) protected void verifyCallableStatementParameter(int indexOfStatement, String nameOfParameter, Object object)(Code)(Java Doc) protected void verifyCallableStatementParameter(CallableStatement statement, int indexOfParameter, Object object)(Code)(Java Doc) protected void verifyCallableStatementParameter(String sql, int indexOfParameter, Object object)(Code)(Java Doc) protected void verifyCallableStatementParameter(int indexOfStatement, int indexOfParameter, Object object)(Code)(Java Doc) protected void verifyCallableStatementParameter(CallableStatement statement, String nameOfParameter, Object object)(Code)(Java Doc) protected void verifyCallableStatementParameter(String sql, String nameOfParameter, Object object)(Code)(Java Doc) protected void verifyCallableStatementParameterNotPresent(CallableStatement statement, String nameOfParameter)(Code)(Java Doc) protected void verifyCallableStatementParameterNotPresent(int indexOfStatement, int indexOfParameter)(Code)(Java Doc) protected void verifyCallableStatementParameterNotPresent(CallableStatement statement, int indexOfParameter)(Code)(Java Doc) protected void verifyCallableStatementParameterNotPresent(String sql, int indexOfParameter)(Code)(Java Doc) protected void verifyCallableStatementParameterNotPresent(int indexOfStatement, String nameOfParameter)(Code)(Java Doc) protected void verifyCallableStatementParameterNotPresent(String sql, String nameOfParameter)(Code)(Java Doc) protected void verifyCallableStatementParameterPresent(int indexOfStatement, String nameOfParameter)(Code)(Java Doc) protected void verifyCallableStatementParameterPresent(CallableStatement statement, int indexOfParameter)(Code)(Java Doc) protected void verifyCallableStatementParameterPresent(String sql, int indexOfParameter)(Code)(Java Doc) protected void verifyCallableStatementParameterPresent(int indexOfStatement, int indexOfParameter)(Code)(Java Doc) protected void verifyCallableStatementParameterPresent(String sql, String nameOfParameter)(Code)(Java Doc) protected void verifyCallableStatementParameterPresent(CallableStatement statement, String nameOfParameter)(Code)(Java Doc) protected void verifyCallableStatementPresent(String sql)(Code)(Java Doc) protected void verifyCommitted()(Code)(Java Doc) protected void verifyConnectionClosed()(Code)(Java Doc) protected void verifyNotCommitted()(Code)(Java Doc) protected void verifyNotRolledBack()(Code)(Java Doc) protected void verifyNumberCallableStatements(int number, String sql)(Code)(Java Doc) protected void verifyNumberCallableStatements(int number)(Code)(Java Doc) protected void verifyNumberCommits(int number)(Code)(Java Doc) protected void verifyNumberPreparedStatements(int number, String sql)(Code)(Java Doc) protected void verifyNumberPreparedStatements(int number)(Code)(Java Doc) protected void verifyNumberRollbacks(int number)(Code)(Java Doc) protected void verifyNumberStatements(int number)(Code)(Java Doc) protected void verifyPreparedStatementClosed(String sql)(Code)(Java Doc) protected void verifyPreparedStatementClosed(int index)(Code)(Java Doc) protected void verifyPreparedStatementNotPresent(String sql)(Code)(Java Doc) protected void verifyPreparedStatementParameter(PreparedStatement statement, int indexOfParameter, Object object)(Code)(Java Doc) protected void verifyPreparedStatementParameter(String sql, int indexOfParameter, Object object)(Code)(Java Doc) protected void verifyPreparedStatementParameter(int indexOfStatement, int indexOfParameter, Object object)(Code)(Java Doc) protected void verifyPreparedStatementParameterNotPresent(String sql, int indexOfParameter)(Code)(Java Doc) protected void verifyPreparedStatementParameterNotPresent(PreparedStatement statement, int indexOfParameter)(Code)(Java Doc) protected void verifyPreparedStatementParameterNotPresent(int indexOfStatement, int indexOfParameter)(Code)(Java Doc) protected void verifyPreparedStatementParameterPresent(PreparedStatement statement, int indexOfParameter)(Code)(Java Doc) protected void verifyPreparedStatementParameterPresent(String sql, int indexOfParameter)(Code)(Java Doc) protected void verifyPreparedStatementParameterPresent(int indexOfStatement, int indexOfParameter)(Code)(Java Doc) protected void verifyPreparedStatementPresent(String sql)(Code)(Java Doc) protected void verifyResultSetClosed(String id)(Code)(Java Doc) protected void verifyResultSetColumn(String id, String name, List columnData)(Code)(Java Doc) protected void verifyResultSetColumn(MockResultSet resultSet, int number, List columnData)(Code)(Java Doc) protected void verifyResultSetColumn(MockResultSet resultSet, int number, Object[] columnData)(Code)(Java Doc) protected void verifyResultSetColumn(String id, int number, List columnData)(Code)(Java Doc) protected void verifyResultSetColumn(String id, int number, Object[] columnData)(Code)(Java Doc) protected void verifyResultSetColumn(MockResultSet resultSet, String name, List columnData)(Code)(Java Doc) protected void verifyResultSetColumn(MockResultSet resultSet, String name, Object[] columnData)(Code)(Java Doc) protected void verifyResultSetColumn(String id, String name, Object[] columnData)(Code)(Java Doc) protected void verifyResultSetEquals(String id, MockResultSet target)(Code)(Java Doc) protected void verifyResultSetEquals(MockResultSet source, MockResultSet target)(Code)(Java Doc) protected void verifyResultSetRow(MockResultSet resultSet, int number, List rowData)(Code)(Java Doc) protected void verifyResultSetRow(MockResultSet resultSet, int number, Object[] rowData)(Code)(Java Doc) protected void verifyResultSetRow(String id, int number, List rowData)(Code)(Java Doc) protected void verifyResultSetRow(String id, int number, Object[] rowData)(Code)(Java Doc) protected void verifyResultSetRowDeleted(MockResultSet resultSet, int number)(Code)(Java Doc) protected void verifyResultSetRowDeleted(String id, int number)(Code)(Java Doc) protected void verifyResultSetRowInserted(MockResultSet resultSet, int number)(Code)(Java Doc) protected void verifyResultSetRowInserted(String id, int number)(Code)(Java Doc) protected void verifyResultSetRowNotDeleted(String id, int number)(Code)(Java Doc) protected void verifyResultSetRowNotDeleted(MockResultSet resultSet, int number)(Code)(Java Doc) protected void verifyResultSetRowNotInserted(MockResultSet resultSet, int number)(Code)(Java Doc) protected void verifyResultSetRowNotInserted(String id, int number)(Code)(Java Doc) protected void verifyResultSetRowNotUpdated(String id, int number)(Code)(Java Doc) protected void verifyResultSetRowNotUpdated(MockResultSet resultSet, int number)(Code)(Java Doc) protected void verifyResultSetRowUpdated(MockResultSet resultSet, int number)(Code)(Java Doc) protected void verifyResultSetRowUpdated(String id, int number)(Code)(Java Doc) protected void verifyRolledBack()(Code)(Java Doc) protected void verifySQLStatementExecuted(String sql)(Code)(Java Doc) protected void verifySQLStatementNotExecuted(String sql)(Code)(Java Doc) protected void verifySQLStatementParameter(String sql, int indexOfParameterSet, String nameOfParameter, Object expectedParameter)(Code)(Java Doc) protected void verifySQLStatementParameter(String sql, int indexOfParameterSet, int indexOfParameter, Object expectedParameter)(Code)(Java Doc) protected void verifySQLStatementParameter(String sql, int indexOfParameterSet, Map parameterMap)(Code)(Java Doc) protected void verifySQLStatementParameterNumber(String sql, int indexOfParameterSet, int number)(Code)(Java Doc) protected void verifyStatementClosed(int index)(Code)(Java Doc)
|
|
|