You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by kr...@apache.org on 2012/06/21 13:30:16 UTC

svn commit: r1352498 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit: DerbyDistribution.java ReleaseRepository.java TestConfiguration.java

Author: kristwaa
Date: Thu Jun 21 11:30:16 2012
New Revision: 1352498

URL: http://svn.apache.org/viewvc?rev=1352498&view=rev
Log:
DERBY-5475: Formalize use of old Derby distributions in test

Expose the release repository in TestConfiguration.
Removed some leftover throws IOException, and added some exception handling
to avoid one throws IOException clause.

Patch file: derby-5475-4a-less_exceptions_and_expose.diff

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DerbyDistribution.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ReleaseRepository.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DerbyDistribution.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DerbyDistribution.java?rev=1352498&r1=1352497&r2=1352498&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DerbyDistribution.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DerbyDistribution.java Thu Jun 21 11:30:16 2012
@@ -75,13 +75,13 @@ public class DerbyDistribution
     private final String testingClasspath;
 
     /**
-     * @throws IOException if obtaining the canonical path of a file fails
+     * Derives the information for a Derby distribution.
+     *
      * @throws NullPointerException if version is {@code null}
      * @see #getInstance
      */
     private DerbyDistribution(DerbyVersion version,
-                              File[] productionJars, File[] testingJars)
-            throws IOException {
+                              File[] productionJars, File[] testingJars) {
         if (version == null) {
             throw new NullPointerException("version is null");
         }
@@ -273,13 +273,19 @@ public class DerbyDistribution
      *
      * @param jars JAR files to merge
      * @return A classpath string.
-     * @throws IOException if obtaining the canonical path of a file fails
      */
-    private static String constructJarClasspath(File[] jars)
-            throws IOException {
+    private static String constructJarClasspath(File[] jars) {
         StringBuffer sb = new StringBuffer(512);
         for (int i=0; i < jars.length; i++) {
-            sb.append(jars[i].getCanonicalPath());
+            try {
+                sb.append(jars[i].getCanonicalPath());
+            } catch (IOException ioe) {
+                // Do the next best thing; use absolute path.
+                String absPath = jars[i].getAbsolutePath();
+                sb.append(absPath);
+                BaseTestCase.println("obtaining canonical path for " +
+                        absPath + " failed: " + ioe.getMessage());
+            }
             sb.append(File.pathSeparatorChar);
         }
         if (jars.length > 0) {
@@ -299,12 +305,10 @@ public class DerbyDistribution
      * @param version the version of the distribution
      * @return A representation of the distribution, or {@code null} if
      *      the specified directory is determined to be invalid.
-     * @throws IOException if obtaining the required information fails
      * @throws IllegalArgumentException if {@code version} is {@code null}
      */
     public static DerbyDistribution getInstance(File dir,
-                                                DerbyVersion version)
-            throws IOException {
+                                                DerbyVersion version) {
         File[] productionJars = getProductionJars(dir);
         File[] testingJars = getTestingJars(dir);
         List tmpJars = new ArrayList();

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ReleaseRepository.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ReleaseRepository.java?rev=1352498&r1=1352497&r2=1352498&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ReleaseRepository.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ReleaseRepository.java Thu Jun 21 11:30:16 2012
@@ -133,15 +133,13 @@ public class ReleaseRepository {
      *      distribution at index zero, or an empty list if there are no
      *      distributions in the repository.
      */
-    public DerbyDistribution[] getDistributions()
-            throws IOException {
+    public DerbyDistribution[] getDistributions() {
         DerbyDistribution[] clone = new DerbyDistribution[dists.size()];
         dists.toArray(clone);
         return clone;
     }
 
-    private void buildDistributionList()
-            throws IOException {
+    private void buildDistributionList() {
         if (dists != null) {
             throw new IllegalStateException("repository already initialized");
         }

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=1352498&r1=1352497&r2=1352498&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 Thu Jun 21 11:30:16 2012
@@ -22,6 +22,7 @@ package org.apache.derbyTesting.junit;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.FileNotFoundException;
+import java.io.IOException;
 import java.io.PrintWriter;
 import java.security.*;
 import java.sql.Connection;
@@ -126,6 +127,8 @@ public final class TestConfiguration {
      */
     private static int uniqueDB;
 
+    /** Repository of old/previous Derby releases available on the local system. */
+    private static ReleaseRepository releaseRepository;
 
     /**
      * Default Derby test configuration object based
@@ -215,7 +218,30 @@ public final class TestConfiguration {
     public static TestConfiguration getCurrent() {
         return (TestConfiguration) CURRENT_CONFIG.get();
     }
-    
+
+    /**
+     * Returns the release repository containing old Derby releases available
+     * on the local system.
+     * <p>
+     * <strong>NOTE</strong>: It is your responsibility to keep the repository
+     * up to date. This usually involves syncing the local Subversion repository
+     * of previous Derby releases with the master repository at Apache.
+     *
+     * @see ReleaseRepository
+     */
+    public static synchronized ReleaseRepository getReleaseRepository() {
+        if (releaseRepository == null) {
+            try {
+                releaseRepository = ReleaseRepository.getInstance();
+            } catch (IOException ioe) {
+                BaseTestCase.printStackTrace(ioe);
+                Assert.fail("failed to initialize the release repository: " +
+                        ioe.getMessage());
+            }
+        }
+        return releaseRepository;
+    }
+
     /**
      * WORK IN PROGRESS
      * Set this Thread's current configuration for running tests.