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

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.J2EEDataSourceTest
All Implemented Interfaces:
junit.framework.Test

public class J2EEDataSourceTest
extends BaseJDBCTestCase

Test the ConnectionPoolDataSource and XADataSource implementations of Derby. DataSource functionality common to DataSources including what is supported with JSR169 is tested in DataSourceTest. Performs SecurityCheck analysis on the JDBC objects returned. This is because this test returns to the client a number of different implementations of Connection, Statement etc.

See Also:
SecurityCheck

Field Summary
protected static java.util.Hashtable conns
          A hashtable of opened connections.
private static java.lang.String CONNSTRING_FORMAT
          The expected format of a connection string.
private static java.lang.String dbName
           
private  java.lang.Object nogc
          Hang onto the SecurityCheck class while running the tests so that it is not garbage collected during the test and lose the information it has collected, in case it should get printed out.
 
Fields inherited from class org.apache.derbyTesting.junit.BaseTestCase
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
 
Constructor Summary
J2EEDataSourceTest(java.lang.String name)
           
 
Method Summary
private  void assertConnectionOK(java.lang.Object[] expectedValues, java.lang.String dsName, java.sql.Connection conn)
           
private  void assertConnectionPreClose(java.lang.String dsName, java.sql.Connection conn)
           
private  void assertConnectionState(int expectedHoldability, int expectedIsolation, boolean expectedCommitSetting, boolean expectedReadOnly, java.sql.Connection conn)
           
private static void assertConnHoldability(java.sql.Connection conn, int expectedHoldability)
          Verify connection holdablity is expected holdability
private  void assertIsoLocks(java.sql.Connection conn, int expectedIsoLevel)
          Checks locks for designated isolation level on the connection.
private static void assertLocks(int[] expectedValues, java.sql.Connection conn)
           
private static void assertMessageText(java.sql.Connection conn, java.lang.String retrieveMessageTextValue)
           
private static void assertPooledConnAutoCommit(java.lang.String desc, javax.sql.PooledConnection pc1)
          Make sure autocommit gets reset on PooledConnection.getConnection()
private static void assertPooledConnHoldability(java.lang.String desc, javax.sql.PooledConnection pc1)
          Checks that Holdability gets reset on PooledConnection.getConnection()
private  void assertPooledConnIso(java.lang.String pooledConnType, javax.sql.PooledConnection pc)
          Test that isolation is reset on PooledConnection.getConnection()
private  void assertStatementOK(java.lang.String dsName, java.sql.Connection conn, java.sql.Statement s)
           
private  void assertStatementState(int[] parameterExpectedValues, int[] expectedValues, java.sql.Statement s)
           
private static void assertStringFormat(java.sql.Connection conn)
          Check the format of the connection string.
private static void assertStringFormat(javax.sql.PooledConnection pc)
          Check the format of a pooled connection
private static java.lang.String assertStringPrefix(java.lang.Object conn)
          Make sure the connection string starts with the right prefix, which is the classname@hashcode.
private  void assertTenConnectionsUnique()
          Get connections using getConnection() and make sure they're unique
private static void assertToString(java.sql.Connection conn)
          Make sure this connection's string is unique (DERBY-243)
private static void assertToString(javax.sql.ConnectionPoolDataSource pds)
          Check uniqueness of strings with a pooled data source.
private static void assertToString(javax.sql.DataSource ds)
          Check uniqueness of connection strings coming from a DataSouce
private static void assertToString(javax.sql.XADataSource xds)
          Check uniqueness of strings for an XA data source
private static void assertTraceFilesExist()
          Check that trace file exists in directory
protected  void assertXAException(java.lang.String tag, javax.transaction.xa.XAException xae)
           
private static junit.framework.Test baseSuite(java.lang.String postfix)
          Return a suite of tests that are run with both client and embedded
static void checkNesConn(java.lang.String dsName)
           
private static void clearConnections()
          Clear out and close connections in the connections hashtable.
private  java.sql.CallableStatement createFloatCallForStateChecking(int[] parameterExpectedValues, int[] CallableStatementExpectedValues, java.sql.Connection conn, java.lang.String sql)
           
private  java.sql.Statement createFloatStatementForStateChecking(int[] StatementExpectedValues, java.sql.Connection conn)
          Create a statement with modified State.
private  java.sql.PreparedStatement createFloatStatementForStateChecking(int[] parameterExpectedValues, int[] PreparedStatementExpectedValues, java.sql.Connection conn, java.lang.String sql)
           
private  void doTestSchemaIsReset(javax.sql.PooledConnection pc, java.lang.String userSchema)
          Executes a test sequence to make sure the schema is reset between logical connections.
private static void dsConnectionRequest(java.lang.String expectedValue, javax.sql.ConnectionPoolDataSource ds, java.lang.String user, java.lang.String ConnAttr)
           
private static void dsConnectionRequest(java.lang.String expectedValue, javax.sql.DataSource ds, java.lang.String user, java.lang.String ConnAttr)
           
private static void dsConnectionRequest(java.lang.String expectedValue, javax.sql.XADataSource ds, java.lang.String user, java.lang.String ConnAttr)
           
private static void dsConnectionRequests(java.lang.String[] expectedValues, javax.sql.ConnectionPoolDataSource ds)
           
private static void dsConnectionRequests(java.lang.String[] expectedValues, javax.sql.DataSource ds)
           
private static void dsConnectionRequests(java.lang.String[] expectedValues, javax.sql.XADataSource ds)
           
private static junit.framework.Test getClientSuite()
          Return a suite of tests that are run with client only
private static junit.framework.Test getEmbeddedSuite(java.lang.String postfix)
          Return a suite of tests that are run with embedded only
private static java.lang.String getNestedMethodName()
          Return the Java class and method for the procedure for the nested connection test.
private static junit.framework.Test getTimeoutSuite(java.lang.String postfix)
          Return a suite of tests that are run with a lower lock timeout.
private  java.sql.CallableStatement internalCreateFloatCallForStateChecking(java.sql.Connection conn, java.lang.String sql)
           
private  java.sql.Statement internalCreateFloatStatementForStateChecking(java.sql.Connection conn)
           
private  java.sql.PreparedStatement internalCreateFloatStatementForStateChecking(java.sql.Connection conn, java.lang.String sql)
           
private static void PoolReset(java.lang.String type, javax.sql.PooledConnection pc)
          When a connection is being pooled, the underlying JDBC embedded connection object is re-used.
private static void PoolResetWork(java.lang.String expectedID, java.lang.String tableAction, java.sql.Connection conn)
           
private static void queryOnStatement(java.lang.String expectedCursorName, int[] expectedValues, java.sql.Connection conn, java.sql.Statement s)
           
private static void resultSetQuery(java.lang.String expectedCursorName, int[] expectedValues, java.sql.ResultSet rs)
           
private  boolean selectTimesoutDuringUpdate(java.sql.Connection conn)
          Determine if a select on this connection during update will timeout.
private static void setDatabaseProperty(java.lang.String property, java.lang.String value)
           
private  void setHoldability(java.sql.Connection conn, boolean hold)
           
private static void setupDerby1144Table(java.sql.Connection conn)
          insert two rows into the simple table for DERBY-1144 tests
private  void subtestCloseEventWithNullListener(javax.sql.PooledConnection pc)
          Test that notification of a close event doesn't fail when the listener is null.
private  void subTestDataSourceDescription(javax.sql.DataSource ds)
          Utility method for testing setting and fetching the description property on a data source.
private  void subtestErrorEventWithNullListener(javax.sql.PooledConnection pc)
          Test that notification of an error event doesn't fail when the listener is null.
private  void subtestPooledAddListenerOnClose(javax.sql.PooledConnection pc)
          Tests that a listener of a pooled connection can successfully add another listener when processing a close event.
private  void subtestPooledCloseOnClose(javax.sql.PooledConnection pc)
          Tests that a pooled connection can successfully be closed during the processing of its close event by its listener.
private  void subtestPooledRemoveListenerOnClose(javax.sql.PooledConnection pc)
          Tests that a listener of a pooled connection can successfully remove itself during the processing of its close event by its listener.
private  void subtestPooledReuseOnClose(javax.sql.PooledConnection pc)
          Tests that a pooled connection can successfully be reused (a new connection obtained from it) during the processing of its close event by its listener.
static junit.framework.Test suite()
           
 void tearDown()
          Tear down this fixture, sub-classes should call super.tearDown().
 void testAllDataSources()
           
 void testAutoCommitOnXAResourceStart()
           
 void testBadConnectionAttributeSyntax()
           
 void testClientDSConnectionAttributes()
          Check that database name set using setConnectionAttributes is not used by ClientDataSource.
 void testClientMessageTextConnectionAttribute()
          Check that messageText connection attribute functions correctly.
 void testClientTraceFileDSConnectionAttribute()
          Check that traceFile connection attribute functions correctly.
 void testCloseActiveConnection_CP()
          Test that connections retrieved from ConnectionPoolDataSource behave as expected when close() is called and the transaction is active.
 void testCloseActiveConnection_DS()
          Test that connections retrieved from DataSource behave as expected when close() is called and the transaction is active.
 void testCloseActiveConnection_XA_global()
          Test that connections retrieved from XADataSource that are part of a global XA transaction, behave as expected when close() is called and the transaction is active.
 void testCloseActiveConnection_XA_local()
          Test that connections retrieved from XADataSource that are not part of a global XA transaction, behave as expected when close() is called and the transaction is active.
private  void testCloseActiveConnection(java.sql.Connection c, boolean autoCommit, boolean global)
          Test that Connection.close() behaves as expected when the transaction is active (DERBY-3319).
 void testClosedCPDSConnection()
           
 void testClosedXADSConnection()
           
 void testConnectionErrorEvent()
          Test case for DERBY-3172 When the Derby engine is shutdown or Network Server is brought down, any api on JDBC Connection object should generate a Connection error event.
 void testConnectionEventListenerIsNull()
          Test that event notification doesn't fail when a null listener has been registered (DERBY-3307).
 void testConnectionLeakInDatabaseMetaData()
          Tests that DatabaseMetaData.getConnection does not leak references to physical connections or other logical connections.
 void testDerby3799()
          Regression test for a NullPointerException when trying to use the LOB stored procedures after closing and then getting a new logical connection.
 void testDescriptionProperty()
          Check that messageText connection attribute functions correctly.
 void testDSRequestAuthentication()
           
 void testGlobalLocalInterleaf()
           
 void testJira95pds()
           
 void testJira95xads()
           
 void testPooledReuseOnClose()
          Test that a PooledConnection can be reused and closed (separately) during the close event raised by the closing of its logical connection.
 void testReadOnlyToWritableTran()
           
 void testReuseAcrossGlobalLocal()
           
 void testSchemaIsReset()
          Verifies that the schema is reset when creating a new logical connection.
 void testSchemaIsResetWhenDeleted()
          Tests that deleting the current / default schema doesn't cause the next logical connection to fail.
 void testSetIsolationWithStatement()
           
 void testSetSchemaInXAConnection()
           
 void testXAHoldability()
           
 void timeoutTestDerby1144PooledDS()
          Tests for DERBY-1144 This test tests that holdability, autocomit, and transactionIsolation are reset on getConnection for PooledConnections obtaind from connectionPoolDataSources DERBY-1134 has been filed for more comprehensive testing of client connection state.
 void timeoutTestDerby1144XADS()
           
 
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, 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

dbName

private static final java.lang.String dbName

conns

protected static java.util.Hashtable conns
A hashtable of opened connections. This is used when checking to make sure connection strings are unique; we need to make sure all the connections are closed when we are done, so they are stored in this hashtable


CONNSTRING_FORMAT

private static final java.lang.String CONNSTRING_FORMAT
The expected format of a connection string. In English: "@ (XID=), (SESSION = ), (DATABASE=), (DRDAID = )"

See Also:
Constant Field Values

nogc

private final java.lang.Object nogc
Hang onto the SecurityCheck class while running the tests so that it is not garbage collected during the test and lose the information it has collected, in case it should get printed out.

Constructor Detail

J2EEDataSourceTest

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

getTimeoutSuite

private static junit.framework.Test getTimeoutSuite(java.lang.String postfix)
Return a suite of tests that are run with a lower lock timeout.

Parameters:
postfix - suite name postfix
Returns:
A suite of tests being run with a lower lock timeout.

baseSuite

private static junit.framework.Test baseSuite(java.lang.String postfix)
Return a suite of tests that are run with both client and embedded

Parameters:
postfix - suite name postfix
Returns:
A suite of tests to be run with client and/or embedded

getClientSuite

private static junit.framework.Test getClientSuite()
Return a suite of tests that are run with client only

Returns:
A suite of tests being run with client only

getEmbeddedSuite

private static junit.framework.Test getEmbeddedSuite(java.lang.String postfix)
Return a suite of tests that are run with embedded only

Parameters:
postfix - suite name postfix
Returns:
A suite of tests being run with embedded only

suite

public static junit.framework.Test suite()

tearDown

public void tearDown()
              throws java.lang.Exception
Description copied from class: BaseJDBCTestCase
Tear down this fixture, sub-classes should call super.tearDown(). This cleanups & closes the connection if it is open and any statement objects returned through the utility methods.

Overrides:
tearDown in class BaseJDBCTestCase
Throws:
java.lang.Exception

testConnectionErrorEvent

public void testConnectionErrorEvent()
                              throws java.sql.SQLException,
                                     java.lang.Exception
Test case for DERBY-3172 When the Derby engine is shutdown or Network Server is brought down, any api on JDBC Connection object should generate a Connection error event.

Throws:
java.sql.SQLException
java.lang.Exception

testConnectionEventListenerIsNull

public void testConnectionEventListenerIsNull()
                                       throws java.sql.SQLException
Test that event notification doesn't fail when a null listener has been registered (DERBY-3307).

Throws:
java.sql.SQLException

subtestCloseEventWithNullListener

private void subtestCloseEventWithNullListener(javax.sql.PooledConnection pc)
                                        throws java.sql.SQLException
Test that notification of a close event doesn't fail when the listener is null.

Throws:
java.sql.SQLException

subtestErrorEventWithNullListener

private void subtestErrorEventWithNullListener(javax.sql.PooledConnection pc)
                                        throws java.sql.SQLException
Test that notification of an error event doesn't fail when the listener is null.

Throws:
java.sql.SQLException

testCloseActiveConnection

private void testCloseActiveConnection(java.sql.Connection c,
                                       boolean autoCommit,
                                       boolean global)
                                throws java.sql.SQLException
Test that Connection.close() behaves as expected when the transaction is active (DERBY-3319).

Parameters:
c - the connection to test
autoCommit - the expected auto-commit value. When auto-commit is on, close() shouldn't fail when the transaction is active.
global - tells whether the connection is part of a global XA transaction. If it is, close() shouldn't fail, since the transaction can be finished later without using the connection.
Throws:
java.sql.SQLException

testCloseActiveConnection_DS

public void testCloseActiveConnection_DS()
                                  throws java.sql.SQLException
Test that connections retrieved from DataSource behave as expected when close() is called and the transaction is active.

Throws:
java.sql.SQLException

testCloseActiveConnection_CP

public void testCloseActiveConnection_CP()
                                  throws java.sql.SQLException
Test that connections retrieved from ConnectionPoolDataSource behave as expected when close() is called and the transaction is active.

Throws:
java.sql.SQLException

testCloseActiveConnection_XA_local

public void testCloseActiveConnection_XA_local()
                                        throws java.sql.SQLException
Test that connections retrieved from XADataSource that are not part of a global XA transaction, behave as expected when close() is called and the transaction is active.

Throws:
java.sql.SQLException

testCloseActiveConnection_XA_global

public void testCloseActiveConnection_XA_global()
                                         throws java.sql.SQLException,
                                                javax.transaction.xa.XAException
Test that connections retrieved from XADataSource that are part of a global XA transaction, behave as expected when close() is called and the transaction is active.

Throws:
java.sql.SQLException
javax.transaction.xa.XAException

testPooledReuseOnClose

public void testPooledReuseOnClose()
                            throws java.sql.SQLException
Test that a PooledConnection can be reused and closed (separately) during the close event raised by the closing of its logical connection. DERBY-2142.

Throws:
java.sql.SQLException

subtestPooledReuseOnClose

private void subtestPooledReuseOnClose(javax.sql.PooledConnection pc)
                                throws java.sql.SQLException
Tests that a pooled connection can successfully be reused (a new connection obtained from it) during the processing of its close event by its listener. Sections 11.2 & 12.5 of JDBC 4 specification indicate that the connection can be returned to the pool when the ConnectionEventListener.connectionClosed() is called.

Throws:
java.sql.SQLException

subtestPooledCloseOnClose

private void subtestPooledCloseOnClose(javax.sql.PooledConnection pc)
                                throws java.sql.SQLException
Tests that a pooled connection can successfully be closed during the processing of its close event by its listener.

Throws:
java.sql.SQLException

subtestPooledRemoveListenerOnClose

private void subtestPooledRemoveListenerOnClose(javax.sql.PooledConnection pc)
                                         throws java.sql.SQLException
Tests that a listener of a pooled connection can successfully remove itself during the processing of its close event by its listener. Failed before DERBY-3401 was fixed.

Throws:
java.sql.SQLException

subtestPooledAddListenerOnClose

private void subtestPooledAddListenerOnClose(javax.sql.PooledConnection pc)
                                      throws java.sql.SQLException
Tests that a listener of a pooled connection can successfully add another listener when processing a close event. Failed before DERBY-3401 was fixed.

Throws:
java.sql.SQLException

testAllDataSources

public void testAllDataSources()
                        throws java.sql.SQLException,
                               java.lang.Exception
Throws:
java.sql.SQLException
java.lang.Exception

testClosedCPDSConnection

public void testClosedCPDSConnection()
                              throws java.sql.SQLException,
                                     java.lang.Exception
Throws:
java.sql.SQLException
java.lang.Exception

testClosedXADSConnection

public void testClosedXADSConnection()
                              throws java.sql.SQLException,
                                     java.lang.Exception
Throws:
java.sql.SQLException
java.lang.Exception

testGlobalLocalInterleaf

public void testGlobalLocalInterleaf()
                              throws java.sql.SQLException,
                                     javax.transaction.xa.XAException
Throws:
java.sql.SQLException
javax.transaction.xa.XAException

testSetIsolationWithStatement

public void testSetIsolationWithStatement()
                                   throws java.sql.SQLException,
                                          javax.transaction.xa.XAException
Throws:
java.sql.SQLException
javax.transaction.xa.XAException

testReuseAcrossGlobalLocal

public void testReuseAcrossGlobalLocal()
                                throws java.sql.SQLException,
                                       javax.transaction.xa.XAException
Throws:
java.sql.SQLException
javax.transaction.xa.XAException

testSetSchemaInXAConnection

public void testSetSchemaInXAConnection()
                                 throws java.sql.SQLException
Throws:
java.sql.SQLException

testSchemaIsReset

public void testSchemaIsReset()
                       throws java.sql.SQLException
Verifies that the schema is reset when creating a new logical connection.

The test is run in a non-statement pooling configuration first, and then with statement pooling enabled if the environment supports it.

Relevant Jira issue: DERBY-3690.

The current role also needs to be reset, but can't be tested here since we need to run with SQL authorization.

Throws:
java.sql.SQLException - if something goes wrong
See Also:
RolesTest.testCurrentRoleIsReset()

doTestSchemaIsReset

private void doTestSchemaIsReset(javax.sql.PooledConnection pc,
                                 java.lang.String userSchema)
                          throws java.sql.SQLException
Executes a test sequence to make sure the schema is reset between logical connections.

Parameters:
pc - pooled connection to get logical connections from
userSchema - name of the default schema for the connection (user)
Throws:
java.sql.SQLException - if something goes wrong...

testSchemaIsResetWhenDeleted

public void testSchemaIsResetWhenDeleted()
                                  throws java.sql.SQLException
Tests that deleting the current / default schema doesn't cause the next logical connection to fail.

Relevant Jira issue: DERBY-3690.

Throws:
java.sql.SQLException - if something goes wrong

testAutoCommitOnXAResourceStart

public void testAutoCommitOnXAResourceStart()
                                     throws java.sql.SQLException,
                                            javax.transaction.xa.XAException
Throws:
java.sql.SQLException
javax.transaction.xa.XAException

testReadOnlyToWritableTran

public void testReadOnlyToWritableTran()
                                throws java.sql.SQLException,
                                       java.lang.Exception
Throws:
java.sql.SQLException
java.lang.Exception

testJira95pds

public void testJira95pds()
                   throws java.lang.Exception
Throws:
java.lang.Exception

testJira95xads

public void testJira95xads()
                    throws java.sql.SQLException
Throws:
java.sql.SQLException

testBadConnectionAttributeSyntax

public void testBadConnectionAttributeSyntax()
                                      throws java.sql.SQLException
Throws:
java.sql.SQLException

testClientDSConnectionAttributes

public void testClientDSConnectionAttributes()
                                      throws java.sql.SQLException
Check that database name set using setConnectionAttributes is not used by ClientDataSource. This method tests DERBY-1130.

Throws:
java.sql.SQLException

testDSRequestAuthentication

public void testDSRequestAuthentication()
                                 throws java.lang.Exception
Throws:
java.lang.Exception

testClientTraceFileDSConnectionAttribute

public void testClientTraceFileDSConnectionAttribute()
                                              throws java.sql.SQLException
Check that traceFile connection attribute functions correctly. tracefile was tested in checkDriver, but not for DataSources. tracefile= was used in datasourcepermissions_net, but that's incorrect syntax. Note that we're not checking the contents of the tracefile. Note also that this test cannot run against a remote server.

Throws:
java.sql.SQLException

assertTraceFilesExist

private static void assertTraceFilesExist()
Check that trace file exists in directory


testClientMessageTextConnectionAttribute

public void testClientMessageTextConnectionAttribute()
                                              throws java.sql.SQLException
Check that messageText connection attribute functions correctly. retrievemessagetext was tested in checkdriver, and derbynet/testij, but not tested for datasources, and in datasourcepermissions_net, but as it has nothing to do with permissions/authentication, this test seems a better place for it. There is a corresponding fixture for clientDataSource in DataSourceTest

Throws:
java.sql.SQLException

assertMessageText

private static void assertMessageText(java.sql.Connection conn,
                                      java.lang.String retrieveMessageTextValue)
                               throws java.sql.SQLException
Throws:
java.sql.SQLException

testDescriptionProperty

public void testDescriptionProperty()
                             throws java.sql.SQLException,
                                    java.lang.Exception
Check that messageText connection attribute functions correctly. retrievemessagetext was tested in checkdriver, and derbynet/testij (but not tested for datasources), and in datasourcepermissions_net, but as it has nothing to do with permissions/authentication, this test seems a better place for it. there is a corresponding method call for datasources in DataSourceTest

Throws:
java.sql.SQLException
java.lang.Exception

subTestDataSourceDescription

private void subTestDataSourceDescription(javax.sql.DataSource ds)
                                   throws java.lang.Exception
Utility method for testing setting and fetching the description property on a data source.

Throws:
java.lang.Exception

testXAHoldability

public void testXAHoldability()
                       throws java.sql.SQLException,
                              javax.transaction.xa.XAException
Throws:
java.sql.SQLException
javax.transaction.xa.XAException

testConnectionLeakInDatabaseMetaData

public void testConnectionLeakInDatabaseMetaData()
                                          throws java.sql.SQLException
Tests that DatabaseMetaData.getConnection does not leak references to physical connections or other logical connections.

Throws:
java.sql.SQLException - if something goes wrong

testDerby3799

public void testDerby3799()
                   throws java.sql.SQLException
Regression test for a NullPointerException when trying to use the LOB stored procedures after closing and then getting a new logical connection. The problem was that the LOB stored procedure objects on the server side were closed and not reprepared. See Jira issue DERBY-3799.

Throws:
java.sql.SQLException

timeoutTestDerby1144PooledDS

public void timeoutTestDerby1144PooledDS()
                                  throws java.sql.SQLException
Tests for DERBY-1144 This test tests that holdability, autocomit, and transactionIsolation are reset on getConnection for PooledConnections obtaind from connectionPoolDataSources DERBY-1134 has been filed for more comprehensive testing of client connection state.

Throws:
java.sql.SQLException

timeoutTestDerby1144XADS

public void timeoutTestDerby1144XADS()
                              throws java.sql.SQLException
Throws:
java.sql.SQLException

assertPooledConnAutoCommit

private static void assertPooledConnAutoCommit(java.lang.String desc,
                                               javax.sql.PooledConnection pc1)
                                        throws java.sql.SQLException
Make sure autocommit gets reset on PooledConnection.getConnection()

Parameters:
desc - description of connection
pc1 - pooled connection to test
Throws:
java.sql.SQLException

assertPooledConnHoldability

private static void assertPooledConnHoldability(java.lang.String desc,
                                                javax.sql.PooledConnection pc1)
                                         throws java.sql.SQLException
Checks that Holdability gets reset on PooledConnection.getConnection()

Parameters:
desc -
pc1 -
Throws:
java.sql.SQLException

assertConnHoldability

private static void assertConnHoldability(java.sql.Connection conn,
                                          int expectedHoldability)
                                   throws java.sql.SQLException
Verify connection holdablity is expected holdability

Parameters:
conn -
expectedHoldability - * @throws SQLException
Throws:
java.sql.SQLException

assertPooledConnIso

private void assertPooledConnIso(java.lang.String pooledConnType,
                                 javax.sql.PooledConnection pc)
                          throws java.sql.SQLException
Test that isolation is reset on PooledConnection.getConnection()

Parameters:
pooledConnType - Descripiton of the type of pooled connection
pc - PooledConnection or XAConnection
Throws:
java.sql.SQLException

setupDerby1144Table

private static void setupDerby1144Table(java.sql.Connection conn)
                                 throws java.sql.SQLException
insert two rows into the simple table for DERBY-1144 tests

Parameters:
conn -
Throws:
java.sql.SQLException

assertIsoLocks

private void assertIsoLocks(java.sql.Connection conn,
                            int expectedIsoLevel)
                     throws java.sql.SQLException
Checks locks for designated isolation level on the connection. Currently only supports TRANSACTION_READ_COMMITTED and TRANSACTION_READ_UNCOMMITTED

Parameters:
conn - Connection to test
expectedIsoLevel - expected isolation level
Throws:
java.sql.SQLException

selectTimesoutDuringUpdate

private boolean selectTimesoutDuringUpdate(java.sql.Connection conn)
                                    throws java.sql.SQLException
Determine if a select on this connection during update will timeout. Used to establish isolation level. If the connection isolation level is Connection.TRANSACTION_READ_UNCOMMITTED it will not timeout. Otherwise it should.

Parameters:
conn - Connection to test.
Returns:
true if the select got a lock timeout, false otherwise.
Throws:
java.sql.SQLException

assertConnectionState

private void assertConnectionState(int expectedHoldability,
                                   int expectedIsolation,
                                   boolean expectedCommitSetting,
                                   boolean expectedReadOnly,
                                   java.sql.Connection conn)
                            throws java.sql.SQLException
Throws:
java.sql.SQLException

setDatabaseProperty

private static void setDatabaseProperty(java.lang.String property,
                                        java.lang.String value)
                                 throws java.sql.SQLException
Throws:
java.sql.SQLException

setHoldability

private void setHoldability(java.sql.Connection conn,
                            boolean hold)
                     throws java.sql.SQLException
Throws:
java.sql.SQLException

dsConnectionRequests

private static void dsConnectionRequests(java.lang.String[] expectedValues,
                                         javax.sql.DataSource ds)

dsConnectionRequest

private static void dsConnectionRequest(java.lang.String expectedValue,
                                        javax.sql.DataSource ds,
                                        java.lang.String user,
                                        java.lang.String ConnAttr)

dsConnectionRequests

private static void dsConnectionRequests(java.lang.String[] expectedValues,
                                         javax.sql.ConnectionPoolDataSource ds)

dsConnectionRequest

private static void dsConnectionRequest(java.lang.String expectedValue,
                                        javax.sql.ConnectionPoolDataSource ds,
                                        java.lang.String user,
                                        java.lang.String ConnAttr)

dsConnectionRequests

private static void dsConnectionRequests(java.lang.String[] expectedValues,
                                         javax.sql.XADataSource ds)

dsConnectionRequest

private static void dsConnectionRequest(java.lang.String expectedValue,
                                        javax.sql.XADataSource ds,
                                        java.lang.String user,
                                        java.lang.String ConnAttr)

assertXAException

protected void assertXAException(java.lang.String tag,
                                 javax.transaction.xa.XAException xae)

queryOnStatement

private static void queryOnStatement(java.lang.String expectedCursorName,
                                     int[] expectedValues,
                                     java.sql.Connection conn,
                                     java.sql.Statement s)
                              throws java.sql.SQLException
Throws:
java.sql.SQLException

resultSetQuery

private static void resultSetQuery(java.lang.String expectedCursorName,
                                   int[] expectedValues,
                                   java.sql.ResultSet rs)
                            throws java.sql.SQLException
Throws:
java.sql.SQLException

assertLocks

private static void assertLocks(int[] expectedValues,
                                java.sql.Connection conn)
                         throws java.sql.SQLException
Throws:
java.sql.SQLException

assertStatementState

private void assertStatementState(int[] parameterExpectedValues,
                                  int[] expectedValues,
                                  java.sql.Statement s)
                           throws java.sql.SQLException
Throws:
java.sql.SQLException

createFloatStatementForStateChecking

private java.sql.Statement createFloatStatementForStateChecking(int[] StatementExpectedValues,
                                                                java.sql.Connection conn)
                                                         throws java.sql.SQLException
Create a statement with modified State.

Throws:
java.sql.SQLException

internalCreateFloatStatementForStateChecking

private java.sql.Statement internalCreateFloatStatementForStateChecking(java.sql.Connection conn)
                                                                 throws java.sql.SQLException
Throws:
java.sql.SQLException

createFloatStatementForStateChecking

private java.sql.PreparedStatement createFloatStatementForStateChecking(int[] parameterExpectedValues,
                                                                        int[] PreparedStatementExpectedValues,
                                                                        java.sql.Connection conn,
                                                                        java.lang.String sql)
                                                                 throws java.sql.SQLException
Throws:
java.sql.SQLException

internalCreateFloatStatementForStateChecking

private java.sql.PreparedStatement internalCreateFloatStatementForStateChecking(java.sql.Connection conn,
                                                                                java.lang.String sql)
                                                                         throws java.sql.SQLException
Throws:
java.sql.SQLException

createFloatCallForStateChecking

private java.sql.CallableStatement createFloatCallForStateChecking(int[] parameterExpectedValues,
                                                                   int[] CallableStatementExpectedValues,
                                                                   java.sql.Connection conn,
                                                                   java.lang.String sql)
                                                            throws java.sql.SQLException
Throws:
java.sql.SQLException

internalCreateFloatCallForStateChecking

private java.sql.CallableStatement internalCreateFloatCallForStateChecking(java.sql.Connection conn,
                                                                           java.lang.String sql)
                                                                    throws java.sql.SQLException
Throws:
java.sql.SQLException

assertConnectionOK

private void assertConnectionOK(java.lang.Object[] expectedValues,
                                java.lang.String dsName,
                                java.sql.Connection conn)
                         throws java.sql.SQLException
Throws:
java.sql.SQLException

assertConnectionPreClose

private void assertConnectionPreClose(java.lang.String dsName,
                                      java.sql.Connection conn)
                               throws java.sql.SQLException
Throws:
java.sql.SQLException

assertStatementOK

private void assertStatementOK(java.lang.String dsName,
                               java.sql.Connection conn,
                               java.sql.Statement s)
                        throws java.sql.SQLException
Throws:
java.sql.SQLException

PoolReset

private static void PoolReset(java.lang.String type,
                              javax.sql.PooledConnection pc)
                       throws java.sql.SQLException
When a connection is being pooled, the underlying JDBC embedded connection object is re-used. As each application gets a new Connection object, that is really a wrapper around the old connection it should reset any connection spoecific state on the embedded connection object.

Throws:
java.sql.SQLException

PoolResetWork

private static void PoolResetWork(java.lang.String expectedID,
                                  java.lang.String tableAction,
                                  java.sql.Connection conn)
                           throws java.sql.SQLException
Throws:
java.sql.SQLException

assertToString

private static void assertToString(java.sql.Connection conn)
                            throws java.lang.Exception
Make sure this connection's string is unique (DERBY-243)

Throws:
java.lang.Exception

assertStringFormat

private static void assertStringFormat(javax.sql.PooledConnection pc)
                                throws java.lang.Exception
Check the format of a pooled connection

Throws:
java.lang.Exception

assertStringFormat

private static void assertStringFormat(java.sql.Connection conn)
Check the format of the connection string. This is the default test to run if this is not a BrokeredConnection class


assertStringPrefix

private static java.lang.String assertStringPrefix(java.lang.Object conn)
Make sure the connection string starts with the right prefix, which is the classname@hashcode.

Returns:
the expected prefix string, this is used in further string format checking

assertToString

private static void assertToString(javax.sql.DataSource ds)
                            throws java.lang.Exception
Check uniqueness of connection strings coming from a DataSouce

Throws:
java.lang.Exception

clearConnections

private static void clearConnections()
                              throws java.sql.SQLException
Clear out and close connections in the connections hashtable.

Throws:
java.sql.SQLException

assertTenConnectionsUnique

private void assertTenConnectionsUnique()
                                 throws java.lang.Exception
Get connections using getConnection() and make sure they're unique

Throws:
java.lang.Exception

assertToString

private static void assertToString(javax.sql.XADataSource xds)
                            throws java.lang.Exception
Check uniqueness of strings for an XA data source

Throws:
java.lang.Exception

assertToString

private static void assertToString(javax.sql.ConnectionPoolDataSource pds)
                            throws java.lang.Exception
Check uniqueness of strings with a pooled data source. We want to check the PooledConnection as well as the underlying physical connection.

Throws:
java.lang.Exception

getNestedMethodName

private static java.lang.String getNestedMethodName()
Return the Java class and method for the procedure for the nested connection test.


checkNesConn

public static void checkNesConn(java.lang.String dsName)
                         throws java.sql.SQLException
Throws:
java.sql.SQLException

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.