db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r434257 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting: functionTests/tests/jdbc4/ functionTests/tests/store/ junit/
Date Thu, 24 Aug 2006 00:06:34 GMT
Author: djd
Date: Wed Aug 23 17:06:33 2006
New Revision: 434257

URL: http://svn.apache.org/viewvc?rev=434257&view=rev
Log:
DERBY-1555 (partial) Remove access and use of static variables to store the current test configuration.
Changed to use a ThreadLocal private to TestConfiguration and access to the current configuration
is through utility methods in the base classes or TestConfiguration.getCurrent().

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/AutoloadBooting.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/AutoloadTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ClosedObjectTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/UnsupportedVetter.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/VerifySignatures.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BootAllTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestSetup.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/AutoloadBooting.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/AutoloadBooting.java?rev=434257&r1=434256&r2=434257&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/AutoloadBooting.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/AutoloadBooting.java
Wed Aug 23 17:06:33 2006
@@ -348,7 +348,7 @@
 	private	void	loadNetworkClientDriver()
 		throws Exception
 	{
-		boolean		isAutoloading = !CONFIG.autoloading();
+		boolean		isAutoloading = !getTestConfiguration().autoloading();
 		
 		//
 		// Forcibly load the network client if we are not autoloading it.

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/AutoloadTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/AutoloadTest.java?rev=434257&r1=434256&r2=434257&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/AutoloadTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/AutoloadTest.java
Wed Aug 23 17:06:33 2006
@@ -101,7 +101,7 @@
 		// We expect that the connection to the database will fail for
 		// one reason or another.
 		//
-		if ( CONFIG.autoloading() )
+		if ( getTestConfiguration().autoloading() )
 		{
 			println( "We ARE autoloading..." );
 
@@ -136,12 +136,12 @@
 	private	void	failToConnect( String expectedSQLState )
 		throws Exception
 	{
-		String			connectionURL = CONFIG.getJDBCUrl( NONEXISTENT_DATABASE );
+		String			connectionURL = getTestConfiguration().getJDBCUrl( NONEXISTENT_DATABASE );
 		Properties		properties = new Properties();
 		SQLException 	se = null;
 
-		properties.put( "user", CONFIG.getUserName() );
-		properties.put( "password", CONFIG.getUserPassword() );
+		properties.put( "user", getTestConfiguration().getUserName() );
+		properties.put( "password", getTestConfiguration().getUserPassword() );
 
 		try {
 			println( "Attempting to connect with this URL: '" + connectionURL + "'" );

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ClosedObjectTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ClosedObjectTest.java?rev=434257&r1=434256&r2=434257&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ClosedObjectTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ClosedObjectTest.java
Wed Aug 23 17:06:33 2006
@@ -42,6 +42,7 @@
 import junit.framework.TestSuite;
 import org.apache.derbyTesting.functionTests.util.TestDataSourceFactory;
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.TestConfiguration;
 
 /**
  * Test that all methods on <code>ResultSet</code>,
@@ -698,8 +699,8 @@
          */
         protected Connection newConnection_() throws SQLException {
             DataSource ds = TestDataSourceFactory.getDataSource();
-            return ds.getConnection(CONFIG.getUserName(),
-                                    CONFIG.getUserPassword());
+            return ds.getConnection(TestConfiguration.getCurrent().getUserName(),
+                    TestConfiguration.getCurrent().getUserPassword());
         }
     }
 
@@ -727,8 +728,8 @@
         protected Connection newConnection_() throws SQLException {
             ConnectionPoolDataSource ds = TestDataSourceFactory.getConnectionPoolDataSource();
             PooledConnection pc =
-                ds.getPooledConnection(CONFIG.getUserName(),
-                                       CONFIG.getUserPassword());
+                ds.getPooledConnection(TestConfiguration.getCurrent().getUserName(),
+                        TestConfiguration.getCurrent().getUserPassword());
             return pc.getConnection();
         }
     }
@@ -755,8 +756,8 @@
          */
         protected Connection newConnection_() throws SQLException {
             XADataSource ds = TestDataSourceFactory.getXADataSource();
-            XAConnection xac = ds.getXAConnection(CONFIG.getUserName(),
-                                                  CONFIG.getUserPassword());
+            XAConnection xac = ds.getXAConnection(TestConfiguration.getCurrent().getUserName(),
+                    TestConfiguration.getCurrent().getUserPassword());
             return xac.getConnection();
         }
     }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/UnsupportedVetter.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/UnsupportedVetter.java?rev=434257&r1=434256&r2=434257&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/UnsupportedVetter.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/UnsupportedVetter.java
Wed Aug 23 17:06:33 2006
@@ -364,7 +364,7 @@
 	public	void	testSupportedMethods()
 		throws Exception
 	{
-		CONFIG.setVerbosity( true );
+        getTestConfiguration().setVerbosity( true );
 
 		HashSet<String>	vanishedMethodList = new HashSet<String>();
 		HashSet<String>	unsupportedList = new HashSet<String>();
@@ -418,7 +418,8 @@
 	{
 		ConnectionPoolDataSource	ds = TestDataSourceFactory.getConnectionPoolDataSource();
 		PooledConnection			pc = ds.getPooledConnection
-			(CONFIG.getUserName(), CONFIG.getUserPassword());
+			(getTestConfiguration().getUserName(),
+                    getTestConfiguration().getUserPassword());
 		Connection					conn = pc.getConnection();
 
 		vetObject( ds, unsupportedList, notUnderstoodList );
@@ -436,7 +437,8 @@
 	{
 		XADataSource				ds = TestDataSourceFactory.getXADataSource();
 		XAConnection				xaconn = ds.getXAConnection
-			(CONFIG.getUserName(), CONFIG.getUserPassword());
+			(getTestConfiguration().getUserName(),
+                    getTestConfiguration().getUserPassword());
 		Connection					conn = xaconn.getConnection();
 
 		vetObject( ds, unsupportedList, notUnderstoodList );

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/VerifySignatures.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/VerifySignatures.java?rev=434257&r1=434256&r2=434257&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/VerifySignatures.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/VerifySignatures.java
Wed Aug 23 17:06:33 2006
@@ -34,6 +34,7 @@
 import org.apache.derbyTesting.functionTests.util.TestUtil;
 import org.apache.derbyTesting.functionTests.util.TestDataSourceFactory;
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.TestConfiguration;
 
 /**
  * JUnit test which checks that all methods specified by the
@@ -110,7 +111,7 @@
         collectClassesFromConnectionPoolDataSource(classes);
         collectClassesFromXADataSource(classes);
         addClass(classes,
-                 DriverManager.getDriver(CONFIG.getJDBCUrl()).getClass(),
+                 DriverManager.getDriver(TestConfiguration.getCurrent().getJDBCUrl()).getClass(),
                  java.sql.Driver.class);
 
         TestSuite suite = new TestSuite();
@@ -151,8 +152,8 @@
         DataSource ds = TestDataSourceFactory.getDataSource();
         addClass(classes, ds.getClass(), javax.sql.DataSource.class);
         collectClassesFromConnection(ds.getConnection
-                                     (CONFIG.getUserName(),
-                                      CONFIG.getUserPassword()),
+                                     (TestConfiguration.getCurrent().getUserName(),
+                                             TestConfiguration.getCurrent().getUserPassword()),
                                      classes);
     }
 
@@ -173,8 +174,8 @@
                  cpds.getClass(), javax.sql.ConnectionPoolDataSource.class);
 
         PooledConnection pc =
-            cpds.getPooledConnection(CONFIG.getUserName(),
-                                     CONFIG.getUserPassword());
+            cpds.getPooledConnection(TestConfiguration.getCurrent().getUserName(),
+                    TestConfiguration.getCurrent().getUserPassword());
         addClass(classes, pc.getClass(), javax.sql.PooledConnection.class);
 
         collectClassesFromConnection(pc.getConnection(), classes);
@@ -196,8 +197,8 @@
         XADataSource xads = TestDataSourceFactory.getXADataSource();
         addClass(classes, xads.getClass(), javax.sql.XADataSource.class);
 
-        XAConnection xaconn = xads.getXAConnection(CONFIG.getUserName(),
-                                                   CONFIG.getUserPassword());
+        XAConnection xaconn = xads.getXAConnection(TestConfiguration.getCurrent().getUserName(),
+                TestConfiguration.getCurrent().getUserPassword());
         addClass(classes, xaconn.getClass(), javax.sql.XAConnection.class);
 
         collectClassesFromConnection(xaconn.getConnection(), classes);

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BootAllTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BootAllTest.java?rev=434257&r1=434256&r2=434257&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BootAllTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BootAllTest.java
Wed Aug 23 17:06:33 2006
@@ -37,8 +37,6 @@
  */
 public class BootAllTest  extends BaseJDBCTestCase {
 
-    /** JDBC Connection */
-    private Connection con;
     private Driver driver;
     private String databases[] = new String[] {"wombat1", "wombat2", "wombat3"};
     
@@ -57,16 +55,16 @@
      */
     public void setUp() throws Exception {
         for (int i = 0; i < databases.length; i++) {
-            con = openConnection(databases[i]);
+            Connection con = openConnection(databases[i]);
             con.close();
             try {
-                con = openConnection(databases[i] + ";shutdown=true");
+                openConnection(databases[i] + ";shutdown=true");
             } catch (SQLException se) {
                 assertEquals("Expected exception on setUp " + se.getSQLState(), 
                         DATABASE_SHUT_DOWN, se.getSQLState());
             }
         }
-        String url = CONFIG.getJDBCUrl("");
+        String url = getTestConfiguration().getJDBCUrl("");
         driver = DriverManager.getDriver(url);
         DriverManager.deregisterDriver(driver);
         try {
@@ -83,11 +81,11 @@
      * Shutdown all databases
      */
     public void tearDown() throws Exception {
-        String driverName = CONFIG.getJDBCClient().getJDBCDriverName();
+        String driverName = getTestConfiguration().getJDBCClient().getJDBCDriverName();
         Class.forName(driverName);
         println("Teardown of: " + getName());
         try {
-            con = openConnection(";shutdown=true");
+            openConnection(";shutdown=true");
         } catch (SQLException se) {
             assertEquals("Expected exception on tearDown " + se.getSQLState(), 
                     ALL_DATABASES_SHUT_DOWN, se.getSQLState());
@@ -111,8 +109,8 @@
 
         setSystemProperty("derby.system.bootAll", "true");
 
-        String driverName = CONFIG.getJDBCClient().getJDBCDriverName();
-        String url = CONFIG.getJDBCUrl("");
+        String driverName = getTestConfiguration().getJDBCClient().getJDBCDriverName();
+        String url = getTestConfiguration().getJDBCUrl("");
 
         Class.forName(driverName).newInstance();
         DriverManager.registerDriver(driver);

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java?rev=434257&r1=434256&r2=434257&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java Wed
Aug 23 17:06:33 2006
@@ -245,7 +245,7 @@
      *         <code>false</code> otherwise.
      */
      public static boolean usingEmbedded() {
-         return CONFIG.getJDBCClient().isEmbedded();
+         return TestConfiguration.getCurrent().getJDBCClient().isEmbedded();
      }
     
     /**
@@ -255,7 +255,7 @@
     *         <code>false</code> otherwise.
     */
     public static boolean usingDerbyNetClient() {
-        return CONFIG.getJDBCClient().isDerbyNetClient();
+        return TestConfiguration.getCurrent().getJDBCClient().isDerbyNetClient();
     }
     
     /**
@@ -265,7 +265,7 @@
     *         <code>false</code> otherwise.
     */
     public static boolean usingDerbyNet() {
-        return CONFIG.getJDBCClient().isDB2Client();
+        return TestConfiguration.getCurrent().getJDBCClient().isDB2Client();
     }
 
     /**

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=434257&r1=434256&r2=434257&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 Aug 23 17:06:33 2006
@@ -48,7 +48,7 @@
      */
     public final TestConfiguration getTestConfiguration()
     {
-    	return TestConfiguration.DERBY_TEST_CONFIG;
+    	return TestConfiguration.getCurrent();
     }
     
     /**

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java?rev=434257&r1=434256&r2=434257&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java Wed Aug
23 17:06:33 2006
@@ -37,15 +37,6 @@
  */
 public abstract class BaseTestCase
     extends TestCase {
-
-    /**
-     * Configuration for the test case.
-     * The configuration is created based on system properties.
-     *
-     * @see TestConfiguration
-     */
-    public static final TestConfiguration CONFIG = 
-        TestConfiguration.DERBY_TEST_CONFIG;
     
     /**
      * No argument constructor made private to enforce naming of test cases.
@@ -90,7 +81,7 @@
      */
     public final TestConfiguration getTestConfiguration()
     {
-    	return CONFIG;
+    	return TestConfiguration.getCurrent();
     }
     
     /**
@@ -106,7 +97,7 @@
      * @param text String to print
      */
     public static void println(final String text) {
-        if (CONFIG.isVerbose()) {
+        if (TestConfiguration.getCurrent().isVerbose()) {
             out.println("DEBUG: " + text);
         }
     }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.java?rev=434257&r1=434256&r2=434257&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.java
Wed Aug 23 17:06:33 2006
@@ -43,9 +43,6 @@
      */
     public NetworkServerTestSetup(Test test) {
         super(test);
-        
-        this.config = TestConfiguration.DERBY_TEST_CONFIG;
-        this.networkServerController = null;
     }
 
     /**
@@ -53,6 +50,8 @@
      */
     protected void setUp() throws Exception {
         
+        TestConfiguration config = TestConfiguration.getCurrent();
+        
         if (!config.getJDBCClient().isEmbedded()) {
             BaseTestCase.println("Starting network server:");
             networkServerController = new NetworkServerControl
@@ -87,9 +86,6 @@
     
     /* Network Server Control */
     private NetworkServerControl networkServerController;
-    
-    /* Configuration of test */
-    private final TestConfiguration config;
     
     /** Wait maximum 1 minute for server to start */
     private static final int WAIT_TIME = 60000;

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=434257&r1=434256&r2=434257&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 Aug 23 17:06:33 2006
@@ -1,4 +1,4 @@
-/*
+d/*
  *
  * Derby - Class TestConfiguration
  *
@@ -31,12 +31,41 @@
  * Class which holds information about the configuration of a Test.
  */
 public class TestConfiguration {
-    
+
     /**
      * Default Derby test configuration object.
      */
-    public static final TestConfiguration DERBY_TEST_CONFIG = 
+    private static final TestConfiguration DERBY_TEST_CONFIG = 
         new TestConfiguration(getSystemProperties());
+    
+    /**
+     * Current configuration is stored in a ThreadLocal to
+     * allow the potential for multiple tests to be running
+     * concurrently with different configurations.
+     */
+    private static final ThreadLocal CURRENT_CONFIG = new ThreadLocal() {
+        protected Object initialValue() {
+            return DERBY_TEST_CONFIG;
+        }
+    };
+   
+    /**
+     * Get this Thread's current configuraiton for running
+     * the tests.
+     * @return TestConfiguration to use.
+     */
+    public static TestConfiguration getCurrent() {
+        return (TestConfiguration) CURRENT_CONFIG.get();
+    }
+    
+    /**
+     * Set this Thread's current configuration for running tests.
+     * @param config Configuration to set it to.
+     */
+    private static void setCurrent(TestConfiguration config)
+    {
+        CURRENT_CONFIG.set(config);
+    }
     
     /**
      * This constructor creates a TestConfiguration from a Properties object.



Mime
View raw message