db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1136717 - in /db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting: functionTests/tests/memory/TriggerTests.java junit/BaseJDBCTestCase.java
Date Thu, 16 Jun 2011 22:42:04 GMT
Author: mamta
Date: Thu Jun 16 22:42:04 2011
New Revision: 1136717

URL: http://svn.apache.org/viewvc?rev=1136717&view=rev
Log:
DERBY-5279 Adding following code to catch any exception other than table does not exist. If
the caught error is derby lock time out then we want to know what is the lock out property
set to. It should be set to default which is 60 but it is possible that some other test has
changed that setting and forgot to revert it back to default before that test finished. The
information about lock timeout will help us resolve DERBY-5279


Modified:
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/memory/TriggerTests.java
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java

Modified: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/memory/TriggerTests.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/memory/TriggerTests.java?rev=1136717&r1=1136716&r2=1136717&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/memory/TriggerTests.java
(original)
+++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/memory/TriggerTests.java
Thu Jun 16 22:42:04 2011
@@ -241,9 +241,27 @@ public class TriggerTests extends BaseJD
 	 * @throws SQLException
 	 */
 	public void basicSetup() throws SQLException{
-        dropTable("TABLE1");
-        dropTable("TABLE2");
-        dropTable("TABLE3");
+		try {
+	        dropTable("TABLE1");
+	        dropTable("TABLE2");
+	        dropTable("TABLE3");
+		} catch (SQLException sqle) {
+			//DERBY-5279 Adding following code to catch any exception other 
+			// than table does not exist. If the caught error is derby
+			// lock time out then we want to know what is the lock out
+			// property set to. It should be set to default which is
+			// 60 but it is possible that some other test has changed
+			// that setting and forgot to revert it back to default
+			// before that test finished. The information about
+			// lock timeout will help us resolve DERBY-5279
+            assertSQLState("40XL1", sqle);	
+            //if we come here, then it means that we got lock timeout error
+            // In such a case, we want to see what is the current lock timeout
+            // setting when this test is getting run. The assetEquals following
+            // will always fails because we are comparing 1=2. We are doing
+            // this so that the lock out property will get printed.
+            assertEquals("lock timeout is set to " + getDatabaseProperty("derby.locks.deadlockTimeout"),
"1", "2");
+		}
 
         Statement s = createStatement();
 		try {

Modified: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java?rev=1136717&r1=1136716&r2=1136717&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java
(original)
+++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java
Thu Jun 16 22:42:04 2011
@@ -502,6 +502,26 @@ public abstract class BaseJDBCTestCase
     public static boolean usingDerbyNet() {
         return TestConfiguration.getCurrent().getJDBCClient().isDB2Client();
     }
+    
+    /**
+     * Get the value of a database property using the default connection 
+     * @param propertyName Property key
+     * @return null if the property is not set at the database level,
+     * otherwise the value of the property.
+     * @throws SQLException
+     */
+    public String getDatabaseProperty(String propertyName) throws SQLException
+    {
+        PreparedStatement ps =  prepareStatement(
+             "VALUES SYSCS_UTIL.SYSCS_GET_DATABASE_PROPERTY(?)");
+        
+        ps.setString(1, propertyName);
+        ResultSet rs = ps.executeQuery();
+        
+        rs.next();
+        
+        return rs.getString(1);
+    }
 
     /**
      * Assert equality between two <code>Blob</code> objects.



Mime
View raw message