db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1330196 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit: BaseJDBCTestSetup.java DatabasePropertyTestSetup.java TestConfiguration.java
Date Wed, 25 Apr 2012 11:18:51 GMT
Author: kahatlen
Date: Wed Apr 25 11:18:51 2012
New Revision: 1330196

URL: http://svn.apache.org/viewvc?rev=1330196&view=rev
Log:
DERBY-5705: Authorization decorators don't null out connections when done

- Callers that override DatabasePropertyTestSetup.tearDown() with an
  empty method are replaced by calls to getNoTeardownInstance().

- Make the tearDown() method in decorators returned by
  getNoTeardownInstance() close and null out the reference to the
  default connection.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestSetup.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DatabasePropertyTestSetup.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestSetup.java?rev=1330196&r1=1330195&r2=1330196&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestSetup.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestSetup.java
Wed Apr 25 11:18:51 2012
@@ -90,7 +90,15 @@ public abstract class BaseJDBCTestSetup
     protected void tearDown()
     throws java.lang.Exception
     {
-    	JDBC.cleanup(conn);
+        clearConnection();
+    }
+
+    /**
+     * Close the default connection and null out the reference to it.
+     * Typically only called from {@code tearDown()}.
+     */
+    void clearConnection() throws SQLException {
+        JDBC.cleanup(conn);
         conn = null;
     }
 }
\ No newline at end of file

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DatabasePropertyTestSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DatabasePropertyTestSetup.java?rev=1330196&r1=1330195&r2=1330196&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DatabasePropertyTestSetup.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DatabasePropertyTestSetup.java
Wed Apr 25 11:18:51 2012
@@ -192,12 +192,16 @@ public class DatabasePropertyTestSetup e
         return test;
     }
 
-    private static DatabasePropertyTestSetup getNoTeardownInstance(
+    static DatabasePropertyTestSetup getNoTeardownInstance(
         Test test, Properties p, boolean staticp)
     {
         return new DatabasePropertyTestSetup(test, p, staticp) {
                 protected void tearDown()
                         throws java.lang.Exception {
+                    // We don't want to reset the properties, but we should
+                    // still clear the reference to the default connection to
+                    // allow it to be garbage collected.
+                    clearConnection();
                 }
             };
     }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java?rev=1330196&r1=1330195&r2=1330196&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
Wed Apr 25 11:18:51 2012
@@ -911,11 +911,8 @@ public final class TestConfiguration {
         // reset it.
         final Properties sqlAuth = new Properties();
         sqlAuth.setProperty("derby.database.sqlAuthorization", "true");
-        Test setSQLAuthMode = new DatabasePropertyTestSetup(test,
-                sqlAuth, true) {
-            protected void tearDown() {
-            }
-        };
+        Test setSQLAuthMode = DatabasePropertyTestSetup.getNoTeardownInstance(
+                test, sqlAuth, true);
         
         return changeUserDecorator(
             new DatabaseChangeSetup(setSQLAuthMode, DEFAULT_DBNAME_SQL, DEFAULT_DBNAME_SQL,
true),
@@ -939,11 +936,8 @@ public final class TestConfiguration {
         // reset it.
         final Properties sqlAuth = new Properties();
         sqlAuth.setProperty("derby.database.sqlAuthorization", "true");
-        Test setSQLAuthMode = new DatabasePropertyTestSetup(test,
-                                                            sqlAuth, true) {
-                protected void tearDown() { }
-            };
-
+        Test setSQLAuthMode = DatabasePropertyTestSetup.getNoTeardownInstance(
+                test, sqlAuth, true);
 
         setSQLAuthMode = new DatabaseChangeSetup(
             new DropDatabaseSetup(setSQLAuthMode, DEFAULT_DBNAME_SQL) {



Mime
View raw message