db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r498816 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting: functionTests/tests/upgradeTests/UpgradeRun.java junit/JDBCClient.java junit/JDBCClientSetup.java junit/TestConfiguration.java
Date Mon, 22 Jan 2007 21:26:43 GMT
Author: djd
Date: Mon Jan 22 13:26:42 2007
New Revision: 498816

URL: http://svn.apache.org/viewvc?view=rev&rev=498816
Log:
DERBY-2217 (partial) Change the upgrade JUnit test to use the non-JDBC 4 data sources
when running in Java SE 6 and against old Derby releases that do not have those data sources.

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCClientSetup.java  
(with props)
Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCClient.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/upgradeTests/UpgradeRun.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java?view=diff&rev=498816&r1=498815&r2=498816
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java
Mon Jan 22 13:26:42 2007
@@ -109,7 +109,9 @@
                     "Upgrade Phase: " + UpgradeChange.PHASES[phase],
                     phase, version);
             
-            suite.addTest(new PhaseChanger(phaseTests, phase, loader, version));
+            Test phaseSet = new PhaseChanger(phaseTests, phase, loader, version);
+            phaseSet = handleJavaSE6(phase, version, phaseSet);
+            suite.addTest(phaseSet);
         }
           
         TestSetup setup = TestConfiguration.singleUseDatabaseDecorator(suite);
@@ -252,5 +254,42 @@
         // Specify null for parent class loader to avoid mixing up 
         // jars specified in the system classpath
         return new URLClassLoader(url, null);       
+    }
+    
+    
+    /**
+     * When running against certains old releases in Java SE 6
+     * we need to setup the connections to the old
+     * database to not use the specific JDBC 4
+     * datasources (e.g. EmbeddedDataSource40).
+     * (Since they don't exist in the old release).
+     *
+     */
+    private static Test handleJavaSE6(int phase, int[] version, Test test)
+    {
+        // 
+        // we need to tell the JUnit infratructure not to
+        // look for the  40 datasources (e.g. EmbeddedDataSource40)
+        boolean oldReleaseNeedsJDBC3 = false;
+        switch (phase)
+        {
+        case UpgradeChange.PH_CREATE:
+        case UpgradeChange.PH_POST_SOFT_UPGRADE:
+            
+            // Pre 10.2.2.0 need jdbc 3 drivers.
+            if (version[0] == 10 && version[1] < 3)
+            {
+                if (version[1] < 2 || version[2] < 2)
+                   oldReleaseNeedsJDBC3 = true;
+            }
+            break;
+        default:
+            break;
+        }
+        
+        if (oldReleaseNeedsJDBC3) {
+            return TestConfiguration.forceJDBC3Embedded(test);
+        }
+        return test;
     }
 }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCClient.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCClient.java?view=diff&rev=498816&r1=498815&r2=498816
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCClient.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCClient.java Mon Jan
22 13:26:42 2007
@@ -31,7 +31,7 @@
     /**
      * The embedded JDBC client.
      */
-    private static final JDBCClient EMBEDDED_30= new JDBCClient(
+    static final JDBCClient EMBEDDED_30= new JDBCClient(
             "Embedded_30", 
             "org.apache.derby.jdbc.EmbeddedDriver", 
             "org.apache.derby.jdbc.EmbeddedDataSource", 
@@ -42,7 +42,7 @@
     /**
      * The embedded JDBC client for JDBC 4.0.
      */
-    private static final JDBCClient EMBEDDED_40 = new JDBCClient(
+    static final JDBCClient EMBEDDED_40 = new JDBCClient(
             "Embedded_40", 
             "org.apache.derby.jdbc.EmbeddedDriver", 
             "org.apache.derby.jdbc.EmbeddedDataSource40", 

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCClientSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCClientSetup.java?view=auto&rev=498816
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCClientSetup.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCClientSetup.java Mon
Jan 22 13:26:42 2007
@@ -0,0 +1,44 @@
+/*
+ *
+ * Derby - Class org.apache.derbyTesting.junit.JDBCClientSetup
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, 
+ * software distributed under the License is distributed on an 
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
+ * either express or implied. See the License for the specific 
+ * language governing permissions and limitations under the License.
+ */
+package org.apache.derbyTesting.junit;
+
+import junit.framework.Test;
+
+/**
+ * Change to a specified JDBCClient configuration based upon the
+ * current configuration at setup time. Previous configuration
+ * is restored at tearDown time.
+ *
+ */
+final class JDBCClientSetup extends ChangeConfigurationSetup {
+
+    private final JDBCClient client;
+     
+    public JDBCClientSetup(Test test, JDBCClient client) {
+        super(test);
+        this.client = client;
+    }
+
+    TestConfiguration getNewConfiguration(TestConfiguration old) {
+               
+        return new TestConfiguration(old, client,
+                    old.getHostName(), old.getPort());
+    }
+}

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCClientSetup.java
------------------------------------------------------------------------------
    svn:eol-style = native

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?view=diff&rev=498816&r1=498815&r2=498816
==============================================================================
--- 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
Mon Jan 22 13:26:42 2007
@@ -369,6 +369,23 @@
     }
     
     /**
+     * Returns a decorator that forces the JDBC 3 embedded client  in
+     * a Java SE 6/JDBC 4 environment. The only difference is that
+     * the DataSource class names will be the "old" JDBC 3 versions
+     * and not the JDBC 4 specific ones.
+     * that
+     * @param test
+     * @return
+     */
+    public static Test forceJDBC3Embedded(Test test)
+    {
+        if (JDBC.vmSupportsJDBC4()) {
+            test = new JDBCClientSetup(test, JDBCClient.EMBEDDED_30);
+        }
+        return test;
+    }
+    
+    /**
      * Default embedded configuration
      *
      */



Mime
View raw message