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 2012/09/07 16:03:18 UTC
svn commit: r1382032 - in
/db/derby/code/trunk/java/testing/org/apache/derbyTesting:
functionTests/tests/jdbc4/Wrapper41.java
functionTests/tests/jdbc4/Wrapper41Conn.java
functionTests/tests/jdbc4/Wrapper41DataSource.java
junit/TestConfiguration.java
Author: kahatlen
Date: Fri Sep 7 14:03:18 2012
New Revision: 1382032
URL: http://svn.apache.org/viewvc?rev=1382032&view=rev
Log:
DERBY-5917: NoClassDefFoundErrors when running tests without derbynet.jar and derbyclient.jar
Avoid attempts to load client classes when the client driver is not there.
Modified:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41Conn.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41DataSource.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/Wrapper41.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41.java?rev=1382032&r1=1382031&r2=1382032&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41.java Fri Sep 7 14:03:18 2012
@@ -59,10 +59,10 @@ public class Wrapper41
public Wrapper41( Object wrapped ) throws Exception
{
if ( wrapped instanceof EmbedResultSet40 ) { _embedded = (EmbedResultSet40) wrapped; }
- else if ( wrapped instanceof NetResultSet40 ) { _netclient = (NetResultSet40) wrapped; }
else if ( wrapped instanceof EmbedCallableStatement40 ) { _embedCallableStatement = (EmbedCallableStatement40) wrapped; }
- else if ( wrapped instanceof CallableStatement40 ) { _callableStatement = (CallableStatement40) wrapped; }
else if ( wrapped instanceof BrokeredCallableStatement40 ) { _brokeredCallableStatement = (BrokeredCallableStatement40) wrapped; }
+ else if ( wrapped instanceof NetResultSet40 ) { _netclient = (NetResultSet40) wrapped; }
+ else if ( wrapped instanceof CallableStatement40 ) { _callableStatement = (CallableStatement40) wrapped; }
else if ( wrapped instanceof LogicalCallableStatement40 ) { _logicalCallableStatement = (LogicalCallableStatement40) wrapped; }
else { throw nothingWrapped(); }
}
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41Conn.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41Conn.java?rev=1382032&r1=1382031&r2=1382032&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41Conn.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41Conn.java Fri Sep 7 14:03:18 2012
@@ -57,8 +57,8 @@ public class Wrapper41Conn
public Wrapper41Conn( Object wrapped ) throws Exception
{
if ( wrapped instanceof EmbedConnection40 ) { _embedded = (EmbedConnection40) wrapped; }
- else if ( wrapped instanceof NetConnection40 ) { _netclient = (NetConnection40) wrapped; }
else if ( wrapped instanceof BrokeredConnection40 ) { _brokeredConnection = (BrokeredConnection40) wrapped; }
+ else if ( wrapped instanceof NetConnection40 ) { _netclient = (NetConnection40) wrapped; }
else if ( wrapped instanceof LogicalConnection40 ) { _logicalConnection = (LogicalConnection40) wrapped; }
else { throw nothingWrapped(); }
}
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41DataSource.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41DataSource.java?rev=1382032&r1=1382031&r2=1382032&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41DataSource.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41DataSource.java Fri Sep 7 14:03:18 2012
@@ -62,9 +62,9 @@ public class Wrapper41DataSource
public Wrapper41DataSource( Object wrapped ) throws Exception
{
if ( wrapped instanceof EmbeddedDataSource40 ) { _embedded = (EmbeddedDataSource40 ) wrapped; }
- else if ( wrapped instanceof ClientDataSource40 ) { _netclient = (ClientDataSource40) wrapped; }
else if ( wrapped instanceof EmbeddedConnectionPoolDataSource40 ) { _ecpds = (EmbeddedConnectionPoolDataSource40) wrapped; }
else if ( wrapped instanceof EmbeddedXADataSource40 ) { _exads = (EmbeddedXADataSource40) wrapped; }
+ else if ( wrapped instanceof ClientDataSource40 ) { _netclient = (ClientDataSource40) wrapped; }
else if ( wrapped instanceof ClientConnectionPoolDataSource40 ) { _ccpds = (ClientConnectionPoolDataSource40) wrapped; }
else if ( wrapped instanceof ClientXADataSource40 ) { _cxads = (ClientXADataSource40) wrapped; }
else { throw nothingWrapped(); }
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=1382032&r1=1382031&r2=1382032&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 Fri Sep 7 14:03:18 2012
@@ -495,10 +495,8 @@ public final class TestConfiguration {
*
*/
public static Test clientServerSuite(Class testClass)
- {
- TestSuite suite = new TestSuite(testClass,
- suiteName(testClass)+":client");
- return clientServerDecorator(suite);
+ {
+ return clientServerDecorator(bareClientServerSuite(testClass));
}
/**
* Create a suite for the passed test class that includes
@@ -508,9 +506,8 @@ public final class TestConfiguration {
*/
public static Test clientServerSuiteWithAlternativePort(Class testClass) {
- TestSuite suite = new TestSuite(testClass, suiteName(testClass)
- + ":client");
- return clientServerDecoratorWithAlternativePort(suite);
+ return clientServerDecoratorWithAlternativePort(
+ bareClientServerSuite(testClass));
}
/**
@@ -520,9 +517,8 @@ public final class TestConfiguration {
*/
public static Test clientExistingServerSuite(Class testClass)
{
- TestSuite suite = new TestSuite(testClass,
- suiteName(testClass)+":client");
- return defaultExistingServerDecorator(suite); // Will not start server and does not stop it when done!.
+ // Will not start server and does not stop it when done.
+ return defaultExistingServerDecorator(bareClientServerSuite(testClass));
}
/**
@@ -536,18 +532,16 @@ public final class TestConfiguration {
*/
public static Test clientExistingServerSuite(Class testClass, String hostName, int portNumber)
{
- TestSuite suite = new TestSuite(testClass,
- suiteName(testClass)+":client");
- return existingServerDecorator(suite, hostName, portNumber);
// Will not start server and does not stop it when done!.
+ return existingServerDecorator(bareClientServerSuite(testClass),
+ hostName, portNumber);
}
public static Test clientExistingServerSuite(Class testClass,
String hostName, int portNumber, String dbPath)
{
- TestSuite suite = new TestSuite(testClass,
- suiteName(testClass)+":client");
- return existingServerDecorator(suite, hostName, portNumber, dbPath);
// Will not start server and does not stop it when done!.
+ return existingServerDecorator(bareClientServerSuite(testClass),
+ hostName, portNumber, dbPath);
}
/**
@@ -626,9 +620,9 @@ public final class TestConfiguration {
{
// Need to have network server and client and not
// running in J2ME (JSR169).
- if (!(Derby.hasClient() && Derby.hasServer())
- || JDBC.vmSupportsJSR169())
+ if (!supportsClientServer()) {
return new TestSuite("empty: no network server support");
+ }
//
// This looks bogus to me. Shouldn't this get the hostname and port
@@ -646,9 +640,9 @@ public final class TestConfiguration {
{
// Need to have network server and client and not
// running in J2ME (JSR169).
- if (!(Derby.hasClient() && Derby.hasServer())
- || JDBC.vmSupportsJSR169())
+ if (!supportsClientServer()) {
return new TestSuite("empty: no network server support");
+ }
Test r =
new ServerSetup(test, hostName, PortNumber);
@@ -664,9 +658,9 @@ public final class TestConfiguration {
{
// Need to have network server and client and not
// running in J2ME (JSR169).
- if (!(Derby.hasClient() && Derby.hasServer())
- || JDBC.vmSupportsJSR169())
+ if (!supportsClientServer()) {
return new TestSuite("empty: no network server support");
+ }
Test r =
new ServerSetup(test, hostName, PortNumber);
@@ -681,9 +675,10 @@ public final class TestConfiguration {
public static Test defaultServerDecoratorWithAlternativePort(Test test) {
// Need to have network server and client and not
// running in J2ME (JSR169).
- if (!(Derby.hasClient() && Derby.hasServer())
- || JDBC.vmSupportsJSR169())
+ if (!supportsClientServer()) {
return new TestSuite("empty: no network server support");
+ }
+
int port = getCurrent().getNextAvailablePort();
//
@@ -695,6 +690,30 @@ public final class TestConfiguration {
}
/**
+ * Check if client and server testing is supported in the test environment.
+ */
+ private static boolean supportsClientServer() {
+ return JDBC.vmSupportsJDBC3() && Derby.hasClient() && Derby.hasServer();
+ }
+
+ /**
+ * Create a suite of test cases to run in a client/server environment. The
+ * returned test suite is not decorated with a ServerSetup.
+ *
+ * @param testClass the class from which to extract the test cases
+ * @return a test suite with all the test cases in {@code testClass}, or
+ * an empty test suite if client/server is not supported in the test
+ * environment
+ */
+ private static Test bareClientServerSuite(Class testClass) {
+ TestSuite suite = new TestSuite(suiteName(testClass) + ":client");
+ if (supportsClientServer()) {
+ suite.addTestSuite(testClass);
+ }
+ return suite;
+ }
+
+ /**
* Generate the unique database name for single use.
*/
public static synchronized String generateUniqueDatabaseName()