You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2010/11/09 11:17:12 UTC

svn commit: r1032907 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests: jdbcapi/BlobClob4BlobTest.java lang/DeadlockModeTest.java

Author: kahatlen
Date: Tue Nov  9 10:17:12 2010
New Revision: 1032907

URL: http://svn.apache.org/viewvc?rev=1032907&view=rev
Log:
DERBY-4884 (partial) DatabasePropertyTestSetup cannot change static properties in encrypted databases

Make DeadlockModeTest and BlobClob4BlobTest propagate timeout settings
to the encrypted database. Also make DeadlockModeTest actually use the
encrypted database when running within the encryption decorator.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/BlobClob4BlobTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DeadlockModeTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/BlobClob4BlobTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/BlobClob4BlobTest.java?rev=1032907&r1=1032906&r2=1032907&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/BlobClob4BlobTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/BlobClob4BlobTest.java Tue Nov  9 10:17:12 2010
@@ -3037,17 +3037,23 @@ public class BlobClob4BlobTest extends B
 
     public static Test suite() {
         TestSuite suite = new TestSuite("BlobClob4BlobTest");
+        suite.addTest(baseSuite("embedded"));
         suite.addTest(
-                TestConfiguration.embeddedSuite(BlobClob4BlobTest.class));
-        suite.addTest(
-                TestConfiguration.clientServerSuite(BlobClob4BlobTest.class));
+                TestConfiguration.clientServerDecorator(baseSuite("client")));
+
         // JSR169 does not have encryption support
         if (JDBC.vmSupportsJDBC3())
         {
-            TestSuite encSuite = new TestSuite ("BlobClob4BlobTest:encrypted");
-            encSuite.addTestSuite (BlobClob4BlobTest.class);
+            Test encSuite = baseSuite("encrypted");
             suite.addTest(Decorator.encryptedDatabase (encSuite));
         }
+
+        return suite;
+    }
+
+    private static Test baseSuite(String name) {
+        TestSuite suite = new TestSuite(
+                BlobClob4BlobTest.class, "BlobClob4BlobTest:" + name);
         return new CleanDatabaseTestSetup(
                 DatabasePropertyTestSetup.setLockTimeouts(suite, 2, 4));
     }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DeadlockModeTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DeadlockModeTest.java?rev=1032907&r1=1032906&r2=1032907&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DeadlockModeTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DeadlockModeTest.java Tue Nov  9 10:17:12 2010
@@ -32,7 +32,6 @@ import org.apache.derbyTesting.junit.Cle
 import org.apache.derbyTesting.junit.DatabasePropertyTestSetup;
 import org.apache.derbyTesting.junit.Decorator;
 import org.apache.derbyTesting.junit.JDBC;
-import org.apache.derbyTesting.junit.TestConfiguration;
 
 /**
  * This tests for deadlock which can occur if two threads get a 
@@ -84,11 +83,12 @@ public class DeadlockModeTest extends Ba
      * This method creates THREAD_COUNT threads which will all try to
      * update the same table 
      */
-    private void createThreads(Thread [] t) {
+    private void createThreads(Thread [] t) throws SQLException {
         for (int i = 0; i < THREAD_COUNT; i++)
-        {   
+        {
+            final Connection c = openDefaultConnection();
             t[i] = new Thread(new Runnable() {
-                public void run() {threadWorker(); }});
+                public void run() {threadWorker(c); }});
             t[i].start();
         }
     }
@@ -117,17 +117,9 @@ public class DeadlockModeTest extends Ba
      * can not throw exceptions, therefore we make a "bogus"
      * assertNull(string message,Exception e) call.
      */
-    private void threadWorker() {
-        Connection threadConnection = null;
-                
+    private void threadWorker(Connection threadConnection) {
         try {
             synchronized (syncObject) {
-                
-                /* If a connection hasn't been opened for this thread, open one */
-                if (threadConnection == null){
-                    threadConnection = openDefaultConnection();
-                }
-                
                 /* A new thread started, so we increment the counter */
                 startedCount++;
                 
@@ -152,6 +144,8 @@ public class DeadlockModeTest extends Ba
                 stmt.executeUpdate("update t set i = 456 where i = 456");
                 threadConnection.commit();
             }
+
+            threadConnection.close();
         } catch (Exception e) {
             synchronized(syncObject){
                 listExceptions.add(e);
@@ -182,30 +176,6 @@ public class DeadlockModeTest extends Ba
         };
     } 
     
-    protected static Test encryptedBaseSuite(String name) {
-        TestSuite suite = new TestSuite(name);
-        suite.addTestSuite(DeadlockModeTest.class);
-        
-        return new CleanDatabaseTestSetup(
-                DatabasePropertyTestSetup.setLockTimeouts(Decorator.encryptedDatabase(suite), 2, 4)) 
-        {
-            /**
-             * Creates the tables used in the test cases.
-             * @exception SQLException if a database error occurs
-             */
-            protected void decorateSQL(Statement stmt) throws SQLException
-            {
-                stmt.execute("create table t (i int)");
-                
-                stmt.executeUpdate("insert into t values (1956)");
-        
-                stmt.executeUpdate("insert into t values (180)");
-        
-                stmt.executeUpdate("insert into t values (3)");
-            }
-        };
-    } 
-    
     public static Test suite() {
         TestSuite suite = new TestSuite("DeadlockModeTest ");
         suite.addTest(
@@ -214,9 +184,8 @@ public class DeadlockModeTest extends Ba
         
         /* JSR169 does not have encryption support */
         if ( JDBC.vmSupportsJDBC3() ) {
-            suite.addTest(
-                    encryptedBaseSuite("DeadlockModeTest:encrypted")
-                    );
+            suite.addTest(Decorator.encryptedDatabase(
+                    baseSuite("DeadlockModeTest:encrypted")));
         }
 
         return suite;