From: Steve F. <sm...@us...> - 2001-09-19 21:38:34
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/sql In directory usw-pr-cvs1:/tmp/cvs-serv11269 Modified Files: MockConnection.java Log Message: Added multiple prepared statements Added autoCommit Index: MockConnection.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/sql/MockConnection.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- MockConnection.java 2001/08/11 20:42:05 1.3 +++ MockConnection.java 2001/09/19 21:38:31 1.4 @@ -1,21 +1,20 @@ package com.mockobjects.sql; import java.sql.*; -import java.util.Map; -import com.mockobjects.ExpectationCounter; -import com.mockobjects.ExpectationValue; -import com.mockobjects.MockObject; +import java.util.*; +import com.mockobjects.*; public class MockConnection extends MockObject implements Connection { private ExpectationCounter myCommitCalls = new ExpectationCounter("MockConnection.commit"); private ExpectationCounter myRollbackCalls = new ExpectationCounter("MockConnection.rollback"); private ExpectationCounter myCloseCalls = new ExpectationCounter("MockConnection.close"); - private ExpectationValue myPrepareStatementString = new ExpectationValue("MockConnection.preparedStatementString"); - private PreparedStatement myPreparedStatement; + private ExpectationCollection myPreparedStatementStrings = new ExpectationList("MockConnection.preparedStatementString"); + private ArrayList myPreparedStatements = new ArrayList(); private SQLException myStatementException = null; private ExpectationCounter myCreateStatementCalls = new ExpectationCounter("MockConnection.createStatement"); + private ExpectationValue myAutoCommit = new ExpectationValue("MockConnection.setAutoCommit"); private Statement myStatement; public MockConnection() { @@ -34,16 +33,16 @@ myCreateStatementCalls.setExpected(calls); } - public void setExpectedPrepareStatementString(String sql) { - myPrepareStatementString.setExpected(sql); + public void addExpectedPreparedStatementString(String sql) { + myPreparedStatementStrings.addExpected(sql); } public void setExpectedRollbackCalls(int callCount) { myRollbackCalls.setExpected(callCount); } - public void setupPreparedStatement(PreparedStatement prepared) { - myPreparedStatement = prepared; + public void setupAddPreparedStatement(PreparedStatement prepared) { + myPreparedStatements.add(prepared); } public void setupStatement(Statement statement) { @@ -129,9 +128,9 @@ } public PreparedStatement prepareStatement(String sql) throws SQLException { - myPrepareStatementString.setActual(sql); + myPreparedStatementStrings.addActual(sql); throwStatementExceptionIfAny(); - return myPreparedStatement; + return (PreparedStatement) myPreparedStatements.remove(0); } public PreparedStatement prepareStatement( @@ -146,9 +145,12 @@ myRollbackCalls.inc(); } - public void setAutoCommit(boolean autoCommit) - throws SQLException { - throw new UnsupportedOperationException(); + public void setExpectedAutoCommit(boolean autoCommit) { + myAutoCommit.setExpected(autoCommit); + } + + public void setAutoCommit(boolean autoCommit) throws SQLException { + myAutoCommit.setActual(autoCommit); } public void setCatalog(String catalog) throws SQLException { |