From: <fb...@us...> - 2003-02-19 05:36:32
|
Hi, This is a simple patch that implements createStatement(int resultSetType, int resultSetConcurrency). I use IntelliJ's Idea and I reformatted the code too, so there are a few changes that are not a direct result of this implementation. Thanks, Francois Beausoleil Index: src/jdk/common/com/mockobjects/sql/CommonMockConnection.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/sql/CommonMockConnection.java,v retrieving revision 1.6 diff -u -r1.6 CommonMockConnection.java --- src/jdk/common/com/mockobjects/sql/CommonMockConnection.java 9 Dec 2002 18:20:14 -0000 1.6 +++ src/jdk/common/com/mockobjects/sql/CommonMockConnection.java 19 Feb 2003 05:08:44 -0000 @@ -68,7 +68,7 @@ * Exceptions to throw can be registered for calling createStatement, * preparedStatement, or close. * Several less-often-used methods are not implemented. - * If a notImplemented method is are needed for your project, please submit + * If a notImplemented method is needed for your project, please submit * a patch. * @see <a href="http://java.sun.com/j2se/1.3/docs/api/java/sql/Connection.html">javax.sql.Connection</a> * @author @@ -89,6 +89,9 @@ private boolean autoCommit = false; + private final ExpectationValue myResultSetConcurrency; + private final ExpectationValue myResultSetType; + private final ExpectationList myAutoCommit; private final ExpectationCounter myCloseCalls; private final ExpectationCounter myCommitCalls; @@ -132,6 +135,8 @@ myPreparedStatements = new ReturnObjectList(name + ".PreparedStatements"); myPreparedStatementStrings = new ExpectationList(name + ".preparedStatementString"); myRollbackCalls = new ExpectationCounter(name + ".rollback"); + myResultSetType = new ExpectationValue(name + ".resultSetType"); + myResultSetConcurrency = new ExpectationValue(name + ".resultSetConcurrency"); } /** @@ -188,6 +193,30 @@ myRollbackCalls.setExpected(callCount); } + /** + * Sets expectations about the possible value of the + * <code>resultSetConcurrency</code> parameter of + * {@link #createStatement(int, int) createStatement()} calls. + * + * @param resultSetConcurrency One of the constants starting with CONCUR + * in {@link java.sql.ResultSet}. + */ + public void setExpectedResultSetConcurrency(int resultSetConcurrency) { + myResultSetConcurrency.setExpected(resultSetConcurrency); + } + + /** + * Sets expectations about the possible value of the + * <code>resultSetType</code> parameter of + * {@link #createStatement(int, int) createStatement()} calls. + * + * @param resultSetType One of the constants starting with TYPE + * in {@link java.sql.ResultSet}. + */ + public void setExpectedResultSetType(int resultSetType) { + myResultSetType.setExpected(resultSetType); + } + // --------------------------------------------------------------------- setup /** @@ -304,7 +333,7 @@ * Returns the DatabaseMetaData instance passed to setupMetaData. */ public DatabaseMetaData getMetaData() - throws SQLException { + throws SQLException { return myMetaData; } @@ -328,7 +357,7 @@ public PreparedStatement prepareStatement(String sql) throws SQLException { myPreparedStatementStrings.addActual(sql); throwStatementExceptionIfAny(); - return (PreparedStatement) myPreparedStatements.nextReturnObject(); + return (PreparedStatement)myPreparedStatements.nextReturnObject(); } /** @@ -360,11 +389,16 @@ * Calls notImplemented. Returns null. */ public Statement createStatement( - int resultSetType, - int resultSetConcurrency) - throws SQLException { - notImplemented(); - return null; + int resultSetType, + int resultSetConcurrency) + throws SQLException { + myCreateStatementCalls.inc(); + throwStatementExceptionIfAny(); + + myResultSetType.setActual(resultSetType); + myResultSetConcurrency.setActual(resultSetConcurrency); + + return myStatement; } public boolean getAutoCommit() throws SQLException { @@ -423,7 +457,7 @@ * Calls notImplemented. Returns null. */ public CallableStatement prepareCall(String sql) - throws SQLException { + throws SQLException { notImplemented(); return null; } @@ -432,10 +466,10 @@ * Calls notImplemented. Returns null. */ public CallableStatement prepareCall( - String sql, - int resultSetType, - int resultSetConcurrency) - throws SQLException { + String sql, + int resultSetType, + int resultSetConcurrency) + throws SQLException { notImplemented(); return null; } @@ -444,10 +478,10 @@ * Calls notImplemented. Returns null. */ public PreparedStatement prepareStatement( - String sql, - int resultSetType, - int resultSetConcurrency) - throws SQLException { + String sql, + int resultSetType, + int resultSetConcurrency) + throws SQLException { notImplemented(); return null; } @@ -470,7 +504,7 @@ * Calls notImplemented. */ public void setTransactionIsolation(int level) - throws SQLException { + throws SQLException { notImplemented(); } @@ -491,39 +525,39 @@ } public Statement createStatement(int resultSetType, int resultSetConcurrency, - int resultSetHoldability) throws SQLException { + int resultSetHoldability) throws SQLException { notImplemented(); return null; } public PreparedStatement prepareStatement(String sql, int resultSetType, - int resultSetConcurrency, int resultSetHoldability) - throws SQLException { + int resultSetConcurrency, int resultSetHoldability) + throws SQLException { notImplemented(); return null; } public CallableStatement prepareCall(String sql, int resultSetType, - int resultSetConcurrency, - int resultSetHoldability) throws SQLException { + int resultSetConcurrency, + int resultSetHoldability) throws SQLException { notImplemented(); return null; } public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) - throws SQLException { + throws SQLException { notImplemented(); return null; } public PreparedStatement prepareStatement(String sql, int columnIndexes[]) - throws SQLException { + throws SQLException { notImplemented(); return null; } public PreparedStatement prepareStatement(String sql, String columnNames[]) - throws SQLException { + throws SQLException { notImplemented(); return null; } |