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 ka...@apache.org on 2013/06/20 10:12:31 UTC
svn commit: r1494884 - in /db/derby/code/branches/10.10: ./
java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/
java/testing/org/apache/derbyTesting/junit/
Author: kahatlen
Date: Thu Jun 20 08:12:31 2013
New Revision: 1494884
URL: http://svn.apache.org/r1494884
Log:
DERBY-6126: compatibility._Suite fails if derbyTesting.jar lives in different directory than product jars
Merged revision 1494883 from trunk.
Modified:
db/derby/code/branches/10.10/ (props changed)
db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/VersionCombinationConfigurator.java
db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/junit/DerbyDistribution.java
db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/junit/ReleaseRepository.java
Propchange: db/derby/code/branches/10.10/
------------------------------------------------------------------------------
Merged /db/derby/code/trunk:r1494883
Modified: db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/VersionCombinationConfigurator.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/VersionCombinationConfigurator.java?rev=1494884&r1=1494883&r2=1494884&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/VersionCombinationConfigurator.java (original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/VersionCombinationConfigurator.java Thu Jun 20 08:12:31 2013
@@ -72,6 +72,9 @@ import org.apache.derbyTesting.junit.Tes
*/
public class VersionCombinationConfigurator {
+ private static final String EMB_DRIVER =
+ "org.apache.derby.jdbc.EmbeddedDriver";
+
/** Name of the configuration, only used for informational purposes. */
private final String name;
/** Decides if combinations have to involve trunk (as server or client). */
@@ -281,20 +284,25 @@ public class VersionCombinationConfigura
* Returns the running distribution, which is typically trunk.
*
* @return Information about the running distribution.
- * @throws IllegalArgumentException if parsing the version string fails, or
- * if trunk is run off the classes directory
+ * @throws IllegalStateException if parsing the version string fails, if
+ * required Derby classes are missing, or if trunk is run off the
+ * classes directory
*/
private DerbyDistribution getRunningDistribution() {
- File libDir = new File(getClassURI(getClass()));
- if (libDir.isDirectory()) {
- throw new IllegalStateException("only running off jars is " +
- "supported, currently running off " + libDir);
+ File libDir;
+ try {
+ libDir = getJarDirectoryOf(Class.forName(EMB_DRIVER));
+ } catch (ClassNotFoundException cnfe) {
+ // Add relevant information to the error message, the cause and
+ // its stack trace is not printed by default in this context.
+ throw new IllegalStateException(
+ "missing Derby class: " + cnfe.getMessage(), cnfe);
}
- // Get the directory the JAR file is living in.
- libDir = libDir.getParentFile();
+ File testingDir = getJarDirectoryOf(getClass());
DerbyVersion version = DerbyVersion.parseVersionString(
sysinfo.getVersionString());
- DerbyDistribution dist = DerbyDistribution.getInstance(libDir, version);
+ DerbyDistribution dist = DerbyDistribution.newInstance(
+ version, libDir, testingDir);
if (dist == null) {
throw new IllegalStateException(
"failed to get running distribution (programming error?)");
@@ -303,6 +311,22 @@ public class VersionCombinationConfigura
}
/**
+ * Returns the directory for the JAR file containing the given class.
+ *
+ * @return A directory path.
+ * @throws IllegalStateException if the class isn't loaded from a JAR
+ */
+ private File getJarDirectoryOf(Class clazz) {
+ File jarPath = new File(getClassURI(clazz));
+ if (jarPath.isDirectory()) {
+ throw new IllegalStateException("only running off jars is " +
+ "supported, currently running off directory " + jarPath);
+ }
+ // Get the directory the JAR file is living in.
+ return jarPath.getParentFile();
+ }
+
+ /**
* Sorts and filters out distributions based on the configurator settings.
*
* We suppress warnings here because DerbyDistribution needs to
Modified: db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/junit/DerbyDistribution.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/junit/DerbyDistribution.java?rev=1494884&r1=1494883&r2=1494884&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/junit/DerbyDistribution.java (original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/junit/DerbyDistribution.java Thu Jun 20 08:12:31 2013
@@ -35,12 +35,13 @@ import org.apache.derbyTesting.functionT
* based on the version of the Derby distribution.
* <p>
* <em>Implementation note</em>: For simplicity distributions off the classes
- * directory has been forbidden. The main reason for this is that it is
+ * directory have been forbidden. The main reason for this is that it is
* sometimes a hard requirement that you must include only a single JAR from a
* distribution on the classpath. One such example is the compatibility test,
* where you need the testing code from one distribution and the client driver
- * from another. While it is possible to support such a configuration in many
- * scenarios, it complicates things quite a bit. Generating the JARs when
+ * from another. While it is possible to support such a configuration running
+ * off the {@code classes}-directory in many scenarios, it complicates
+ * the creation and handling of classpath string. Generating the JARs when
* testing on trunk seems like an acceptable price to pay.
*/
public class DerbyDistribution
@@ -296,22 +297,49 @@ public class DerbyDistribution
}
/**
- * Returns an instance based on the given library directory and version.
* <p>
- * This method is capable of understanding the difference of JAR based
- * distribution and a distribution running off the classes-directory.
+ * Returns a distribution with the specified version, based on the given
+ * library directory.
+ * </p>
+ *
+ * <p>
+ * It is the responsibility of the caller to ensure that the specified
+ * version matches the JARs in the given directory.
+ * </p>
+ *
+ * @param version the version of the distribution
+ * @param baseDir the base dir for the distribution, holding the Derby JARs
+ * @return A representation of the distribution, or {@code null} if
+ * the specified directory doesn't contain a valid distribution.
+ * @throws IllegalArgumentException if {@code version} is {@code null}
+ */
+ public static DerbyDistribution newInstance(DerbyVersion version,
+ File baseDir) {
+ return newInstance(version, baseDir, baseDir);
+ }
+
+ /**
+ * <p>
+ * Returns a distribution with the specified version, based on the given
+ * library and testing directories.
+ * </p>
+ *
+ * <p>
+ * It is the responsibility of the caller to ensure that the specified
+ * version matches the JARs in the given directories.
+ * </p>
*
- * @param dir the base directory for the distribution (either the classes
- * directory or a directory holding the Derby JAR files)
* @param version the version of the distribution
+ * @param baseDir the directory holding the production JARs
+ * @param testDir the directory holding the testing JAR
* @return A representation of the distribution, or {@code null} if
- * the specified directory is determined to be invalid.
+ * the specified directories don't make up a valid distribution.
* @throws IllegalArgumentException if {@code version} is {@code null}
*/
- public static DerbyDistribution getInstance(File dir,
- DerbyVersion version) {
- File[] productionJars = getProductionJars(dir);
- File[] testingJars = getTestingJars(dir);
+ public static DerbyDistribution newInstance(DerbyVersion version,
+ File baseDir, File testDir) {
+ File[] productionJars = getProductionJars(baseDir);
+ File[] testingJars = getTestingJars(testDir);
List tmpJars = new ArrayList();
tmpJars.addAll(Arrays.asList(productionJars));
tmpJars.addAll(Arrays.asList(testingJars));
@@ -320,7 +348,9 @@ public class DerbyDistribution
}
// Invalid distribution, ignore it.
BaseTestCase.println("Distribution deemed invalid (note that running " +
- "off classes isn't supported): " + dir.getAbsolutePath());
+ "off classes isn't supported): " + baseDir.getAbsolutePath() +
+ (baseDir.equals(testDir) ? ""
+ : ", " + testDir.getAbsolutePath()));
return null;
}
}
Modified: db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/junit/ReleaseRepository.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/junit/ReleaseRepository.java?rev=1494884&r1=1494883&r2=1494884&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/junit/ReleaseRepository.java (original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/junit/ReleaseRepository.java Thu Jun 20 08:12:31 2013
@@ -192,8 +192,8 @@ public class ReleaseRepository {
dir.getAbsolutePath());
continue;
}
- DerbyDistribution dist = DerbyDistribution.getInstance(
- dir, version);
+ DerbyDistribution dist = DerbyDistribution.newInstance(
+ version, dir);
// TODO: 10.0.1.2 is considered invalid because it doesn't have a
// a client JAR. Accept, ignore, or warn all the time?
if (dist == null) {