db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1309244 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting: functionTests/tests/largedata/LobLimitsTest.java junit/SystemPropertyTestSetup.java
Date Wed, 04 Apr 2012 04:50:12 GMT
Author: mamta
Date: Wed Apr  4 04:50:12 2012
New Revision: 1309244

URL: http://svn.apache.org/viewvc?rev=1309244&view=rev
Log:
DerbyDERBY-5663 Getting NPE when trying to set derby.language.logStatementText property to
true inside a junit suite.

It is possible that the same instance of SystemPropertyTestSetup decorator is used more than
once. In such a case, nulling out the oldValues in tearDown method can cause a null pointer
exception in the subsequent use of the same SystemPropertyTestSetup. The right thing to do
is to initialize oldValues to new Properties object everytime SystemPropertyTestSetup.setUp
gets used. In order to do this, we are removing the initialization of oldValues from the constructor
and putting it in setUp method.

Additionally, we do not want to null out newValues in tearDown method because the subsequent
use of same SystemPropertyTestSetup instance will loose the new values requested by the user
of the decorator. Because of this, we will not null newValues in tearDown anymore.

Existing junit All suite and derbyall ran fine with these changes.


Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/largedata/LobLimitsTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SystemPropertyTestSetup.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/largedata/LobLimitsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/largedata/LobLimitsTest.java?rev=1309244&r1=1309243&r2=1309244&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/largedata/LobLimitsTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/largedata/LobLimitsTest.java
Wed Apr  4 04:50:12 2012
@@ -36,6 +36,7 @@ import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
+import java.util.Properties;
 
 import junit.framework.Test;
 
@@ -45,6 +46,7 @@ import org.apache.derbyTesting.junit.Sup
 import org.apache.derbyTesting.junit.TestConfiguration;
 import org.apache.derbyTesting.functionTests.util.PrivilegedFileOpsForTests;
 import org.apache.derbyTesting.junit.JDBC;
+import org.apache.derbyTesting.junit.SystemPropertyTestSetup;
 
 /**
  * This test is part of the "largedata" suite because this test tests data for
@@ -132,6 +134,11 @@ public class LobLimitsTest extends BaseJ
      * @return a test suite
      */
     static Test baseSuite(final int biggestSize, final int bigSize) {
+    	//Run the suite with following properties in case we run into lock
+    	// time out issues. It will help debug the problem if timeouts occur.
+        Properties sysprops = new Properties();
+        sysprops.setProperty("derby.locks.deadlockTrace", "true");
+        sysprops.setProperty("derby.locks.monitor", "true");
         // Some of the test cases depend on certain other test cases to run
         // first, so force the test cases to run in lexicographical order.
         Test suite = new CleanDatabaseTestSetup(
@@ -141,6 +148,7 @@ public class LobLimitsTest extends BaseJ
                 setupTables(s, biggestSize, bigSize);
             }
         };
+        suite = new SystemPropertyTestSetup(suite,sysprops);
 
         return new SupportFilesSetup(suite);
     }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SystemPropertyTestSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SystemPropertyTestSetup.java?rev=1309244&r1=1309243&r2=1309244&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SystemPropertyTestSetup.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SystemPropertyTestSetup.java
Wed Apr  4 04:50:12 2012
@@ -51,7 +51,6 @@ public class SystemPropertyTestSetup ext
 	{
 		super(test);
 		this.newValues = newValues;
-		this.oldValues = new Properties();
 		this.staticProperties = staticProperties;
 	}
 
@@ -67,7 +66,6 @@ public class SystemPropertyTestSetup ext
 	{
 		super(test);
 		this.newValues = newValues;
-		this.oldValues = new Properties();
 		this.staticProperties = false;
 	}
 	/**
@@ -77,6 +75,15 @@ public class SystemPropertyTestSetup ext
     protected void setUp()
     throws java.lang.Exception
     {
+    	//DERBY-5663 Getting NPE when trying to set 
+    	// derby.language.logStatementText property to true inside a junit 
+    	// suite.
+    	//The same instance of SystemPropertyTestSetup can be used again
+    	// and hence we want to make sure that oldValues is not null as set
+    	// in the tearDown() method. If we leave it null, we will run into NPE
+    	// during the tearDown of SystemPropertyTestSetup during the 
+    	// decorator's reuse.
+		this.oldValues = new Properties();
     	// shutdown engine so static properties take effect
         // shutdown the engine before setting the properties. this
         // is because the properties may change authentication settings
@@ -106,7 +113,6 @@ public class SystemPropertyTestSetup ext
     	// shutdown engine to restore any static properties
     	if (staticProperties)
     		TestConfiguration.getCurrent().shutdownEngine();
-        newValues = null;
         oldValues = null;
     }
     



Mime
View raw message