db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r764912 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests: OldVersions.java PhaseChanger.java UpgradeClassLoader.java UpgradeRun.java _Suite.java
Date Tue, 14 Apr 2009 18:23:15 GMT
Author: rhillegas
Date: Tue Apr 14 18:23:15 2009
New Revision: 764912

URL: http://svn.apache.org/viewvc?rev=764912&view=rev
Log:
-d

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/OldVersions.java
  (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeClassLoader.java
  (with props)
Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/PhaseChanger.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/_Suite.java

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/OldVersions.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/OldVersions.java?rev=764912&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/OldVersions.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/OldVersions.java
Tue Apr 14 18:23:15 2009
@@ -0,0 +1,244 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.upgradeTests.OldVersions
+
+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.functionTests.tests.upgradeTests;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.apache.derbyTesting.junit.BaseTestCase;
+import org.apache.derbyTesting.junit.JDBC;
+
+/**
+ * <p>
+ * Old versions visible to the upgrade machinery.
+ * </p>
+ */
+public class OldVersions
+{
+    private static int[][] VERSIONS =
+    {
+        {10, 0, 2, 1}, // 10.0.2.1 (incubator release)
+        {10, 1, 1, 0}, // 10.1.1.0 (Aug 3, 2005 / SVN 208786)
+        {10, 1, 2, 1}, // 10.1.2.1 (Nov 18, 2005 / SVN 330608)
+        {10, 1, 3, 1}, // 10.1.3.1 (Jun 30, 2006 / SVN 417277)
+        {10, 2, 1, 6}, // 10.2.1.6 (Oct 02, 2006 / SVN 452058)
+        {10, 2, 2, 0}, // 10.2.2.0 (Dec 12, 2006 / SVN 485682)
+        {10, 3, 1, 4}, // 10.3.1.4 (Aug 1, 2007 / SVN 561794)
+        {10, 3, 3, 0}, // 10.3.3.0 (May 12, 2008 / SVN 652961)
+        {10, 4, 1, 3}, // 10.4.1.3 (April 24, 2008 / SVN 648739)
+        {10, 4, 2, 0}, // 10.4.2.0 (September 05, 2008 / SVN 693552)
+    };
+
+    /**
+     * <p>
+     * Get an array of versions supported by this platform.
+     * </p>
+     */
+    public static int[][] getSupportedVersions()
+    {
+        int[][] old = null;
+        
+        if ( UpgradeRun.oldVersionsPath != null )
+        {
+            old = getVersions(UpgradeRun.oldVersionsPath);
+        }
+        
+        if ( old == null ) { old = VERSIONS; }
+
+        show( old );
+
+        return getSupportedVersions( old );
+    }
+
+    /**
+     * <p>
+     * Squeeze the supported versions out of any array of candidate versions.
+     * </p>
+     */
+    private static int[][] getSupportedVersions( int[][] old )
+    {
+        ArrayList list = new ArrayList();
+        int count = old.length;
+        
+        for (int i = 0; i < count; i++) {
+            // JSR169 support was only added with 10.1, so don't
+            // run 10.0 to later upgrade if that's what our jvm is supporting.
+            if ((JDBC.vmSupportsJSR169() && 
+                (old[i][0]==10) && (old[i][1]==0))) {
+                traceit("Skipping 10.0 on JSR169");
+                continue;
+            }
+            // Derby 10.3.1.4 does not boot on the phoneME advanced platform,
+            // (see DERBY-3176) so don't run upgrade tests in this combination.
+            if ( System.getProperty("java.vm.name").equals("CVM")
+                  && System.getProperty("java.vm.version").startsWith("phoneme")
+                  && old[i][0]==10 && old[i][1]==3 
+                  && old[i][2]==1 && old[i][3]==4 ) {
+                traceit("Skipping 10.3.1.4 on CVM/phoneme");
+                continue;
+            }
+
+            // otherwise, it's a supported version
+            list.add( old[ i ] );
+        }
+
+        int[][] result = new int[ list.size() ][ 4 ];
+        list.toArray( result );
+
+        return result;
+    }
+    
+    private static int[][] getVersions(String oldVersionsPath)
+    {
+        BufferedReader br = null;
+        try{
+            FileReader fr = new FileReader(oldVersionsPath);
+            br = new BufferedReader(fr);
+        }
+        catch (java.io.FileNotFoundException fNFE)
+        {
+            alarm("File '" + oldVersionsPath 
+                  + "' was not found, using default old versions for upgrade tests.");
+            return null;
+        }
+        traceit("Run upgrade tests on versions defined in '" + oldVersionsPath + "'");
+        return getVersions(br, oldVersionsPath);
+    }
+    
+    private static int[][] getVersions(BufferedReader br, String oldVersionsPath) 
+    {
+        int[][] versionArray = new int[256][4];
+        
+        int versions = 0;
+        
+        String line = null;
+        int lineNum = 0;
+        try {
+            while ((line = br.readLine()) != null) {
+                lineNum++;
+                /* Ignore lines not matching the regexp: "^[\\d]+\\.[\\d]+\\.[\\d]+\\.[\\d]"
+                 * NB. java.util.regex.Matcher and java.util.regex.Pattern can not be
+                 * used on small devices(JSR219).
+                 */
+                try {
+                    String[] parts = split4(line,'.');
+                    // String[] parts = line.split("\\."); // JSR219 does NOT have String.split()!
+                    if (parts.length >= 3) {
+                        
+                        int[] vstr = new int[4];
+                        for (int i = 0; i < 4; i++) // Using first 4 values
+                        {
+                            String str = parts[i];
+                            if (i == 3) { // Clean... remove trailing non-digits
+                                str = clean(str,"0123456789");
+                            }
+                            vstr[i] = Integer.parseInt(str);
+                        }
+                        versionArray[versions++] = vstr;
+                    } else {
+                        alarm("Illegal version format on: " + line);
+                    }
+                } catch (NumberFormatException nfe) {
+                    alarm("NumberFormatException on line " + lineNum + ": " + line + ": "
+ " " + nfe.getMessage());
+                } catch (ArrayIndexOutOfBoundsException aie) {
+                    alarm("ArrayIndexOutOfBoundsException on line " + lineNum + ": " + line
+ ": " + " " + aie.getMessage());
+                }
+            }
+        } catch (IOException ioe) {
+            alarm("Error reading from file: " + oldVersionsPath + ioe.getMessage());
+        }
+        
+        int[][] finalVERSIONS = new int[versions][4];
+        for (int v = 0; v < versions; v++) {
+            finalVERSIONS[v] = versionArray[v];
+        }
+        return  finalVERSIONS;
+        
+    }
+    
+    private static void show( int[][] old ) {
+        traceit("Upgrade test versions listed:");
+        for (int o = 0; o < old.length; o++) {
+            String ver = "";
+            for (int i = 0; i < old[o].length; i++) {
+                if (i == 0) {
+                    ver = "" + old[o][i];
+                } else {
+                    ver = ver + "." + old[o][i];
+                }
+            }
+            traceit(ver);
+        }
+    }
+    private static String[] split4(String l, char c)
+    {
+        String[] res = new String[4];
+        try{
+            int p0 = l.indexOf(c);
+            if (p0<0) return res;
+            
+            res[0] = l.substring(0, p0);
+            int p1 = l.indexOf(c,p0+1);
+            if (p1<0) return res;
+            
+            res[1] = l.substring(p0+1, p1);
+            int p2 = l.indexOf(c,p1+1); 
+            if (p2<0) return res;
+            
+            res[2] = l.substring(p1+1, p2);
+            int p3 = l.indexOf(c,p2+1); 
+            if (p3<0) p3=l.length();
+            
+            res[3] = l.substring(p2+1, p3);
+            
+        } catch(StringIndexOutOfBoundsException sie){
+            println("split4 StringIndexOutOfBoundsException: "+sie.getMessage());
+            sie.printStackTrace();
+        }
+        return res;
+    }
+    private static String clean(String l, String allowed)
+    {
+        for (int i=0;i<l.length();i++)
+        {
+            if (!matches(l.charAt(i),allowed))
+            {
+                return l.substring(0,i);
+            }
+        }
+        return l;
+    }
+    private static boolean matches(char c, String allowed)
+    {
+        for (int j=0;j<allowed.length();j++)
+        {
+            if (allowed.charAt(j) == c) return true;
+        }
+        return false;
+    }
+
+    private static void println( String text ) { BaseTestCase.println( text ); }
+    private static void traceit( String text ) { BaseTestCase.traceit( text ); }
+    private static void alarm( String text ) { BaseTestCase.alarm( text ); }
+    
+}

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/OldVersions.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/PhaseChanger.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/PhaseChanger.java?rev=764912&r1=764911&r2=764912&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/PhaseChanger.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/PhaseChanger.java
Tue Apr 14 18:23:15 2009
@@ -79,7 +79,7 @@
         
         if (loader != null) {
             previousLoader = Thread.currentThread().getContextClassLoader();
-            setThreadLoader(loader);
+            UpgradeClassLoader.setThreadLoader(loader);
         }
          
         DataSource ds = JDBCDataSource.getDataSource();
@@ -148,7 +148,7 @@
         
        
         if (loader != null)
-            setThreadLoader(previousLoader);       
+            UpgradeClassLoader.setThreadLoader(previousLoader);       
         loader = null;
         previousLoader = null;
         
@@ -156,26 +156,4 @@
         UpgradeChange.oldVersion.set(null);
     }
     
-    private void setThreadLoader(final ClassLoader which) {
-
-        AccessController.doPrivileged
-        (new java.security.PrivilegedAction(){
-            
-            public Object run()  { 
-                java.lang.Thread.currentThread().setContextClassLoader(which);
-              return null;
-            }
-        });
-    }
-    
-    private ClassLoader getThreadLoader() {
-
-        return (ClassLoader) AccessController.doPrivileged
-        (new java.security.PrivilegedAction(){
-            
-            public Object run()  { 
-                return Thread.currentThread().getContextClassLoader();
-            }
-        });
-    }
 }

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeClassLoader.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeClassLoader.java?rev=764912&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeClassLoader.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeClassLoader.java
Tue Apr 14 18:23:15 2009
@@ -0,0 +1,246 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.upgradeTests.UpgradeClassLoader
+
+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.functionTests.tests.upgradeTests;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.security.AccessController;
+import java.util.Properties;
+
+import junit.extensions.TestSetup;
+import junit.framework.Assert;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.derbyTesting.junit.BaseTestCase;
+
+/**
+ * <p>
+ * This class factors out the machinery  needed to wrap a class loader around
+ * the jar files for an old release.
+ * </p>
+ */
+public class UpgradeClassLoader
+{
+    private static final String[] jarFiles = {
+            "derby.jar", 
+            //"derbynet.jar",
+            //"derbyclient.jar",
+            //"derbytools.jar"
+            };
+
+    static final String oldVersionsPath;
+    static final String jarPath;
+    
+    static {
+         
+        oldVersionsPath = (String) AccessController.doPrivileged
+        (new java.security.PrivilegedAction(){
+
+            public Object run(){
+            return System.getProperty(_Suite.OLD_VERSIONS_PATH_PROPERTY);
+
+            }
+
+        }
+         );
+
+         jarPath = (String ) AccessController.doPrivileged
+        (new java.security.PrivilegedAction(){
+
+            public Object run(){
+            return System.getProperty(_Suite.OLD_RELEASE_PATH_PROPERTY);
+
+            }
+
+        }
+         );
+    }
+
+    protected static String getTextVersion(int[] iv)
+    {
+        String version = iv[0] + "." + iv[1] +
+        "." + iv[2] + "." + iv[3];
+        return version;
+    }
+
+    /**
+     * <p>
+     * Wrap a class loader around the given version.
+     * </p>
+     */
+    public static ClassLoader makeClassLoader( final int[] version )
+    {
+        ClassLoader oldLoader = (ClassLoader )AccessController.doPrivileged
+        (new java.security.PrivilegedAction(){
+
+            public Object run(){
+            return createClassLoader(version);
+
+            }
+
+        }
+         );
+        
+        if (oldLoader == null)
+        {
+            BaseTestCase.traceit("Empty: Skip upgrade Tests (no jars) for " + getTextVersion(version));
+        }
+        
+        return oldLoader;
+    }
+
+    /**
+     * <p>
+     * Force this thread to use a specific class loader.
+     * </p>
+     */
+    public static void setThreadLoader(final ClassLoader which) {
+
+        AccessController.doPrivileged
+        (new java.security.PrivilegedAction(){
+            
+            public Object run()  { 
+                java.lang.Thread.currentThread().setContextClassLoader(which);
+              return null;
+            }
+        });
+    }
+    
+    /**
+     * <p>
+     * Retrieve the class loader currently being used by this thread.
+     * </p>
+     */
+    public static ClassLoader getThreadLoader() {
+
+        return (ClassLoader) AccessController.doPrivileged
+        (new java.security.PrivilegedAction(){
+            
+            public Object run()  { 
+                return Thread.currentThread().getContextClassLoader();
+            }
+        });
+    }
+
+    /**
+     * Get the location of jars of old release. The location is specified 
+     * in the property derbyTesting.oldReleasePath. If derbyTesting.oldReleasePath
+     * is set to the empty string it is ignored.
+     *  
+     * @return location of jars of old release
+     */
+    private static String getOldJarLocation(int[] oldVersion) {
+      
+        if (jarPath == null || jarPath.length() == 0)
+            return null;
+        
+        String version = getTextVersion(oldVersion);
+        String jarLocation = jarPath + File.separator + version;
+        
+        return jarLocation;
+    }
+
+    /**
+     * Get the location of jars of old release, using the url for svn at apache.
+     *  
+     * @return location of jars of old release
+     */
+    private static String getOldJarURLLocation(int[] oldVersion) {
+
+        String oldJarUrl = _Suite.OLD_JAR_URL;
+        
+        String version = getTextVersion(oldVersion);
+        String jarLocation = oldJarUrl + "/" + version;
+        
+        return jarLocation;       
+    }
+
+    /**
+     * Create a class loader using jars in the specified location. Add all jars 
+     * specified in jarFiles and the testing jar.
+     * 
+     * @param version the Derby version to create a classloader for.
+     * @return class loader
+     */
+    private static ClassLoader createClassLoader(int[] version)
+    {
+        URL[] url = new URL[jarFiles.length];
+        
+        String jarLocation = getOldJarLocation(version);
+        
+        if (jarLocation != null)
+        {
+            File lib = new File(jarLocation);
+
+            // If the jars do not exist then return null
+            // and the caller will set up to skip this.
+            if (!lib.exists()){
+                BaseTestCase.alarm("Non-existing location for jar files: '" 
+                    + jarLocation + "'. Upgrade tests can NOT be run!");
+                return null;
+            }
+
+            for (int i=0; i < jarFiles.length; i++) {
+                try {
+                    url[i] = new File(lib, jarFiles[i]).toURL();
+                } catch (MalformedURLException e) {
+                    Assert.fail(e.toString());
+                }
+            }
+        }
+        else
+        
+        // if the property was not set, attempt to access the jars from 
+        // the saved svn location.
+        // Note, this means the test fails if there is no network connection
+        // (or the server at apache is down) unless the property is set
+        // to a valid location
+        {
+            String oldURLJarLocation = getOldJarURLLocation(version);
+            for (int i=0; i < jarFiles.length; i++) {
+                try {
+                    url[i] = new URL(oldURLJarLocation + "/" + jarFiles[i]);
+                    Object dummy = url[i].getContent(); // IOException if not available.
+                } catch (MalformedURLException e) {
+                    Assert.fail(e.toString());
+                } catch (IOException e) {
+                    BaseTestCase.alarm("IOException msg: '" + e.getMessage() + "'." 
+                        + " Upgrade tests can NOT be run!");
+                    return null;
+                }
+
+            }
+        }
+        
+        // Specify null for parent class loader to avoid mixing up 
+        // jars specified in the system classpath
+        return new URLClassLoader(url, null);       
+    }
+    
+}
+
+    
+

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeClassLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

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?rev=764912&r1=764911&r2=764912&view=diff
==============================================================================
--- 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
Tue Apr 14 18:23:15 2009
@@ -50,14 +50,8 @@
  * connections.
  *
  */
-class UpgradeRun {
-    private static final String[] jarFiles = {
-            "derby.jar", 
-            //"derbynet.jar",
-            //"derbyclient.jar",
-            //"derbytools.jar"
-            };
-    
+class UpgradeRun extends UpgradeClassLoader
+{
     
     /**
      * Set of additional databases for tests that
@@ -82,60 +76,15 @@
         new AdditionalDb("ROLES_10_5", false)
     };
     
-    static final String oldVersionsPath;
-    static final String jarPath;
-    
-    static {
-         
-        oldVersionsPath = (String) AccessController.doPrivileged
-        (new java.security.PrivilegedAction(){
-
-            public Object run(){
-            return System.getProperty(_Suite.OLD_VERSIONS_PATH_PROPERTY);
-
-            }
-
-        }
-         );
-
-         jarPath = (String ) AccessController.doPrivileged
-        (new java.security.PrivilegedAction(){
-
-            public Object run(){
-            return System.getProperty(_Suite.OLD_RELEASE_PATH_PROPERTY);
-
-            }
-
-        }
-         );
-    }
-
-    private static String getTextVersion(int[] iv)
-    {
-        String version = iv[0] + "." + iv[1] +
-        "." + iv[2] + "." + iv[3];
-        return version;
-    }
-
     public final static Test suite(final int[] version) {
         
-        ClassLoader oldLoader = (ClassLoader )AccessController.doPrivileged
-        (new java.security.PrivilegedAction(){
-
-            public Object run(){
-            return createClassLoader(version);
-
-            }
-
-        }
-         );
+        ClassLoader oldLoader = makeClassLoader( version );
         
         // If no jars then just skip.
         if (oldLoader == null)
         {
             TestSuite suite = new TestSuite(
                     "Empty: Skipped upgrade Tests (no jars) for " + getTextVersion(version));
-            BaseTestCase.traceit("Empty: Skip upgrade Tests (no jars) for " + getTextVersion(version));
             return suite;
         }
         
@@ -283,101 +232,6 @@
         return TestConfiguration.connectionDSDecorator(suite);
     }
     
-    /**
-     * Get the location of jars of old release. The location is specified 
-     * in the property derbyTesting.oldReleasePath. If derbyTesting.oldReleasePath
-     * is set to the empty string it is ignored.
-     *  
-     * @return location of jars of old release
-     */
-    private static String getOldJarLocation(int[] oldVersion) {
-      
-        if (jarPath == null || jarPath.length() == 0)
-            return null;
-        
-        String version = getTextVersion(oldVersion);
-        String jarLocation = jarPath + File.separator + version;
-        
-        return jarLocation;
-    }
-
-    /**
-     * Get the location of jars of old release, using the url for svn at apache.
-     *  
-     * @return location of jars of old release
-     */
-    private static String getOldJarURLLocation(int[] oldVersion) {
-
-        String oldJarUrl = _Suite.OLD_JAR_URL;
-        
-        String version = getTextVersion(oldVersion);
-        String jarLocation = oldJarUrl + "/" + version;
-        
-        return jarLocation;       
-    }
-
-    /**
-     * Create a class loader using jars in the specified location. Add all jars 
-     * specified in jarFiles and the testing jar.
-     * 
-     * @param version the Derby version to create a classloader for.
-     * @return class loader
-     */
-    private static ClassLoader createClassLoader(int[] version)
-    {
-        URL[] url = new URL[jarFiles.length];
-        
-        String jarLocation = getOldJarLocation(version);
-        
-        if (jarLocation != null)
-        {
-            File lib = new File(jarLocation);
-
-            // If the jars do not exist then return null
-            // and the caller will set up to skip this.
-            if (!lib.exists()){
-                BaseTestCase.alarm("Non-existing location for jar files: '" 
-                    + jarLocation + "'. Upgrade tests can NOT be run!");
-                return null;
-            }
-
-            for (int i=0; i < jarFiles.length; i++) {
-                try {
-                    url[i] = new File(lib, jarFiles[i]).toURL();
-                } catch (MalformedURLException e) {
-                    Assert.fail(e.toString());
-                }
-            }
-        }
-        else
-        
-        // if the property was not set, attempt to access the jars from 
-        // the saved svn location.
-        // Note, this means the test fails if there is no network connection
-        // (or the server at apache is down) unless the property is set
-        // to a valid location
-        {
-            String oldURLJarLocation = getOldJarURLLocation(version);
-            for (int i=0; i < jarFiles.length; i++) {
-                try {
-                    url[i] = new URL(oldURLJarLocation + "/" + jarFiles[i]);
-                    Object dummy = url[i].getContent(); // IOException if not available.
-                } catch (MalformedURLException e) {
-                    Assert.fail(e.toString());
-                } catch (IOException e) {
-                    BaseTestCase.alarm("IOException msg: '" + e.getMessage() + "'." 
-                        + " Upgrade tests can NOT be run!");
-                    return null;
-                }
-
-            }
-        }
-        
-        // 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

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/_Suite.java?rev=764912&r1=764911&r2=764912&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/_Suite.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/_Suite.java
Tue Apr 14 18:23:15 2009
@@ -20,9 +20,6 @@
 */
 package org.apache.derbyTesting.functionTests.tests.upgradeTests;
 
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.IOException;
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
@@ -115,7 +112,7 @@
      * when running tests.
      */
 
-    private static OldVersions old;
+    private static int[][] old;
 
     /**
      * Use suite method instead.
@@ -129,180 +126,15 @@
                 + OLD_RELEASE_PATH_PROPERTY + "=" + UpgradeRun.jarPath
                 + " / " + OLD_VERSIONS_PATH_PROPERTY + "=" + UpgradeRun.oldVersionsPath;
         TestSuite suite = new TestSuite(id);       
-        
-        if ( UpgradeRun.oldVersionsPath != null )
-        {
-            old = new OldVersions(UpgradeRun.oldVersionsPath);
-        }
-        OldVersions.show();
 
-        for (int i = 0; i < old.VERSIONS.length; i++) {
-            // JSR169 support was only added with 10.1, so don't
-            // run 10.0 to later upgrade if that's what our jvm is supporting.
-            if ((JDBC.vmSupportsJSR169() && 
-                (old.VERSIONS[i][0]==10) && (old.VERSIONS[i][1]==0))) {
-                traceit("Skipping 10.0 on JSR169");
-                continue;
-            }
-            // Derby 10.3.1.4 does not boot on the phoneME advanced platform,
-            // (see DERBY-3176) so don't run upgrade tests in this combination.
-            if ( System.getProperty("java.vm.name").equals("CVM")
-                  && System.getProperty("java.vm.version").startsWith("phoneme")
-                  && old.VERSIONS[i][0]==10 && old.VERSIONS[i][1]==3 
-                  && old.VERSIONS[i][2]==1 && old.VERSIONS[i][3]==4 ) {
-                traceit("Skipping 10.3.1.4 on CVM/phoneme");
-                continue;
-            }
-            suite.addTest(UpgradeRun.suite(old.VERSIONS[i]));
+        old = OldVersions.getSupportedVersions();
+        
+        for (int i = 0; i < old.length; i++) {
+            suite.addTest(UpgradeRun.suite(old[i]));
         }
 
         return suite;
     }
     
 
-    private static class OldVersions{
-
-        private static int[][] VERSIONS =
-          {
-            {10, 0, 2, 1}, // 10.0.2.1 (incubator release)
-            {10, 1, 1, 0}, // 10.1.1.0 (Aug 3, 2005 / SVN 208786)
-            {10, 1, 2, 1}, // 10.1.2.1 (Nov 18, 2005 / SVN 330608)
-            {10, 1, 3, 1}, // 10.1.3.1 (Jun 30, 2006 / SVN 417277)
-            {10, 2, 1, 6}, // 10.2.1.6 (Oct 02, 2006 / SVN 452058)
-            {10, 2, 2, 0}, // 10.2.2.0 (Dec 12, 2006 / SVN 485682)
-            {10, 3, 1, 4}, // 10.3.1.4 (Aug 1, 2007 / SVN 561794)
-            {10, 3, 3, 0}, // 10.3.3.0 (May 12, 2008 / SVN 652961)
-            {10, 4, 1, 3}, // 10.4.1.3 (April 24, 2008 / SVN 648739)
-            {10, 4, 2, 0}, // 10.4.2.0 (September 05, 2008 / SVN 693552)
-          };
-        private OldVersions(String oldVersionsPath)
-        {
-            BufferedReader br = null;
-            try{
-                FileReader fr = new FileReader(oldVersionsPath);
-                br = new BufferedReader(fr);
-            }
-            catch (java.io.FileNotFoundException fNFE)
-            {
-                alarm("File '" + oldVersionsPath 
-                        + "' was not found, using default old versions for upgrade tests.");
-                return;
-            }
-            traceit("Run upgrade tests on versions defined in '" + oldVersionsPath + "'");
-            getVersions(br, oldVersionsPath);
-        }
-
-        private void getVersions(BufferedReader br, String oldVersionsPath) 
-        {
-            VERSIONS = new int[256][4];
-
-            int versions = 0;
-
-            String line = null;
-            int lineNum = 0;
-            try {
-                while ((line = br.readLine()) != null) {
-                    lineNum++;
-                    /* Ignore lines not matching the regexp: "^[\\d]+\\.[\\d]+\\.[\\d]+\\.[\\d]"
-                     * NB. java.util.regex.Matcher and java.util.regex.Pattern can not be
-                     * used on small devices(JSR219).
-                     */
-                    try {
-                        String[] parts = split4(line,'.');
-                        // String[] parts = line.split("\\."); // JSR219 does NOT have String.split()!
-                        if (parts.length >= 3) {
-
-                            int[] vstr = new int[4];
-                            for (int i = 0; i < 4; i++) // Using first 4 values
-                            {
-                                String str = parts[i];
-                                if (i == 3) { // Clean... remove trailing non-digits
-                                    str = clean(str,"0123456789");
-                                }
-                                vstr[i] = Integer.parseInt(str);
-                            }
-                            VERSIONS[versions++] = vstr;
-                        } else {
-                            alarm("Illegal version format on: " + line);
-                        }
-                    } catch (NumberFormatException nfe) {
-                        alarm("NumberFormatException on line " + lineNum + ": " + line +
": " + " " + nfe.getMessage());
-                    } catch (ArrayIndexOutOfBoundsException aie) {
-                        alarm("ArrayIndexOutOfBoundsException on line " + lineNum + ": "
+ line + ": " + " " + aie.getMessage());
-                    }
-                }
-            } catch (IOException ioe) {
-                alarm("Error reading from file: " + oldVersionsPath + ioe.getMessage());
-            }
-            
-            int[][] finalVERSIONS = new int[versions][4];
-            for (int v = 0; v < versions; v++) {
-                finalVERSIONS[v] = VERSIONS[v];
-            }
-            VERSIONS = finalVERSIONS;
-
-        }
-
-        private static void show() {
-            traceit("Upgrade test versions listed:");
-            for (int o = 0; o < VERSIONS.length; o++) {
-                String ver = "";
-                for (int i = 0; i < VERSIONS[o].length; i++) {
-                    if (i == 0) {
-                        ver = "" + VERSIONS[o][i];
-                    } else {
-                        ver = ver + "." + VERSIONS[o][i];
-                    }
-                }
-                traceit(ver);
-            }
-        }
-        private static String[] split4(String l, char c)
-        {
-            String[] res = new String[4];
-            try{
-            int p0 = l.indexOf(c);
-            if (p0<0) return res;
-            
-            res[0] = l.substring(0, p0);
-            int p1 = l.indexOf(c,p0+1);
-            if (p1<0) return res;
-            
-            res[1] = l.substring(p0+1, p1);
-            int p2 = l.indexOf(c,p1+1); 
-            if (p2<0) return res;
-            
-            res[2] = l.substring(p1+1, p2);
-            int p3 = l.indexOf(c,p2+1); 
-            if (p3<0) p3=l.length();
-            
-            res[3] = l.substring(p2+1, p3);
-            
-            } catch(StringIndexOutOfBoundsException sie){
-                println("split4 StringIndexOutOfBoundsException: "+sie.getMessage());
-                sie.printStackTrace();
-            }
-            return res;
-        }
-        private static String clean(String l, String allowed)
-        {
-            for (int i=0;i<l.length();i++)
-            {
-                if (!matches(l.charAt(i),allowed))
-                {
-                    return l.substring(0,i);
-                }
-            }
-            return l;
-        }
-        private static boolean matches(char c, String allowed)
-        {
-            for (int j=0;j<allowed.length();j++)
-            {
-                if (allowed.charAt(j) == c) return true;
-            }
-            return false;
-        }
-        
-    }
 }



Mime
View raw message