org.apache.derbyTesting.functionTests.tests.jdbcapi
Class DataSourceSerializationTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.apache.derbyTesting.junit.BaseTestCase
              extended by org.apache.derbyTesting.junit.BaseJDBCTestCase
                  extended by org.apache.derbyTesting.functionTests.tests.jdbcapi.DataSourceSerializationTest
All Implemented Interfaces:
junit.framework.Test

public class DataSourceSerializationTest
extends BaseJDBCTestCase

Makes sure that old serialized data sources can be de-serialized with the current version of the data souce.

Serialized data source from old versions are expected to be found in testData/serializedDataSources, with the following filename format CLASSNAME-VERSION.ser, where CLASSNAME is the unqualified name of the data source class, and VERSION is the Derby version. An example: ClientPooledConnectionDataSource-10_1.ser

A separation between JDBC 4.0 specific classes and the other classes is not made.

This test should detect the typical incompatible changes in the current data source implementations, for instance deleting a field or changing its type.


Field Summary
private static java.lang.String VERSION_10_0_2_1
          Constant for Derby version 10.0.2.1.
private static java.lang.String VERSION_10_1_3_1
          Constant for Derby version 10.1.3.1.
private static java.lang.String VERSION_10_2_2_0
          Constant for Derby version 10.2.2.0
private static java.lang.String VERSION_10_3_2_1
          Constant for Derby version 10.3.2.1.
 
Fields inherited from class org.apache.derbyTesting.junit.BaseTestCase
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
 
Constructor Summary
DataSourceSerializationTest(java.lang.String name)
           
 
Method Summary
private  void deSerializeDs(java.lang.String className, java.lang.String version)
          Attempts to de-serialize a data source object from a file.
 void serTestClientConnectionPoolDataSource()
          Tests the de-serialization of the client connection pool data source.
 void serTestClientDataSource()
          Tests the de-serialization of the basic client data source.
 void serTestClientXADataSource()
          Tests the de-serialization of the client XA data source.
 void serTestEmbeddedConnectionPoolDataSource()
          Tests the de-serialization of the embedded connection pool data source.
 void serTestEmbeddedDataSource()
          Tests the de-serialization of the basic embedded data source.
 void serTestEmbeddedXADataSource()
          Tests the de-serialization of the embedded XA data source.
static junit.framework.Test suite()
          Returns an appropariate suite of tests to run.
 
Methods inherited from class org.apache.derbyTesting.junit.BaseJDBCTestCase
assertCallError, assertCheckTable, assertCompileError, assertEquals, assertEquals, assertEquals, assertEquivalentDataType, assertGetIntError, assertNextError, assertPreparedStatementError, assertSQLExceptionEquals, assertSQLState, assertSQLState, assertStatementError, assertStatementError, assertStatementError, assertStatementError, assertTableRowCount, assertUpdateCount, assertUpdateCount, checkAllConsistency, checkEstimatedRowCount, commit, createStatement, createStatement, createStatement, dropTable, dropTable, getConnection, getDatabaseProperty, getLastSQLException, initializeConnection, openConnection, openDefaultConnection, openDefaultConnection, openUserConnection, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, rollback, runScript, runScript, runSQLCommands, setAutoCommit, tearDown, usingDB2Client, usingDerbyNetClient, usingEmbedded
 
Methods inherited from class org.apache.derbyTesting.junit.BaseTestCase
alarm, assertEquals, assertEquals, assertEquals, assertExecJavaCmdAsExpected, assertSecurityManager, assertThrowableEquals, execJavaCmd, fail, getFailureFolder, getJavaExecutableName, getSystemProperty, getTestConfiguration, getTestResource, openTestResource, println, printStackTrace, readProcessOutput, removeDirectory, removeDirectory, removeSystemProperty, runBare, setSystemProperty, traceit
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runTest, setName, setUp, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VERSION_10_0_2_1

private static final java.lang.String VERSION_10_0_2_1
Constant for Derby version 10.0.2.1.

See Also:
Constant Field Values

VERSION_10_1_3_1

private static final java.lang.String VERSION_10_1_3_1
Constant for Derby version 10.1.3.1.

See Also:
Constant Field Values

VERSION_10_2_2_0

private static final java.lang.String VERSION_10_2_2_0
Constant for Derby version 10.2.2.0

See Also:
Constant Field Values

VERSION_10_3_2_1

private static final java.lang.String VERSION_10_3_2_1
Constant for Derby version 10.3.2.1.

See Also:
Constant Field Values
Constructor Detail

DataSourceSerializationTest

public DataSourceSerializationTest(java.lang.String name)
Method Detail

serTestEmbeddedDataSource

public void serTestEmbeddedDataSource()
                               throws java.lang.Exception
Tests the de-serialization of the basic embedded data source.

Throws:
java.lang.Exception - for a number of error conditions

serTestEmbeddedConnectionPoolDataSource

public void serTestEmbeddedConnectionPoolDataSource()
                                             throws java.lang.Exception
Tests the de-serialization of the embedded connection pool data source.

Throws:
java.lang.Exception - for a number of error conditions

serTestEmbeddedXADataSource

public void serTestEmbeddedXADataSource()
                                 throws java.lang.Exception
Tests the de-serialization of the embedded XA data source.

Throws:
java.lang.Exception - for a number of error conditions

serTestClientDataSource

public void serTestClientDataSource()
                             throws java.lang.Exception
Tests the de-serialization of the basic client data source.

Throws:
java.lang.Exception - for a number of error conditions

serTestClientConnectionPoolDataSource

public void serTestClientConnectionPoolDataSource()
                                           throws java.lang.Exception
Tests the de-serialization of the client connection pool data source.

Throws:
java.lang.Exception - for a number of error conditions

serTestClientXADataSource

public void serTestClientXADataSource()
                               throws java.lang.Exception
Tests the de-serialization of the client XA data source.

Throws:
java.lang.Exception - for a number of error conditions

deSerializeDs

private void deSerializeDs(java.lang.String className,
                           java.lang.String version)
                    throws java.lang.Exception
Attempts to de-serialize a data source object from a file.

  1. Derby version string - UTF
  2. Derby build number - UTF
  3. Derby data source - object
  4. Derby data source reference - object

If the object is successfully instantiated and cast to DataSource

Parameters:
className - name of the class to de-serialize
version - Derby version
Throws:
java.lang.Exception - on a number of error conditions

suite

public static junit.framework.Test suite()
Returns an appropariate suite of tests to run.

Returns:
A test suite.

Built on Thu 2009-11-26 18:42:53-0800, from revision 884739

Apache Derby V10.6 Internals - Copyright © 2004,2008 The Apache Software Foundation. All Rights Reserved.