db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1004609 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LargeDataLocksTest.java
Date Tue, 05 Oct 2010 10:51:23 GMT
Author: kahatlen
Date: Tue Oct  5 10:51:23 2010
New Revision: 1004609

URL: http://svn.apache.org/viewvc?rev=1004609&view=rev
Log:
Don't compress tables in CleanDatabaseTestSetup.
SYSCS_INPLACE_COMPRESS_TABLE is not supported yet.

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

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LargeDataLocksTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LargeDataLocksTest.java?rev=1004609&r1=1004608&r2=1004609&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LargeDataLocksTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LargeDataLocksTest.java
Tue Oct  5 10:51:23 2010
@@ -27,6 +27,7 @@ import java.io.UnsupportedEncodingExcept
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
 import java.sql.SQLException;
 import java.sql.Statement;
 
@@ -69,7 +70,7 @@ public class LargeDataLocksTest extends 
         }
         assertEquals(38000, numChars);
         rs.close();
-        assertEquals(0, countLocks());
+        assertLockCount(0);
         commit();
     }
 
@@ -87,7 +88,7 @@ public class LargeDataLocksTest extends 
         byte[] value = rs.getBytes(1);
         assertEquals(38000, value.length);
         rs.close();
-        assertEquals(0, countLocks());
+        assertLockCount(0);
         commit();
 
     }
@@ -113,7 +114,7 @@ public class LargeDataLocksTest extends 
         }
         assertEquals(38000, numBytes);
         rs.close();
-        assertEquals(0, countLocks());
+        assertLockCount(0);
         commit();
     }
 
@@ -133,30 +134,45 @@ public class LargeDataLocksTest extends 
         String value = rs.getString(1);
         assertEquals(38000, value.length());
         rs.close();
-        assertEquals(0, countLocks());
+        assertLockCount(0);
         commit();
     }
 
     /**
-     * Create a new connection and count the number of locks held.
-     * 
-     * @return number of locks held
-     * 
-     * @throws SQLException
+     * Assert that the lock table contains a certain number of locks. Fail and
+     * dump the contents of the lock table if the lock table does not contain
+     * the expected number of locks.
+     *
+     * @param expected the expected number of locks
      */
-    public int countLocks() throws SQLException {
+    private void assertLockCount(int expected) throws SQLException {
+        // Count the locks in a new connection so that we don't accidentally
+        // make the default connection auto-commit and release locks.
         Connection conn = openDefaultConnection();
-        String sql;
         Statement stmt = conn.createStatement();
+        ResultSet rs = stmt.executeQuery("select * from syscs_diag.lock_table");
+        ResultSetMetaData meta = rs.getMetaData();
+
+        // Build an error message with the contents of the lock table as
+        // we walk through it.
+        StringBuffer msg = new StringBuffer(
+                "Unexpected lock count. Contents of lock table:\n");
+        int count;
+        for (count = 0; rs.next(); count++) {
+            msg.append(count + 1).append(": ");
+            for (int col = 1; col <= meta.getColumnCount(); col++) {
+                String name = meta.getColumnName(col);
+                Object val = rs.getObject(col);
+                msg.append(name).append('=').append(val).append(' ');
+            }
+            msg.append('\n');
+        }
 
-        sql = "Select count(*) from new org.apache.derby.diag.LockTable() as LT";
-        ResultSet lockrs = stmt.executeQuery(sql);
-        lockrs.next();
-        int count = lockrs.getInt(1);
-        lockrs.close();
+        rs.close();
         stmt.close();
         conn.close();
-        return count;
+
+        assertEquals(msg.toString(), expected, count);
     }
 
     public static Test baseSuite(String name) {



Mime
View raw message