/** * Creates the {@link com.mockrunner.mock.jdbc.MockConnection} using <code>new</code>. * This method can be overridden to return a subclass of {@link com.mockrunner.mock.jdbc.MockConnection}. * @return the {@link com.mockrunner.mock.jdbc.MockConnection} */ public MockConnection createMockConnection() { return new MockConnection(); }
/** * Returns the {@link CallableStatementResultSetHandler}. * The {@link CallableStatementResultSetHandler} * contains methods that can be used to specify the * {@link com.mockrunner.mock.jdbc.MockResultSet} objects * and update counts that a {@link com.mockrunner.mock.jdbc.MockCallableStatement} * should return when executing an SQL statement. * @return the {@link CallableStatementResultSetHandler} */ public CallableStatementResultSetHandler getCallableStatementResultSetHandler() { return mockFactory.getMockConnection().getCallableStatementResultSetHandler(); }
/** * Returns the {@link PreparedStatementResultSetHandler}. * The {@link PreparedStatementResultSetHandler} * contains methods that can be used to specify the * {@link com.mockrunner.mock.jdbc.MockResultSet} objects * and update counts that a {@link com.mockrunner.mock.jdbc.MockPreparedStatement} * should return when executing an SQL statement. * @return the {@link PreparedStatementResultSetHandler} */ public PreparedStatementResultSetHandler getPreparedStatementResultSetHandler() { return mockFactory.getMockConnection().getPreparedStatementResultSetHandler(); }
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException { verifyAutoGeneratedKeysParameter(autoGeneratedKeys); MockPreparedStatement statement = new MockPreparedStatement(this, sql, autoGeneratedKeys == Statement.RETURN_GENERATED_KEYS); getPreparedStatementResultSetHandler().addPreparedStatement(statement); return statement; }
/** * Returns a <code>List</code> of all SQL statements that were executed * by calling an <code>execute</code> method of a {@link com.mockrunner.mock.jdbc.MockStatement}, * {@link com.mockrunner.mock.jdbc.MockPreparedStatement} or * {@link com.mockrunner.mock.jdbc.MockCallableStatement}. * @return the <code>List</code> of SQL statements */ public List getExecutedSQLStatements() { ArrayList list = new ArrayList(); list.addAll(mockFactory.getMockConnection().getStatementResultSetHandler().getExecutedStatements()); list.addAll(mockFactory.getMockConnection().getPreparedStatementResultSetHandler().getExecutedStatements()); list.addAll(mockFactory.getMockConnection().getCallableStatementResultSetHandler().getExecutedStatements()); return list; }
/** * Returns the {@link StatementResultSetHandler}. * The {@link StatementResultSetHandler} * contains methods that can be used to specify the * {@link com.mockrunner.mock.jdbc.MockResultSet} objects * and update counts that a {@link com.mockrunner.mock.jdbc.MockStatement} * should return when executing an SQL statement. * @return the {@link StatementResultSetHandler} */ public StatementResultSetHandler getStatementResultSetHandler() { return mockFactory.getMockConnection().getStatementResultSetHandler(); }
/** * Returns a <code>Map</code> of all parameters that were used when * executing a {@link com.mockrunner.mock.jdbc.MockPreparedStatement} or * {@link com.mockrunner.mock.jdbc.MockCallableStatement}. * The keys are the corresponding SQL statements. The values are the * {@link ParameterSets} objects. * @return the <code>Map</code> of parameters */ public Map getExecutedSQLStatementParameterMap() { Map map = new TreeMap(); map.putAll(mockFactory.getMockConnection().getPreparedStatementResultSetHandler().getExecutedStatementParameterMap()); map.putAll(mockFactory.getMockConnection().getCallableStatementResultSetHandler().getExecutedStatementParameterMap()); return map; }
/** * Verifies that the changes were not commited. * Makes only sense, if the <code>Connection</code> is not in * autocommit mode. Automatic commits are not recognized. * @throws VerifyFailedException if verification fails */ public void verifyNotCommitted() { int number = mockFactory.getMockConnection().getNumberCommits(); if(number > 0) { throw new VerifyFailedException("Connection was committed"); } }
/** * Verifies that the changes were not rolled back. * Makes only sense, if the <code>Connection</code> is not in * autocommit mode. * @throws VerifyFailedException if verification fails */ public void verifyNotRolledBack() { int number = mockFactory.getMockConnection().getNumberRollbacks(); if(number > 0) { throw new VerifyFailedException("Connection was rolled back."); } }
public boolean isValid(int timeout) throws SQLException { return !isClosed(); }
public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException { return prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); }
/** * Returns a list of all <code>Savepoint</code> objects. * @return the <code>List</code> of {@link com.mockrunner.mock.jdbc.MockSavepoint} objects */ public List getSavepoints() { return new ArrayList(mockFactory.getMockConnection().getSavepointMap().values()); }
public Savepoint setSavepoint() throws SQLException { return setSavepoint(""); }
/** * Returns a <code>List</code> of all SQL statements that were executed * by calling an <code>execute</code> method of a {@link com.mockrunner.mock.jdbc.MockStatement}, * {@link com.mockrunner.mock.jdbc.MockPreparedStatement} or * {@link com.mockrunner.mock.jdbc.MockCallableStatement}. * @return the <code>List</code> of SQL statements */ public List getExecutedSQLStatements() { ArrayList list = new ArrayList(); list.addAll(mockFactory.getMockConnection().getStatementResultSetHandler().getExecutedStatements()); list.addAll(mockFactory.getMockConnection().getPreparedStatementResultSetHandler().getExecutedStatements()); list.addAll(mockFactory.getMockConnection().getCallableStatementResultSetHandler().getExecutedStatements()); return list; }
/** * Returns the {@link StatementResultSetHandler}. * The {@link StatementResultSetHandler} * contains methods that can be used to specify the * {@link com.mockrunner.mock.jdbc.MockResultSet} objects * and update counts that a {@link com.mockrunner.mock.jdbc.MockStatement} * should return when executing an SQL statement. * @return the {@link StatementResultSetHandler} */ public StatementResultSetHandler getStatementResultSetHandler() { return mockFactory.getMockConnection().getStatementResultSetHandler(); }
/** * Returns a <code>Map</code> of all parameters that were used when * executing a {@link com.mockrunner.mock.jdbc.MockPreparedStatement} or * {@link com.mockrunner.mock.jdbc.MockCallableStatement}. * The keys are the corresponding SQL statements. The values are the * {@link ParameterSets} objects. * @return the <code>Map</code> of parameters */ public Map<String, ParameterSets> getExecutedSQLStatementParameterMap() { Map<String, ParameterSets> map = new TreeMap<String, ParameterSets>(); map.putAll(mockFactory.getMockConnection().getPreparedStatementResultSetHandler().getExecutedStatementParameterMap()); map.putAll(mockFactory.getMockConnection().getCallableStatementResultSetHandler().getExecutedStatementParameterMap()); return map; }
/** * Verifies that the changes were commited, i.e. the <code>commit</code> * method of <code>Connection</code> was at least called once. * Makes only sense, if the <code>Connection</code> is not in * autocommit mode. Automatic commits are not recognized. * @throws VerifyFailedException if verification fails */ public void verifyCommitted() { int number = mockFactory.getMockConnection().getNumberCommits(); if(number <= 0) { throw new VerifyFailedException("Connection received no commits."); } }
/** * Verifies that the changes were not rolled back. * Makes only sense, if the <code>Connection</code> is not in * autocommit mode. * @throws VerifyFailedException if verification fails */ public void verifyNotRolledBack() { int number = mockFactory.getMockConnection().getNumberRollbacks(); if(number > 0) { throw new VerifyFailedException("Connection was rolled back."); } }
public boolean isValid(int timeout) throws SQLException { return isClosed(); }
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException { verifyAutoGeneratedKeysParameter(autoGeneratedKeys); MockPreparedStatement statement = new MockPreparedStatement(this, sql, autoGeneratedKeys == Statement.RETURN_GENERATED_KEYS);; getPreparedStatementResultSetHandler().addPreparedStatement(statement); return statement; }