From: <fra...@ya...> - 2002-06-30 04:44:12
|
Hello everyone, This unidiff patch allows one to setup the connection and result set objects that the mock should return. A small and simple patch :) Hope that helps ! Francois Beausoleil Index: src/jdk/common/com/mockobjects/sql/CommonMockStatement.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/sql/CommonMockStatement.java,v retrieving revision 1.1 diff -u -r1.1 CommonMockStatement.java --- src/jdk/common/com/mockobjects/sql/CommonMockStatement.java 28 Jun 2002 17:35:39 -0000 1.1 +++ src/jdk/common/com/mockobjects/sql/CommonMockStatement.java 30 Jun 2002 04:43:18 -0000 @@ -16,6 +16,8 @@ private int myUpdateCount = 0; private SQLException myExecuteException = null; + private Connection myConnection = null; + public void setExpectedExecuteCalls(int callCount) { myExecuteCalls.setExpected(callCount); } @@ -32,6 +34,10 @@ myResultSets.addObjectToReturn(aResultSet); } + public void setupConnection(Connection conn) { + myConnection = conn; + } + public void setupThrowExceptionOnExecute(SQLException exception) { myExecuteException = exception; } @@ -42,7 +48,7 @@ protected void innerExecute() throws SQLException { myExecuteCalls.inc(); - if(null != myExecuteException) { + if (null != myExecuteException) { throw myExecuteException; } } @@ -59,7 +65,7 @@ public ResultSet executeQuery(String sql) throws SQLException { myQueryString.setActual(sql); innerExecute(); - return (ResultSet) myResultSets.nextReturnObject(); + return (ResultSet)myResultSets.nextReturnObject(); } public int executeUpdate(String sql) throws SQLException { @@ -172,8 +178,6 @@ } public Connection getConnection() throws SQLException { - notImplemented(); - return null; + return myConnection; } - } ===== Francois Beausoleil Java Gui Builder - http://jgb.sourceforge.net/ __________________________________________________________ Lèche-vitrine ou lèche-écran ? magasinage.yahoo.ca |