You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by di...@apache.org on 2004/05/01 14:52:23 UTC
cvs commit: jakarta-commons/dbcp/src/test/org/apache/commons/dbcp TesterConnection.java
dirkv 2004/05/01 05:52:23
Modified: dbcp/src/test/org/apache/commons/dbcp TesterConnection.java
Log:
If a failure exception is set on the test connection implementation then each method will fail,
this is used to simulate isClosed() method failure
Revision Changes Path
1.13 +15 -1 jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TesterConnection.java
Index: TesterConnection.java
===================================================================
RCS file: /home/cvs/jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TesterConnection.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- TesterConnection.java 7 Mar 2004 10:54:55 -0000 1.12
+++ TesterConnection.java 1 May 2004 12:52:23 -0000 1.13
@@ -43,6 +43,7 @@
protected SQLWarning warnings = null;
protected String username = null;
protected String password = null;
+ protected Exception failure;
public TesterConnection(String username, String password) {
this.username = username;
@@ -112,6 +113,7 @@
}
public boolean isClosed() throws SQLException {
+ checkFailure();
return !_open;
}
@@ -188,7 +190,19 @@
if(!_open) {
throw new SQLException("Connection is closed.");
}
+ checkFailure();
}
+
+ protected void checkFailure() throws SQLException {
+ if (failure != null) {
+ throw new SQLNestedException("TesterConnection failure", failure);
+ }
+ }
+
+ public void setFailure(Exception failure) {
+ this.failure = failure;
+ }
+
// ------------------- JDBC 3.0 -----------------------------------------
// Will be commented by the build process on a JDBC 2.0 system
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org