From: Steve F. <sm...@us...> - 2001-08-11 20:42:08
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/sql In directory usw-pr-cvs1:/tmp/cvs-serv1930/core/com/mockobjects/sql Modified Files: MockConnection.java Log Message: more examples, plus some tidy up Index: MockConnection.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/sql/MockConnection.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MockConnection.java 2001/08/05 23:33:10 1.2 --- MockConnection.java 2001/08/11 20:42:05 1.3 *************** *** 14,18 **** private ExpectationValue myPrepareStatementString = new ExpectationValue("MockConnection.preparedStatementString"); private PreparedStatement myPreparedStatement; ! private SQLException myPrepareException = null; private ExpectationCounter myCreateStatementCalls = new ExpectationCounter("MockConnection.createStatement"); --- 14,18 ---- private ExpectationValue myPrepareStatementString = new ExpectationValue("MockConnection.preparedStatementString"); private PreparedStatement myPreparedStatement; ! private SQLException myStatementException = null; private ExpectationCounter myCreateStatementCalls = new ExpectationCounter("MockConnection.createStatement"); *************** *** 51,56 **** } ! public void setupThrowExceptionOnPrepare(SQLException exception) { ! myPrepareException = exception; } --- 51,56 ---- } ! public void setupThrowExceptionOnPrepareOrCreate(SQLException exception) { ! myStatementException = exception; } *************** *** 68,71 **** --- 68,72 ---- public Statement createStatement() throws SQLException { myCreateStatementCalls.inc(); + throwStatementExceptionIfAny(); return myStatement; } *************** *** 130,136 **** public PreparedStatement prepareStatement(String sql) throws SQLException { myPrepareStatementString.setActual(sql); ! if (null != myPrepareException) { ! throw myPrepareException; ! } return myPreparedStatement; } --- 131,135 ---- public PreparedStatement prepareStatement(String sql) throws SQLException { myPrepareStatementString.setActual(sql); ! throwStatementExceptionIfAny(); return myPreparedStatement; } *************** *** 168,171 **** --- 167,176 ---- public void setTypeMap(Map map) throws SQLException { throw new UnsupportedOperationException(); + } + + private void throwStatementExceptionIfAny() throws SQLException { + if (null != myStatementException) { + throw myStatementException; + } } |