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 da...@apache.org on 2005/11/09 18:47:13 UTC
svn commit: r332090 - in /db/derby/code/trunk/java/testing: ./
org/apache/derbyTesting/functionTests/harness/
org/apache/derbyTesting/functionTests/master/
org/apache/derbyTesting/functionTests/suites/
org/apache/derbyTesting/functionTests/tests/compat...
Author: davidvc
Date: Wed Nov 9 09:46:52 2005
New Revision: 332090
URL: http://svn.apache.org/viewcvs?rev=332090&view=rev
Log:
Changes for DERBY-689, contributed by Rick Hillegas (rick.hillegas@sun.com)
Rick says:
Various improvements to compatibility test:
1) Moved all JUnit tests under a ...functionTests/tests/junitTests as Myrna and John requested.
2) Made the test harness sanity check the classpath as David requested.
3) Abstracted a CompatibilitySuite out of the original test to make it easier to add more test classes, as Francois requested.
4) Added combinations for the 10.1.2.0 client and server
5) The derbyall diff tool was enhanced to fabricate an empty canon file if one doesn't exist in the codeline. This eliminates the need to create empty canons for JUnit tests.
===
David says:
I made a slight modification -- I moved the CompatibilityTest to
derbynetclientmats instead of derbynetmats, as it's intended only for
the network client, not for the DB2 driver
I'd also like to clarify that the "empty canon file" is not created on
disk -- it's only created as an InputStream within the test harness. Nice
fix, no more empty files to create for tests that have no output.
Added:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/
- copied from r331635, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/CompatibilitySuite.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/JDBCDriverTest.java
- copied, changed from r332087, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/JDBCDriverTest.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/Pinger.java
- copied, changed from r332087, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/Pinger.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/README.html
- copied, changed from r332087, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/README.html
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/build.xml
- copied, changed from r332087, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/build.xml
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/testScript.xml
- copied, changed from r332087, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/testScript.xml
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/CompatibilityTest.java
- copied, changed from r331635, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/CompatibilityTest.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/CompatibilityTest_app.properties
- copied, changed from r331635, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/CompatibilityTest_app.properties
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/build.xml (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/copyfiles.ant (with props)
Removed:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/CompatibilityTest.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/JDBCDriverTest.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/Pinger.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/README.html
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/build.xml
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/testScript.xml
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/CompatibilityTest.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/CompatibilityTest_app.properties
Modified:
db/derby/code/trunk/java/testing/README.htm
db/derby/code/trunk/java/testing/build.xml
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/FileCompare.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetclientmats.runall
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetmats.runall
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/copyfiles.ant
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/build.xml
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/DerbyJUnitTest.java
Modified: db/derby/code/trunk/java/testing/README.htm
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/README.htm?rev=332090&r1=332089&r2=332090&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/README.htm (original)
+++ db/derby/code/trunk/java/testing/README.htm Wed Nov 9 09:46:52 2005
@@ -68,7 +68,7 @@
<LI><P><A HREF="#props">4.12 Some test harness properties</A>
</P>
<LI><P><A HREF="#security">4.13 SecuirtyManager testing by default</A></P>
- <li><a href="./org/apache/derbyTesting/functionTests/tests/compatibility/README.html">5. Compatibility Tests</a> </li>
+ <li><a href="./org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/README.html">5. Compatibility Tests</a> </li>
</UL>
<P><BR><BR>
</P>
Modified: db/derby/code/trunk/java/testing/build.xml
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/build.xml?rev=332090&r1=332089&r2=332090&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/build.xml (original)
+++ db/derby/code/trunk/java/testing/build.xml Wed Nov 9 09:46:52 2005
@@ -39,10 +39,12 @@
<target name="testing"
description="Build Derby testing files">
+
<ant dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/harness"/>
<ant dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/testData"/>
<ant dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/util"/>
- <ant dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/tests/compatibility"/>
+ <ant dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/tests/junitTests/compatibility"/>
+ <ant dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/tests/junitTests/derbynet"/>
<ant dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/tests/jdbcapi"/>
<ant dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/tests/lang"/>
<ant dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/tests/store"/>
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/FileCompare.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/FileCompare.java?rev=332090&r1=332089&r2=332090&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/FileCompare.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/FileCompare.java Wed Nov 9 09:46:52 2005
@@ -179,13 +179,10 @@
is = master;
}
- // If the master is still not found, print an error and return
+ // If the master is still not found, create an empty master
if ( is == null )
{
- System.out.println("No master file was found.");
- pwDiff.println("No master file was found.");
- pwDiff.flush();
- return true;
+ is = new ByteArrayInputStream( new byte[] {} );
}
// compress blanks in output columns to make up for column width differences
// for JCC output
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetclientmats.runall
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetclientmats.runall?rev=332090&r1=332089&r2=332090&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetclientmats.runall (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetclientmats.runall Wed Nov 9 09:46:52 2005
@@ -1,3 +1,4 @@
+junitTests/derbynet/CompatibilityTest.java
jdbcapi/xaSimplePositive.sql
jdbcapi/xaStateTran.sql
jdbcapi/lobStreams.java
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetmats.runall
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetmats.runall?rev=332090&r1=332089&r2=332090&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetmats.runall (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetmats.runall Wed Nov 9 09:46:52 2005
@@ -19,7 +19,6 @@
derbynet/testij.java
derbynet/timeslice.java
derbynet/testSecMec.java
-jdbcapi/CompatibilityTest.java
jdbcapi/autoGeneratedJdbc30.java
jdbcapi/dbMetaDataJdbc30.java
jdbcapi/metadata.java
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/copyfiles.ant
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/copyfiles.ant?rev=332090&r1=332089&r2=332090&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/copyfiles.ant (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/copyfiles.ant Wed Nov 9 09:46:52 2005
@@ -1,4 +1,3 @@
-CompatibilityTest_app.properties
aclob.txt
autoGeneratedJdbc30_app.properties
batchUpdate_app.properties
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/CompatibilitySuite.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/CompatibilitySuite.java?rev=332090&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/CompatibilitySuite.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/CompatibilitySuite.java Wed Nov 9 09:46:52 2005
@@ -0,0 +1,599 @@
+/*
+
+ Derby - Class org.apache.derbyTesting.functionTests.tests.compatibility.CompatibilitySuite
+
+ Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed 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.
+
+ */
+/**
+ * <p>
+ * This is the JUnit suite verifying compatibility of Derby clients and
+ * servers across Derby version levels and supported VMs. When you want
+ * to add a new class of tests to this suite, just add the classname to
+ * the accumulator in suite().
+ * </p>
+ *
+ * @author Rick
+ */
+
+package org.apache.derbyTesting.functionTests.tests.junitTests.compatibility;
+
+import java.io.*;
+import java.sql.*;
+import java.util.*;
+
+import junit.framework.*;
+
+import org.apache.derbyTesting.functionTests.util.DerbyJUnitTest;
+
+public class CompatibilitySuite extends DerbyJUnitTest
+{
+ /////////////////////////////////////////////////////////////
+ //
+ // CONSTANTS
+ //
+ /////////////////////////////////////////////////////////////
+
+ // Supported versions of the db2jcc client.
+ public static final Version IBM_2_4 = new Version( 2, 4 );
+
+ // Supported versions of Derby.
+ public static final Version DRB_10_0 = new Version( 10, 0 );
+ public static final Version DRB_10_1 = new Version( 10, 1 );
+ public static final Version DRB_10_2 = new Version( 10, 2 );
+
+ // Supported VM versions.
+ public static final Version VM_1_3 = new Version( 1, 3 );
+ public static final Version VM_1_4 = new Version( 1, 4 );
+ public static final Version VM_1_5 = new Version( 1, 5 );
+
+ public static final String DEFAULT_USER_NAME = "APP";
+ public static final String DEFAULT_PASSWORD = "APP";
+
+ //
+ // These are properties for the Derby connection URL.
+ //
+ private static final String VERSION_PROPERTY = "java.version";
+ private static final String SERVER_URL = "jdbc:derby://localhost:1527/";
+ private static final String CREATE_PROPERTY = "create=true";
+
+ private static final int EXPECTED_CLIENT_COUNT = 1;
+
+ //
+ // Indexes into the array of client-specific strings. E.g., DB2JCC_CLIENT,
+ // DERBY_CLIENT, and EMBEDDED_CLIENT.
+ //
+ private static final int DATABASE_URL = 0;
+ private static final int DRIVER_NAME = DATABASE_URL + 1;
+
+ // indexed by DATABASE_URL and DRIVER_NAME
+ private static final String[] DB2JCC_CLIENT =
+ {
+ "jdbc:derby:net://localhost:1527/",
+ "com.ibm.db2.jcc.DB2Driver"
+ };
+ private static final String[] DERBY_CLIENT =
+ {
+ "jdbc:derby://localhost:1527/",
+ "org.apache.derby.jdbc.ClientDriver"
+ };
+ private static final String[] EMBEDDED_CLIENT =
+ {
+ "jdbc:derby:",
+ "org.apache.derby.jdbc.EmbeddedDriver"
+ };
+
+ private static final String[][] LEGAL_CLIENTS =
+ {
+ DB2JCC_CLIENT,
+ DERBY_CLIENT,
+ EMBEDDED_CLIENT
+ };
+
+ /////////////////////////////////////////////////////////////
+ //
+ // STATE
+ //
+ /////////////////////////////////////////////////////////////
+
+ private static String[] _defaultClientSettings; // one of the clients in LEGAL_CLIENTS
+ private static Driver _driver; // the corresponding jdbc driver
+ private static String _databaseName; // sandbox for tests
+ private static Version _clientVMLevel; // level of client-side vm
+ private static Version _driverLevel; // client rev level
+ private static Version _serverLevel; // server rev level
+
+ /////////////////////////////////////////////////////////////
+ //
+ // JUnit BEHAVIOR
+ //
+ /////////////////////////////////////////////////////////////
+
+ /**
+ * <p>
+ * JUnit boilerplate which adds as test cases all public methods
+ * whose names start with the string "test" in the named classes.
+ * When you want to add a new class of tests, just wire it into
+ * this suite.
+ * </p>
+ */
+ public static Test suite()
+ {
+ TestSuite testSuite = new TestSuite();
+
+ testSuite.addTestSuite( JDBCDriverTest.class );
+
+ return testSuite;
+ }
+
+
+ /////////////////////////////////////////////////////////////
+ //
+ // ENTRY POINT
+ //
+ /////////////////////////////////////////////////////////////
+
+ /**
+ * <p>
+ * Run JDBC compatibility tests using either the specified client or
+ * the client that is visible
+ * on the classpath. If there is more than one client on the classpath,
+ * exits with an error.
+ * </p>
+ *
+ * <ul>
+ * <li>arg[ 0 ] = required name of database to connect to</li>
+ * <li>arg[ 1 ] = optional driver to use. if not specified, we'll look for a
+ * client on the classpath</li>
+ * </ul>
+ */
+ public static void main( String args[] )
+ throws Exception
+ {
+ int exitStatus = FAILURE_EXIT;
+
+ if (
+ parseDebug() &&
+ parseArgs( args ) &&
+ parseVMLevel() &&
+ findClient() &&
+ findServer()
+ )
+ {
+ TestResult result = junit.textui.TestRunner.run( suite() );
+
+ exitStatus = result.errorCount() + result.failureCount();
+ }
+
+ Runtime.getRuntime().exit( exitStatus );
+ }
+
+ /////////////////////////////////////////////////////////////
+ //
+ // PUBLIC BEHAVIOR
+ //
+ /////////////////////////////////////////////////////////////
+
+ /**
+ * <p>
+ * Get the version of the server.
+ * </p>
+ */
+ public Version getServerVersion() { return _serverLevel; }
+
+ /**
+ * <p>
+ * Get the version of the client.
+ * </p>
+ */
+ public Version getDriverVersion() { return _driverLevel; }
+
+ /**
+ * <p>
+ * Get the vm level of the client.
+ * </p>
+ */
+ public Version getClientVMVersion() { return _clientVMLevel; }
+
+ /**
+ * <p>
+ * Return true if we're using the embedded driver.
+ * </p>
+ */
+ public boolean usingEmbeddedClient() { return ( _defaultClientSettings == EMBEDDED_CLIENT ); }
+
+ /////////////////////////////////////////////////////////////
+ //
+ // MINIONS
+ //
+ /////////////////////////////////////////////////////////////
+
+ ///////////////////
+ //
+ // GENERAL MINIONS
+ //
+ ///////////////////
+
+ //////////////////////////
+ //
+ // INITIALIZATION MINIONS
+ //
+ //////////////////////////
+
+ //
+ // Initialize client settings based on the client found.
+ // Return true if one and only one client found, false otherwise.
+ // We allow for the special case when we're running the embedded client
+ // off the current compiled class tree rather than off product jars.
+ //
+ private static boolean findClient()
+ throws Exception
+ {
+ //
+ // The client may have been specified on the command line.
+ // In that case, we don't bother looking for a client on
+ // the classpath.
+ //
+ if ( _defaultClientSettings != null ) { faultInDriver( _defaultClientSettings ); }
+ else
+ {
+ String currentClientName = null;
+ int legalCount = LEGAL_CLIENTS.length;
+ int foundCount = 0;
+
+ for ( int i = 0; i < legalCount; i++ )
+ {
+ String[] candidate = LEGAL_CLIENTS[ i ];
+
+ if ( faultInDriver( candidate ) )
+ {
+ _defaultClientSettings = candidate;
+ foundCount++;
+ }
+ }
+
+ if ( foundCount != EXPECTED_CLIENT_COUNT )
+ {
+ throw new Exception( "Wrong number of drivers: " + foundCount );
+ }
+ }
+
+ // Now make sure that the JDBC driver is what we expect
+
+ try {
+ _driver = DriverManager.getDriver( _defaultClientSettings[ DATABASE_URL ] );
+ _driverLevel = new Version( _driver.getMajorVersion(), _driver.getMinorVersion() );
+ }
+ catch (SQLException e)
+ {
+ printStackTrace( e );
+
+ throw new Exception
+ ( "Driver doesn't understand expected URL: " + _defaultClientSettings[ DATABASE_URL ] );
+ }
+
+ println
+ (
+ "Driver " + _driver.getClass().getName() +
+ " Version = " + _driverLevel
+ );
+
+ return true;
+ }
+
+ //
+ // Initialize server settings. Assumes that you have called
+ // findClient().
+ //
+ private static boolean findServer()
+ throws Exception
+ {
+ try {
+ Connection conn = getConnection();
+ DatabaseMetaData dmd = conn.getMetaData();
+ String dbProductVersion = dmd.getDatabaseProductVersion();
+
+ _serverLevel = new Version( dbProductVersion );
+ }
+ catch (Exception e)
+ {
+ printStackTrace( e );
+
+ throw new Exception( "Error lookup up server info: " + e.getMessage() );
+ }
+
+ println( "Server Version = " + _serverLevel );
+
+ return true;
+ }
+
+ protected static boolean faultInDriver( String[] clientSettings )
+ {
+ String currentClientName = clientSettings[ DRIVER_NAME ];
+
+ try {
+ Class.forName( currentClientName );
+
+ return true;
+ }
+ catch (Exception e)
+ {
+ println( "Could not find " + currentClientName );
+ return false;
+ }
+ }
+
+ private static boolean parseVMLevel()
+ throws Exception
+ {
+ String vmVersion = System.getProperty( VERSION_PROPERTY );
+
+ try {
+ _clientVMLevel = new Version( vmVersion );
+ }
+ catch (NumberFormatException e)
+ {
+ throw new Exception( "Badly formatted vm version: " + vmVersion );
+ }
+
+ println( "VM Version = " + _clientVMLevel );
+
+ return true;
+ }
+
+ private static boolean parseArgs( String args[] )
+ throws Exception
+ {
+ if ( ( args == null ) || (args.length == 0 ) )
+ { throw new Exception( "Missing database name." ); }
+
+ _databaseName = args[ 0 ];
+
+ if ( (args.length > 1) && !"".equals( args[ 1 ] ) )
+ {
+ String desiredClientName = args[ 1 ];
+ int count = LEGAL_CLIENTS.length;
+
+ for ( int i = 0; i < count; i++ )
+ {
+ String[] candidate = LEGAL_CLIENTS[ i ];
+
+ if ( desiredClientName.equals( candidate[ DRIVER_NAME ] ) )
+ {
+ _defaultClientSettings = candidate;
+ break;
+ }
+ }
+
+ if ( _defaultClientSettings == null )
+ {
+ throw new Exception
+ ( "Could not find client " + desiredClientName + " on the classpath." );
+ }
+ }
+
+ return true;
+ }
+
+ //////////////////////////
+ //
+ // CONNECTION MINIONS
+ //
+ //////////////////////////
+
+ // Get a connection to the server.
+ protected static Connection getConnection()
+ throws Exception
+ {
+ return getConnection( _defaultClientSettings, _databaseName, new Properties() );
+ }
+ protected static Connection getConnection
+ (
+ String[] clientSettings,
+ String databaseName,
+ Properties properties
+ )
+ throws Exception
+ {
+ faultInDriver( clientSettings );
+
+ properties.put( "user", DEFAULT_USER_NAME );
+ properties.put( "password", DEFAULT_PASSWORD );
+ properties.put( "retreiveMessagesFromServerOnGetMessage", "true" );
+
+ Connection conn = DriverManager.getConnection
+ ( makeDatabaseURL( clientSettings, databaseName ), properties );
+
+ println( "Connection is a " + conn.getClass().getName() );
+
+ return conn;
+ }
+
+ // Build the connection URL.
+ private static String makeDatabaseURL( String[] clientSettings, String databaseName )
+ {
+ return clientSettings[ DATABASE_URL ] + databaseName;
+ }
+
+
+ ///////////////
+ //
+ // SQL MINIONS
+ //
+ ///////////////
+
+ /**
+ * <p>
+ * Create an empty database.
+ * </p>
+ */
+ protected void createDB( String databaseName )
+ throws Exception
+ {
+ String[] clientSettings = _defaultClientSettings;
+ String dbURL = makeDatabaseURL( clientSettings, databaseName );
+
+ dbURL = dbURL + ';' + CREATE_PROPERTY;
+
+ Properties properties = new Properties();
+
+ properties.put( "user", DEFAULT_USER_NAME );
+ properties.put( "password", DEFAULT_PASSWORD );
+
+ faultInDriver( clientSettings );
+
+ Connection conn = DriverManager.getConnection( dbURL, properties );
+
+ conn.close();
+ }
+
+ //
+ // Thin wrapper around jdbc layer to support debugging.
+ //
+ protected PreparedStatement prepare( Connection conn, String text )
+ throws SQLException
+ {
+ println( "Preparing: " + text );
+
+ return conn.prepareStatement( text );
+ }
+
+ /////////////////////////////////////////////////////////////
+ //
+ // INNER CLASSES
+ //
+ /////////////////////////////////////////////////////////////
+
+ /**
+ * <p>
+ * This helper class exposes an entry point for creating an empty database.
+ * </p>
+ */
+ public static final class Creator
+ {
+ private static CompatibilitySuite _driver = new CompatibilitySuite();
+
+ /**
+ * <p>
+ * Wait for server to come up, then create the database.
+ * </p>
+ *
+ * <ul>
+ * <li>args[ 0 ] = name of database to create.</li>
+ * </ul>
+ */
+ public static void main( String[] args )
+ throws Exception
+ {
+ String databaseName = args[ 0 ];
+
+ CompatibilitySuite.findClient();
+
+ _driver.createDB( databaseName );
+ }
+
+ }
+
+ /**
+ * <p>
+ * A class for storing a major and minor version number. This class
+ * assumes that more capable versions compare greater than less capable versions.
+ * </p>
+ */
+ public static final class Version implements Comparable
+ {
+ private int _major;
+ private int _minor;
+
+ public Version( int major, int minor )
+ {
+ constructorMinion( major, minor );
+ }
+
+ public Version( String desc )
+ throws NumberFormatException
+ {
+ StringTokenizer tokens = new StringTokenizer( desc, "." );
+
+ constructorMinion
+ (
+ java.lang.Integer.parseInt( tokens.nextToken() ),
+ java.lang.Integer.parseInt( tokens.nextToken() )
+ );
+ }
+
+ private void constructorMinion( int major, int minor )
+ {
+ _major = major;
+ _minor = minor;
+ }
+
+ /**
+ * <p>
+ * Returns true if this Version is at least as advanced
+ * as that Version.
+ * </p>
+ */
+ public boolean atLeast( Version that )
+ {
+ return this.compareTo( that ) > -1;
+ }
+
+
+ ////////////////////////////////////////////////////////
+ //
+ // Comparable BEHAVIOR
+ //
+ ////////////////////////////////////////////////////////
+
+ public int compareTo( Object other )
+ {
+ if ( other == null ) { return -1; }
+ if ( !( other instanceof Version ) ) { return -1; }
+
+ Version that = (Version) other;
+
+ if ( this._major < that._major ) { return -1; }
+ if ( this._major > that._major ) { return 1; }
+
+ return this._minor - that._minor;
+ }
+
+ ////////////////////////////////////////////////////////
+ //
+ // Object OVERLOADS
+ //
+ ////////////////////////////////////////////////////////
+
+ public String toString()
+ {
+ return Integer.toString( _major ) + '.' + Integer.toString( _minor );
+ }
+
+ public boolean equals( Object other )
+ {
+ return (compareTo( other ) == 0);
+ }
+
+ public int hashCode()
+ {
+ return _major ^ _minor;
+ }
+
+ }
+
+
+
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/CompatibilitySuite.java
------------------------------------------------------------------------------
svn:eol-style = native
Copied: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/JDBCDriverTest.java (from r332087, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/JDBCDriverTest.java)
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/JDBCDriverTest.java?p2=db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/JDBCDriverTest.java&p1=db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/JDBCDriverTest.java&r1=332087&r2=332090&rev=332090&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/JDBCDriverTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/JDBCDriverTest.java Wed Nov 9 09:46:52 2005
@@ -26,7 +26,7 @@
* @author Rick
*/
-package org.apache.derbyTesting.functionTests.tests.compatibility;
+package org.apache.derbyTesting.functionTests.tests.junitTests.compatibility;
import java.io.*;
import java.math.*;
@@ -37,7 +37,7 @@
import org.apache.derbyTesting.functionTests.util.DerbyJUnitTest;
-public class JDBCDriverTest extends DerbyJUnitTest
+public class JDBCDriverTest extends CompatibilitySuite
{
/////////////////////////////////////////////////////////////
//
@@ -45,31 +45,9 @@
//
/////////////////////////////////////////////////////////////
- /** If you set this startup property to true, you will get chatty output. */
- public static final String DEBUG_FLAG = "drb.tests.debug";
-
- public static final int SUCCESS_EXIT = 0;
- public static final int FAILURE_EXIT = 1;
-
- //
- // These are properties for the Derby connection URL.
- //
- private static final String VERSION_PROPERTY = "java.version";
- private static final String SERVER_URL = "jdbc:derby://localhost:1527/";
- private static final String CREATE_PROPERTY = "create=true";
-
private static final String ALL_TYPES_TABLE = "allTypesTable";
private static final String KEY_COLUMN = "keyCol";
- private static final int EXPECTED_CLIENT_COUNT = 1;
-
- //
- // Indexes into the array of client-specific strings. E.g., DB2JCC_CLIENT,
- // DERBY_CLIENT, and EMBEDDED_CLIENT.
- //
- private static final int DATABASE_URL = 0;
- private static final int DRIVER_NAME = DATABASE_URL + 1;
-
//
// Data values to be stuffed into columns of ALL_TYPES_TABLE.
//
@@ -84,46 +62,6 @@
private static final boolean Y = true;
private static final boolean _ = false;
- // indexed by DATABASE_URL and DRIVER_NAME
- private static final String[] DB2JCC_CLIENT =
- {
- "jdbc:derby:net://localhost:1527/",
- "com.ibm.db2.jcc.DB2Driver"
- };
- private static final String[] DERBY_CLIENT =
- {
- "jdbc:derby://localhost:1527/",
- "org.apache.derby.jdbc.ClientDriver"
- };
- private static final String[] EMBEDDED_CLIENT =
- {
- "jdbc:derby:",
- "org.apache.derby.jdbc.EmbeddedDriver"
- };
-
- private static final String[][] LEGAL_CLIENTS =
- {
- DB2JCC_CLIENT,
- DERBY_CLIENT,
- EMBEDDED_CLIENT
- };
-
- private static final String DEFAULT_USER_NAME = "APP";
- private static final String DEFAULT_PASSWORD = "APP";
-
- // Supported versions of the db2jcc client.
- private static final Version IBM_2_4 = new Version( 2, 4 );
-
- // Supported versions of Derby.
- private static final Version DRB_10_0 = new Version( 10, 0 );
- private static final Version DRB_10_1 = new Version( 10, 1 );
- private static final Version DRB_10_2 = new Version( 10, 2 );
-
- // Supported VM versions.
- private static final Version VM_1_3 = new Version( 1, 3 );
- private static final Version VM_1_4 = new Version( 1, 4 );
- private static final Version VM_1_5 = new Version( 1, 5 );
-
//
// This table declares the datatypes supported by Derby and the earliest
// versions of the Derby and the db2jcc client which support these
@@ -265,17 +203,6 @@
//
/////////////////////////////////////////////////////////////
- private static boolean _debug; // if true, we print chatty diagnostics
-
- private static PrintStream _outputStream = System.out; // where to print debug output
-
- private static String[] _defaultClientSettings; // one of the clients in LEGAL_CLIENTS
- private static Driver _driver; // the corresponding jdbc driver
- private static String _databaseName; // sandbox for tests
- private static Version _clientVMLevel; // level of client-side vm
- private static Version _driverLevel; // client rev level
- private static Version _serverLevel; // server rev level
-
// map derby type name to type descriptor
private static HashMap _types = new HashMap(); // maps Derby type names to TypeDescriptors
@@ -292,65 +219,6 @@
/////////////////////////////////////////////////////////////
//
- // JUnit BEHAVIOR
- //
- /////////////////////////////////////////////////////////////
-
- /**
- * <p>
- * JUnit boilerplate which adds as test cases all public methods
- * whose names start with the string "test".
- * </p>
- */
- public static Test suite()
- {
- return new TestSuite( JDBCDriverTest.class );
- }
-
-
- /////////////////////////////////////////////////////////////
- //
- // ENTRY POINT
- //
- /////////////////////////////////////////////////////////////
-
- /**
- * <p>
- * Run JDBC compatibility tests using either the specified client or
- * the client that is visible
- * on the classpath. If there is more than one client on the classpath,
- * exits with an error.
- * </p>
- *
- * <ul>
- * <li>arg[ 0 ] = required name of database to connect to</li>
- * <li>arg[ 1 ] = optional driver to use. if not specified, we'll look for a
- * client on the classpath</li>
- * </ul>
- */
- public static void main( String args[] )
- throws Exception
- {
- int exitStatus = FAILURE_EXIT;
-
- if (
- parseDebug() &&
- parseArgs( args ) &&
- parseVMLevel() &&
- findClient() &&
- findServer()
- )
- {
- TestResult result = junit.textui.TestRunner.run( suite() );
-
- exitStatus = result.errorCount() + result.failureCount();
- }
-
- Runtime.getRuntime().exit( exitStatus );
- }
-
- /////////////////////////////////////////////////////////////
- //
// TEST ENTRY POINTS
//
/////////////////////////////////////////////////////////////
@@ -473,7 +341,7 @@
{
TypeDescriptor type = ALL_TYPES[ i ];
- if ( _serverLevel.atLeast( type.getDerbyVersion() ) )
+ if ( getServerVersion().atLeast( type.getDerbyVersion() ) )
{
String typeName = type.getDerbyTypeName();
String columnDesc = doubleQuote( typeName );
@@ -520,7 +388,7 @@
{
TypeDescriptor type = ALL_TYPES[ i ];
- if ( _serverLevel.atLeast( type.getDerbyVersion() ) )
+ if ( getServerVersion().atLeast( type.getDerbyVersion() ) )
{
String typeName = type.getDerbyTypeName();
String columnDesc = doubleQuote( typeName );
@@ -600,7 +468,7 @@
{
TypeDescriptor type = ALL_TYPES[ i ];
- if ( _serverLevel.atLeast( type.getDerbyVersion() ) )
+ if ( getServerVersion().atLeast( type.getDerbyVersion() ) )
{
String columnName = type.getDerbyTypeName();
Object expectedValue = row[ i ];
@@ -647,7 +515,7 @@
private int rsmdTypeKludge( int originalJDbcType )
{
// The embedded client does the right thing.
- if ( _defaultClientSettings == EMBEDDED_CLIENT ) { return originalJDbcType; }
+ if ( usingEmbeddedClient() ) { return originalJDbcType; }
switch( originalJDbcType )
{
@@ -674,7 +542,7 @@
TypeDescriptor type = ALL_TYPES[ i ];
Object value = row[ i ];
- if ( _serverLevel.atLeast( type.getDerbyVersion() ) )
+ if ( getServerVersion().atLeast( type.getDerbyVersion() ) )
{
setParameter( ps, param++, type, value );
}
@@ -782,7 +650,7 @@
{
TypeDescriptor type = ALL_TYPES[ i ];
- if ( _serverLevel.atLeast( type.getDerbyVersion() ) )
+ if ( getServerVersion().atLeast( type.getDerbyVersion() ) )
{
String typeName = type.getDerbyTypeName();
String columnDesc = doubleQuote( typeName ) + '\t' + typeName;
@@ -840,82 +708,6 @@
close( ps );
}
- ///////////////
- //
- // SQL MINIONS
- //
- ///////////////
-
- /**
- * <p>
- * Create an empty database.
- * </p>
- */
- public void createDB( String databaseName )
- throws Exception
- {
- String[] clientSettings = _defaultClientSettings;
- String dbURL = makeDatabaseURL( clientSettings, databaseName );
-
- dbURL = dbURL + ';' + CREATE_PROPERTY;
-
- Properties properties = new Properties();
-
- properties.put( "user", DEFAULT_USER_NAME );
- properties.put( "password", DEFAULT_PASSWORD );
-
- faultInDriver( clientSettings );
-
- Connection conn = DriverManager.getConnection( dbURL, properties );
-
- conn.close();
- }
-
- // Get a connection to the server.
- private static Connection getConnection()
- throws Exception
- {
- return getConnection( _defaultClientSettings, _databaseName, new Properties() );
- }
- private static Connection getConnection
- (
- String[] clientSettings,
- String databaseName,
- Properties properties
- )
- throws Exception
- {
- faultInDriver( clientSettings );
-
- properties.put( "user", DEFAULT_USER_NAME );
- properties.put( "password", DEFAULT_PASSWORD );
- properties.put( "retreiveMessagesFromServerOnGetMessage", "true" );
-
- Connection conn = DriverManager.getConnection
- ( makeDatabaseURL( clientSettings, databaseName ), properties );
-
- println( "Connection is a " + conn.getClass().getName() );
-
- return conn;
- }
-
- // Build the connection URL.
- private static String makeDatabaseURL( String[] clientSettings, String databaseName )
- {
- return clientSettings[ DATABASE_URL ] + databaseName;
- }
-
- //
- // Thin wrapper around jdbc layer to support debugging.
- //
- private PreparedStatement prepare( Connection conn, String text )
- throws SQLException
- {
- println( "Preparing: " + text );
-
- return conn.prepareStatement( text );
- }
-
//
// Logic for stuffing a data value into a column, given its type.
//
@@ -1113,335 +905,11 @@
catch (SQLException e) {}
}
- ///////////////////
- //
- // GENERAL MINIONS
- //
- ///////////////////
-
- // Debug code to print chatty informational messages.
- private static void println( String text )
- {
- if ( _debug )
- {
- _outputStream.println( text );
- _outputStream.flush();
- }
- }
-
- // Print out a stack trace
- private static void printStackTrace( Throwable t )
- {
- while ( t != null )
- {
- t.printStackTrace( _outputStream );
-
- if ( t instanceof SQLException ) { t = ((SQLException) t).getNextException(); }
- else { break; }
- }
- }
-
- //
- // Return a meaningful exit status so that calling scripts can take
- // evasive action.
- //
- private void exit( int exitStatus )
- {
- Runtime.getRuntime().exit( exitStatus );
- }
-
- //////////////////////////
- //
- // INITIALIZATION MINIONS
- //
- //////////////////////////
-
- //
- // Initialize client settings based on the client found.
- // Return true if one and only one client found, false otherwise.
- // We allow for the special case when we're running the embedded client
- // off the current compiled class tree rather than off product jars.
- //
- private static boolean findClient()
- throws Exception
- {
- //
- // The client may have been specified on the command line.
- // In that case, we don't bother looking for a client on
- // the classpath.
- //
- if ( _defaultClientSettings != null ) { faultInDriver( _defaultClientSettings ); }
- else
- {
- String currentClientName = null;
- int legalCount = LEGAL_CLIENTS.length;
- int foundCount = 0;
-
- for ( int i = 0; i < legalCount; i++ )
- {
- String[] candidate = LEGAL_CLIENTS[ i ];
-
- if ( faultInDriver( candidate ) )
- {
- _defaultClientSettings = candidate;
- foundCount++;
- }
- }
-
- if ( foundCount != EXPECTED_CLIENT_COUNT )
- {
- throw new Exception( "Wrong number of drivers: " + foundCount );
- }
- }
-
- // Now make sure that the JDBC driver is what we expect
-
- try {
- _driver = DriverManager.getDriver( _defaultClientSettings[ DATABASE_URL ] );
- _driverLevel = new Version( _driver.getMajorVersion(), _driver.getMinorVersion() );
- }
- catch (SQLException e)
- {
- printStackTrace( e );
-
- throw new Exception
- ( "Driver doesn't understand expected URL: " + _defaultClientSettings[ DATABASE_URL ] );
- }
-
- println
- (
- "Driver " + _driver.getClass().getName() +
- " Version = " + _driverLevel
- );
-
- return true;
- }
-
- //
- // Initialize server settings. Assumes that you have called
- // findClient().
- //
- private static boolean findServer()
- throws Exception
- {
- try {
- Connection conn = getConnection();
- DatabaseMetaData dmd = conn.getMetaData();
- String dbProductVersion = dmd.getDatabaseProductVersion();
-
- _serverLevel = new Version( dbProductVersion );
- }
- catch (Exception e)
- {
- printStackTrace( e );
-
- throw new Exception( "Error lookup up server info: " + e.getMessage() );
- }
-
- println( "Server Version = " + _serverLevel );
-
- return true;
- }
-
- private static boolean faultInDriver( String[] clientSettings )
- {
- String currentClientName = clientSettings[ DRIVER_NAME ];
-
- try {
- Class.forName( currentClientName );
-
- return true;
- }
- catch (Exception e)
- {
- println( "Could not find " + currentClientName );
- return false;
- }
- }
-
- private static boolean parseDebug()
- {
- _debug = Boolean.getBoolean( DEBUG_FLAG );
-
- return true;
- }
-
- private static boolean parseVMLevel()
- throws Exception
- {
- String vmVersion = System.getProperty( VERSION_PROPERTY );
-
- try {
- _clientVMLevel = new Version( vmVersion );
- }
- catch (NumberFormatException e)
- {
- throw new Exception( "Badly formatted vm version: " + vmVersion );
- }
-
- println( "VM Version = " + _clientVMLevel );
-
- return true;
- }
-
- private static boolean parseArgs( String args[] )
- throws Exception
- {
- if ( ( args == null ) || (args.length == 0 ) )
- { throw new Exception( "Missing database name." ); }
-
- _databaseName = args[ 0 ];
-
- if ( (args.length > 1) && !"".equals( args[ 1 ] ) )
- {
- String desiredClientName = args[ 1 ];
- int count = LEGAL_CLIENTS.length;
-
- for ( int i = 0; i < count; i++ )
- {
- String[] candidate = LEGAL_CLIENTS[ i ];
-
- if ( desiredClientName.equals( candidate[ DRIVER_NAME ] ) )
- {
- _defaultClientSettings = candidate;
- break;
- }
- }
-
- if ( _defaultClientSettings == null )
- {
- throw new Exception
- ( "Could not find client " + desiredClientName + " on the classpath." );
- }
- }
-
- return true;
- }
-
-
/////////////////////////////////////////////////////////////
//
// INNER CLASSES
//
/////////////////////////////////////////////////////////////
-
- /**
- * <p>
- * This helper class exposes an entry point for creating an empty database.
- * </p>
- */
- public static final class Creator
- {
- private static JDBCDriverTest _driver = new JDBCDriverTest();
-
- /**
- * <p>
- * Wait for server to come up, then create the database.
- * </p>
- *
- * <ul>
- * <li>args[ 0 ] = name of database to create.</li>
- * </ul>
- */
- public static void main( String[] args )
- throws Exception
- {
- String databaseName = args[ 0 ];
-
- JDBCDriverTest.findClient();
-
- _driver.createDB( databaseName );
- }
-
- }
-
- /**
- * <p>
- * A class for storing a major and minor version number. This class
- * assumes that more capable versions compare greater than less capable versions.
- * </p>
- */
- public static final class Version implements Comparable
- {
- private int _major;
- private int _minor;
-
- public Version( int major, int minor )
- {
- constructorMinion( major, minor );
- }
-
- public Version( String desc )
- throws NumberFormatException
- {
- StringTokenizer tokens = new StringTokenizer( desc, "." );
-
- constructorMinion
- (
- java.lang.Integer.parseInt( tokens.nextToken() ),
- java.lang.Integer.parseInt( tokens.nextToken() )
- );
- }
-
- private void constructorMinion( int major, int minor )
- {
- _major = major;
- _minor = minor;
- }
-
- /**
- * <p>
- * Returns true if this Version is at least as advanced
- * as that Version.
- * </p>
- */
- public boolean atLeast( Version that )
- {
- return this.compareTo( that ) > -1;
- }
-
-
- ////////////////////////////////////////////////////////
- //
- // Comparable BEHAVIOR
- //
- ////////////////////////////////////////////////////////
-
- public int compareTo( Object other )
- {
- if ( other == null ) { return -1; }
- if ( !( other instanceof Version ) ) { return -1; }
-
- Version that = (Version) other;
-
- if ( this._major < that._major ) { return -1; }
- if ( this._major > that._major ) { return 1; }
-
- return this._minor - that._minor;
- }
-
- ////////////////////////////////////////////////////////
- //
- // Object OVERLOADS
- //
- ////////////////////////////////////////////////////////
-
- public String toString()
- {
- return Integer.toString( _major ) + '.' + Integer.toString( _minor );
- }
-
- public boolean equals( Object other )
- {
- return (compareTo( other ) == 0);
- }
-
- public int hashCode()
- {
- return _major ^ _minor;
- }
-
- }
/**
* <p>
Copied: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/Pinger.java (from r332087, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/Pinger.java)
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/Pinger.java?p2=db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/Pinger.java&p1=db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/Pinger.java&r1=332087&r2=332090&rev=332090&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/Pinger.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/Pinger.java Wed Nov 9 09:46:52 2005
@@ -24,7 +24,7 @@
*
* @author Rick
*/
-package org.apache.derbyTesting.functionTests.tests.compatibility;
+package org.apache.derbyTesting.functionTests.tests.junitTests.compatibility;
import org.apache.derby.drda.NetworkServerControl;
Copied: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/README.html (from r332087, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/README.html)
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/README.html?p2=db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/README.html&p1=db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/README.html&r1=332087&r2=332090&rev=332090&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/README.html (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/README.html Wed Nov 9 09:46:52 2005
@@ -118,7 +118,7 @@
outDir=$1
trunkDir=$2
-COMPAT_DIR=$trunkDir/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility
+COMPAT_DIR=$trunkDir/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility
rm -rf $outDir
mkdir $outDir
Copied: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/build.xml (from r332087, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/build.xml)
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/build.xml?p2=db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/build.xml&p1=db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/build.xml&r1=332087&r2=332090&rev=332090&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/build.xml (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/build.xml Wed Nov 9 09:46:52 2005
@@ -4,7 +4,7 @@
<!-- Derby build file -->
<!-- ==================================================================== -->
-<project default="FTOtestsubdir" basedir="../../../../../../../.." >
+<project default="FTOtestsubdir" basedir="../../../../../../../../.." >
<!-- User settings -->
<property file="${user.home}/ant.properties"/>
@@ -34,7 +34,7 @@
<!-- derby testing specific properties files -->
<property file="${ant.home}/properties/derbytesting.properties"/>
<property file="${user.home}/properties/derbytesting.properties"/>
- <property name="this.dir" value="${derby.testing.functest.dir}/tests/compatibility"/>
+ <property name="this.dir" value="${derby.testing.functest.dir}/tests/junitTests/compatibility"/>
<!-- ============ Begin Targets ============== -->
Copied: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/testScript.xml (from r332087, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/testScript.xml)
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/testScript.xml?p2=db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/testScript.xml&p1=db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/testScript.xml&r1=332087&r2=332090&rev=332090&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/testScript.xml (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/testScript.xml Wed Nov 9 09:46:52 2005
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!--
- Derby - Script org/apache/derbyTesting/functionTests/tests/compatibility/testScript.xml
+ Derby - Script org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/testScript.xml
Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
@@ -19,7 +19,7 @@
-->
-<project default="allTests" basedir="../../../../../../../..">
+<project default="allTests" basedir="../../../../../../../../..">
<description>
Driver for running compatibility tests, mixing and matching
clients and servers at different Derby rev levels on different
@@ -39,6 +39,7 @@
10.0.2.1_lib Directory containing the released 10.0.2.1 jars.
10.1.1.0_lib Directory containing the released 10.1.1.0 jars.
+ 10.1.2.0_lib Directory containing the released 10.1.2.0 jars.
trunk_lib Directory containing jars built from the development mainline (trunk).
db2jcc_lib Directory containing the db2jcc jars (see trunk/java/testing/README.htm).
@@ -65,6 +66,8 @@
bring down server
}
}
+
+ Note that the test exits as soon as one combination fails.
</description>
<property file="${user.home}/ant.properties"/>
@@ -80,10 +83,12 @@
<property name="SERVER_10.0.2.1" value="${10.0.2.1_lib}/derby.jar;${10.0.2.1_lib}/derbynet.jar"/>
<property name="SERVER_10.1.1.0" value="${10.1.1.0_lib}/derby.jar;${10.1.1.0_lib}/derbynet.jar"/>
+ <property name="SERVER_10.1.2.0" value="${10.1.2.0_lib}/derby.jar;${10.1.2.0_lib}/derbynet.jar"/>
<property name="SERVER_TRUNK" value="${trunk_lib}/derby.jar;${trunk_lib}/derbynet.jar"/>
<property name="CLIENT_DB2JCC" value="${db2jcc_lib}/db2jcc.jar;${db2jcc_lib}/db2jcc_license_c.jar"/>
<property name="CLIENT_10.1.1.0" value="${10.1.1.0_lib}/derbyclient.jar"/>
+ <property name="CLIENT_10.1.2.0" value="${10.1.2.0_lib}/derbyclient.jar"/>
<property name="CLIENT_TRUNK" value="${trunk_lib}/derbyclient.jar"/>
<property name="TEST_JARS" value="${trunk_lib}/derbyTesting.jar;${junit}"/>
@@ -93,7 +98,7 @@
<property name="VM_DEFAULT" value="${VM_1.4}"/>
- <property name="JDBC_SUITE" value="org.apache.derbyTesting.functionTests.tests.compatibility.JDBCDriverTest"/>
+ <property name="JDBC_SUITE" value="org.apache.derbyTesting.functionTests.tests.junitTests.compatibility.CompatibilitySuite"/>
<property name="EMBEDDED_CLIENT" value="org.apache.derby.jdbc.EmbeddedDriver"/>
<!-- May be overridden on the command line -->
@@ -109,6 +114,7 @@
<target
name="cleanup"
+ depends="_vetSetup"
description="Brings down the server in case it is still running."
>
@@ -121,14 +127,14 @@
description="Run all compatibility tests."
>
- <antcall target="jdbcCompatibility"/>
+ <antcall target="compatibility"/>
</target>
<target
- name="jdbcCompatibility"
+ name="compatibility"
depends="cleanup"
- description="Run jdbc compatibility tests against all combinations."
+ description="Run compatibility tests against all combinations."
>
<antcall target="embeddedTrunk"/>
@@ -228,6 +234,12 @@
<antcall target="_forServerVersion">
<param name="fsvnVM" value="${fsvVM}"/>
+ <param name="fsvnCP" value="${SERVER_10.1.2.0}"/>
+ <param name="fsvnName" value="${fsvName}_server10.1.2.0"/>
+ </antcall>
+
+ <antcall target="_forServerVersion">
+ <param name="fsvnVM" value="${fsvVM}"/>
<param name="fsvnCP" value="${SERVER_10.1.1.0}"/>
<param name="fsvnName" value="${fsvName}_server10.1.1.0"/>
</antcall>
@@ -298,6 +310,12 @@
<antcall target="_forClientVersion">
<param name="fcvnVM" value="${fcvVM}"/>
+ <param name="fcvnCP" value="${CLIENT_10.1.2.0}"/>
+ <param name="fcvnName" value="${fcvName}_clientDerby10.1.2.0"/>
+ </antcall>
+
+ <antcall target="_forClientVersion">
+ <param name="fcvnVM" value="${fcvVM}"/>
<param name="fcvnCP" value="${CLIENT_10.1.1.0}"/>
<param name="fcvnName" value="${fcvName}_clientDerby10.1.1.0"/>
</antcall>
@@ -450,7 +468,7 @@
<arg value="-cp"/>
<arg path="${FULL_TRUNK}"/>
- <arg value="org.apache.derbyTesting.functionTests.tests.compatibility.Pinger"/>
+ <arg value="org.apache.derbyTesting.functionTests.tests.junitTests.compatibility.Pinger"/>
</exec>
@@ -523,6 +541,121 @@
${summaryMessage}
</echo>
+
+ </target>
+
+<!--
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!!
+!! CLASSPATH/VM VETTING
+!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+-->
+
+ <!-- Check that classpaths and vms look good -->
+ <target name="_vetSetup">
+
+ <antcall target="_vetClasspath"/>
+ <antcall target="_vetVMs"/>
+
+ </target>
+
+ <!-- Check that classpaths look good -->
+ <target name="_vetClasspath">
+
+ <antcall target="_vetServer"> <param name="vsLib" value="${10.0.2.1_lib}"/> </antcall>
+ <antcall target="_vetServer"> <param name="vsLib" value="${10.1.1.0_lib}"/> </antcall>
+ <antcall target="_vetServer"> <param name="vsLib" value="${10.1.2.0_lib}"/> </antcall>
+ <antcall target="_vetServer"> <param name="vsLib" value="${trunk_lib}"/> </antcall>
+
+ <antcall target="_vetClient"> <param name="vcLib" value="${10.1.1.0_lib}"/> </antcall>
+ <antcall target="_vetClient"> <param name="vcLib" value="${10.1.2.0_lib}"/> </antcall>
+ <antcall target="_vetClient"> <param name="vcLib" value="${trunk_lib}"/> </antcall>
+
+ <antcall target="_vetDb2Client"/>
+
+ </target>
+
+ <!-- Check that required db2 client jars are visible -->
+ <target name="_vetDb2Client">
+
+ <antcall target="_vetJar">
+ <param name="vjLib" value="${db2jcc_lib}"/>
+ <param name="vjJar" value="db2jcc.jar"/>
+ </antcall>
+
+ <antcall target="_vetJar">
+ <param name="vjLib" value="${db2jcc_lib}"/>
+ <param name="vjJar" value="db2jcc_license_c.jar"/>
+ </antcall>
+
+ </target>
+
+ <!-- Check that required client jar files are visible -->
+ <target name="_vetClient">
+
+ <antcall target="_vetJar">
+ <param name="vjLib" value="${vcLib}"/>
+ <param name="vjJar" value="derbyclient.jar"/>
+ </antcall>
+
+ </target>
+
+ <!-- Check that required server jar files are visible -->
+ <target name="_vetServer">
+
+ <antcall target="_vetJar">
+ <param name="vjLib" value="${vsLib}"/>
+ <param name="vjJar" value="derby.jar"/>
+ </antcall>
+
+ <antcall target="_vetJar">
+ <param name="vjLib" value="${vsLib}"/>
+ <param name="vjJar" value="derbynet.jar"/>
+ </antcall>
+
+ </target>
+
+ <!-- Check that required jarfile is visible -->
+ <target name="_vetJar">
+
+ <fail>
+ <condition>
+ <not>
+ <available file="${vjLib}/${vjJar}"/>
+ </not>
+ </condition>
+ Cannot find jar file ${vjJar} in directory ${vjLib}.
+ Make sure that your ant.properties contains the correct
+ values for all properties described in the header comment
+ (-projecthelp) of this script.
+ </fail>
+
+ </target>
+
+ <!-- Check that required vms are visible -->
+ <target name="_vetVMs">
+
+ <antcall target="_vetVM"> <param name="vv" value="${j13lib}"/> </antcall>
+ <antcall target="_vetVM"> <param name="vv" value="${j14lib}"/> </antcall>
+ <antcall target="_vetVM"> <param name="vv" value="${jdk15}"/> </antcall>
+
+ </target>
+
+ <!-- Check that required vm is visible -->
+ <target name="_vetVM">
+
+ <fail>
+ <condition>
+ <not>
+ <available file="${vv}" type="dir"/>
+ </not>
+ </condition>
+ Cannot find VM ${vv}.
+ Make sure that your ant.properties contains the correct
+ values for all properties described in the header comment
+ (-projecthelp) of this script.
+ </fail>
</target>
Copied: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/CompatibilityTest.java (from r331635, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/CompatibilityTest.java)
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/CompatibilityTest.java?p2=db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/CompatibilityTest.java&p1=db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/CompatibilityTest.java&r1=331635&r2=332090&rev=332090&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/CompatibilityTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/CompatibilityTest.java Wed Nov 9 09:46:52 2005
@@ -25,12 +25,12 @@
*
* @author Rick
*/
-package org.apache.derbyTesting.functionTests.tests.jdbcapi;
+package org.apache.derbyTesting.functionTests.tests.junitTests.derbynet;
import java.sql.*;
import org.apache.derby.tools.ij;
-import org.apache.derbyTesting.functionTests.tests.compatibility.JDBCDriverTest;
+import org.apache.derbyTesting.functionTests.tests.junitTests.compatibility.CompatibilitySuite;
public class CompatibilityTest
{
@@ -68,7 +68,7 @@
ij.getPropertyArg( args );
Connection conn = ij.startJBMS();
- JDBCDriverTest.main( new String[] { DATABASE_NAME, NETWORK_CLIENT_NAME } );
+ CompatibilitySuite.main( new String[] { DATABASE_NAME, NETWORK_CLIENT_NAME } );
}
/////////////////////////////////////////////////////////////
Copied: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/CompatibilityTest_app.properties (from r331635, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/CompatibilityTest_app.properties)
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/CompatibilityTest_app.properties?p2=db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/CompatibilityTest_app.properties&p1=db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/CompatibilityTest_app.properties&r1=331635&r2=332090&rev=332090&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/CompatibilityTest_app.properties (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/CompatibilityTest_app.properties Wed Nov 9 09:46:52 2005
@@ -1,2 +1,3 @@
usedefaults=true
+ij.database=wombat;create=true
noSecurityManager=true
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/build.xml
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/build.xml?rev=332090&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/build.xml (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/build.xml Wed Nov 9 09:46:52 2005
@@ -0,0 +1,87 @@
+<?xml version="1.0"?>
+
+<!-- ==================================================================== -->
+<!-- Derby build file -->
+<!-- ==================================================================== -->
+
+<project default="FTOtestsubdir" basedir="../../../../../../../../.." >
+
+<!-- ==================================================================== -->
+<!-- Set properties -->
+<!-- ==================================================================== -->
+
+ <!-- User settings -->
+ <property file="${user.home}/ant.properties"/>
+
+ <!-- Set property lib dir -->
+ <property name="properties.dir" value="tools/ant/properties" />
+
+ <!-- Significant dirs -->
+ <property file="${properties.dir}/dirs.properties"/>
+ <property file="${properties.dir}/derbytesting.properties"/>
+
+ <!-- Compiler settings -->
+ <property file="${properties.dir}/sane${sanity}.properties"/>
+ <property file="${properties.dir}/defaultcompiler.properties"/>
+ <property file="${properties.dir}/${build.compiler}.properties"/>
+
+ <!-- Parser properties -->
+ <!--property file="${properties.dir}/parser.properties"/-->
+
+ <!-- Compile-time classpath properties files -->
+ <property file="${properties.dir}/extrapath.properties"/>
+ <property file="${properties.dir}/compilepath.properties"/>
+
+ <!-- Release and Version info -->
+ <property file="${properties.dir}/release.properties"/>
+
+ <!-- derby testing specific properties files -->
+ <property file="${ant.home}/properties/derbytesting.properties"/>
+ <property file="${user.home}/properties/derbytesting.properties"/>
+ <property name="this.dir" value="${derby.testing.functest.dir}/tests/junitTests/derbynet"/>
+
+<!-- ============ Begin Targets ============== -->
+
+ <target name="FTOtestsubdir" depends="compilet1,copyfiles"/>
+
+ <!-- mkdir / init target may not be necessary, just here for reference... -->
+ <target name="init">
+ <mkdir dir="${out.dir}/${derby.testing.functest.dir}/tests/junitTests/derbynet"/>
+ </target>
+
+ <target name="compilet1">
+
+ <javac
+ bootclasspath="${empty}"
+ nowarn="on"
+ debug="${debug}"
+ depend="${depend}"
+ deprecation="${deprecation}"
+ optimize="${optimize}"
+ proceed="${proceed}"
+ verbose="${verbose}"
+ srcdir="${derby.testing.src.dir}"
+ destdir="${out.dir}">
+ <classpath>
+ <!--pathelement location="${oro}"/-->
+ <pathelement path="${compile.classpath}"/>
+ <pathelement path="${junit}"/>
+ </classpath>
+ <include name="${this.dir}/*.java"/>
+ </javac>
+ </target>
+
+ <target name="copyfiles">
+ <copy todir="${out.dir}/${derby.testing.functest.dir}/tests/junitTests/derbynet">
+ <fileset dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/tests/junitTests/derbynet"
+ includesfile="${derby.testing.src.dir}/${derby.testing.functest.dir}/tests/junitTests/derbynet/copyfiles.ant"/>
+ </copy>
+ </target>
+
+
+<!-- ============= End Targets ============== -->
+
+<!-- ============= End Project ============== -->
+
+</project>
+
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/build.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/copyfiles.ant
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/copyfiles.ant?rev=332090&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/copyfiles.ant (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/copyfiles.ant Wed Nov 9 09:46:52 2005
@@ -0,0 +1 @@
+CompatibilityTest_app.properties
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/copyfiles.ant
------------------------------------------------------------------------------
svn:eol-style = native
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/build.xml
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/build.xml?rev=332090&r1=332089&r2=332090&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/build.xml (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/build.xml Wed Nov 9 09:46:52 2005
@@ -84,6 +84,7 @@
destdir="${out.dir}">
<classpath>
<pathelement path="${java14compile.classpath}"/>
+ <pathelement path="${junit}"/>
</classpath>
<!--exclude name=""/-->
<!--include name=""/-->
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/DerbyJUnitTest.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/DerbyJUnitTest.java?rev=332090&r1=332089&r2=332090&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/DerbyJUnitTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/DerbyJUnitTest.java Wed Nov 9 09:46:52 2005
@@ -29,6 +29,9 @@
package org.apache.derbyTesting.functionTests.util;
+import java.io.*;
+import java.sql.*;
+
import junit.framework.*;
public class DerbyJUnitTest extends TestCase
@@ -39,12 +42,22 @@
//
/////////////////////////////////////////////////////////////
+ /** If you set this startup property to true, you will get chatty output. */
+ public static final String DEBUG_FLAG = "drb.tests.debug";
+
+ public static final int SUCCESS_EXIT = 0;
+ public static final int FAILURE_EXIT = 1;
+
/////////////////////////////////////////////////////////////
//
// STATE
//
/////////////////////////////////////////////////////////////
+ private static boolean _debug; // if true, we print chatty diagnostics
+
+ private static PrintStream _outputStream = System.out; // where to print debug output
+
/////////////////////////////////////////////////////////////
//
// CONSTRUCTOR
@@ -52,6 +65,66 @@
/////////////////////////////////////////////////////////////
public DerbyJUnitTest() {}
+
+ /////////////////////////////////////////////////////////////
+ //
+ // PUBLIC BEHAVIOR
+ //
+ /////////////////////////////////////////////////////////////
+
+ /**
+ * <p>
+ * Look for the system property which tells us whether to run
+ * chattily.
+ * </p>
+ */
+ public static boolean parseDebug()
+ {
+ _debug = Boolean.getBoolean( DEBUG_FLAG );
+
+ return true;
+ }
+
+ /**
+ * <p>
+ * Debug code to print chatty informational messages.
+ * </p>
+ */
+ public static void println( String text )
+ {
+ if ( _debug )
+ {
+ _outputStream.println( text );
+ _outputStream.flush();
+ }
+ }
+
+ /**
+ * <p>
+ * Print out a stack trace.
+ * </p>
+ */
+ public static void printStackTrace( Throwable t )
+ {
+ while ( t != null )
+ {
+ t.printStackTrace( _outputStream );
+
+ if ( t instanceof SQLException ) { t = ((SQLException) t).getNextException(); }
+ else { break; }
+ }
+ }
+
+ /**
+ * <p>
+ * Return a meaningful exit status so that calling scripts can take
+ * evasive action.
+ * </p>
+ */
+ public void exit( int exitStatus )
+ {
+ Runtime.getRuntime().exit( exitStatus );
+ }
/////////////////////////////////////////////////////////////
//