From: Piran M. <pmo...@La...> - 2002-11-05 15:11:49
|
I'm trying to test some code that make sure something is done on a non-auto-committing connection. I.e., the code does this: if ( myConnection.getAutoCommit() == true ) { try { myConnection.setAutoCommit(false); doCode(); } finally { myConnection.setAutoCommit(true); } } else { doCode(); } But you've not implemented getAutoCommit. Below is a diff -u for the addition. BCNU, Piran Montford. --- CommonMockConnection.java Tue Nov 5 14:57:09 2002 +++ CommonMockConnection.java_old Tue Nov 5 15:00:58 2002 @@ -97,7 +97,7 @@ // -------------------------------------------------------------------- fields - private ExpectationValue myAutoCommitExpectation = + private ExpectationValue myAutoCommit = new ExpectationValue("CommonMockConnection.setAutoCommit"); private ExpectationCounter myCloseCalls = @@ -111,8 +111,6 @@ private boolean myIsClosed; - private boolean myAutoCommit = true; - private SQLException myCloseException; private SQLException myIsClosedException; @@ -154,7 +152,7 @@ * Register the anticipated value for autoCommit during testing. */ public void setExpectedAutoCommit(boolean autoCommit) { - myAutoCommitExpectation.setExpected(autoCommit); + myAutoCommit.setExpected(autoCommit); } @@ -341,20 +339,10 @@ /** * Stores the value passed for comparison with the value passed * to setupAutoCommit. - * The validate method will report any discrepency to the value - * set with {@link setExpectedAutoCommit} + * The validate method will report any discrepency. */ public void setAutoCommit(boolean autoCommit) throws SQLException { - myAutoCommitExpectation.setActual(autoCommit); - myAutoCommit = autoCommit; - } - - /** - * Gets the value last value set with {@link setAutoCommit}. - * Defaults to true. - */ - public boolean getAutoCommit() throws SQLException { - return myAutoCommit; + myAutoCommit.setActual(autoCommit); } // ------------------------------------------------------------ notImplemented @@ -378,6 +366,14 @@ } /** + * Calls notImplemented. Returns false. + */ + public boolean getAutoCommit() throws SQLException { + notImplemented(); + return false; + } + + /** * Calls notImplemented. Returns null. */ public String getCatalog() throws SQLException { ------------------------------ This e-mail is intended for the named addressee only. It may contain confidential and/or privileged information. If you have received this message in error, please let us know and then delete this message from your system. You should not copy the message, use it for any purpose or disclose its contents to anyone. ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ |