public class StatementPoolingTest extends BaseJDBCTestCase
Modifier and Type | Class and Description |
---|---|
private static class |
StatementPoolingTest.LogicalPooledConnectionFactory
A simple factory for obtaining logical connections from a pooled
connection created from a data source configured with statement caching.
|
Modifier and Type | Field and Description |
---|---|
private StatementPoolingTest.LogicalPooledConnectionFactory |
lpcf |
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
Constructor and Description |
---|
StatementPoolingTest(java.lang.String name) |
Modifier and Type | Method and Description |
---|---|
private static void |
assertClassName(java.lang.Object obj,
java.lang.String expectedName)
Assert that the name of the class of the object is what is expected.
|
private void |
cleanTableExceptedToBeEmpty()
Deletes row from a test table that is expected to be empty.
|
private void |
closePooledConnectionFactory()
Closes the connection factory associated with this test.
|
private void |
doTestGetStatement(java.sql.PreparedStatement ps)
Make sure
ResultSet.getStatement() returns the same object as the
one that created the result set. |
private void |
doTestHoldabilityIsReset(boolean closeConnection)
Test sequence for testing if the connection holdability is reset.
|
private void |
doTestIsolationLevelIsReset(boolean closeConnection,
boolean executeQuery)
Tests if the connection isolation level is reset when a new connection
is obtained.
|
private void |
doTestResultSetCloseForHoldability(int holdability)
Tests if the holdability settings is taking effect, and also that the
result set is closed when the connection is closed.
|
private java.sql.Connection |
getCachingConnection()
Returns a logical connection from a pooled connection obtained from a
data source configured with a default statement cache size.
|
private java.sql.Connection |
getCachingConnection(int cacheSize)
Returns a logical connection from a pooled connection obtained from a
data source configured to have the specified statement cache size.
|
void |
resTestCloseCursorsAtCommit() |
void |
resTestCloseDoesNotAffectOtherStatement()
Checks if a reset of one statement affects other open statement on the
connection.
|
void |
resTestCommitOnReuse()
Tests that autocommit is working.
|
void |
resTestHoldCursorsOverCommit() |
void |
resTestLogicalConnectionCloseInvalidatesLogicalStatement()
Checks if closing the logical connection closes the logical statement.
|
void |
resTestNoCommitOnReuse()
Tests that nothing is committed on the connection when autocommit is
disabled.
|
void |
resTestNoDataCommittedOnInvalidTransactionState()
Tests that nothing is committed on the connection when autocommit is
disabled.
|
static junit.framework.Test |
suite() |
void |
tearDown()
Tear down this fixture, sub-classes should call
super.tearDown().
|
void |
testCacheOverflow()
Tests that the statement cache is able to throw out prepared statements
when it reaches maximum capacity.
|
void |
testCachingLogicalConnectionCloseLeavesPhysicalStatementsOpen()
Tests that closing the caching logical connection closes the logical
prepared statement, but not the physical prepared statement.
|
void |
testClosingPSClosesRS()
Tests that closing the prepared statement also closes the result set.
|
void |
testDeleteReferringTableWhenInCache()
Tests that closing a logical prepared statement referring a non-existing
table works.
|
void |
testDeleteReferringTableWhenOpen()
Tests that closing a logical prepared statement referring a non-existing
table works.
|
void |
testGetStatementCallable()
Make sure
ResultSet.getStatement() returns the same object as the
one that created the result set. |
void |
testGetStatementPrepared()
Make sure
ResultSet.getStatement() returns the same object as the
one that created the result set. |
void |
testHoldabilityIsResetExplicitClose()
Tests that the connection holdability is reset, when it is first
modified, the connection closed and a new logical connection obtained.
|
void |
testHoldabilityIsResetNoExplicitClose()
Tests that the connection holdability is reset, when it is first
modified, and a new logical connection obtained without first explicitly
closing the previous one.
|
void |
testIsolationLevelIsResetExplicitCloseNoQuery() |
void |
testIsolationLevelIsResetExplicitCloseQuery() |
void |
testIsolationLevelIsResetNoExplicitCloseNoQuery() |
void |
testIsolationLevelIsResetNoExplicitCloseQuery() |
void |
testPoolingEnabledByCheckingImplementationDetails()
Verifies that statement pooling is enabled by checking the names of the
implementation classes in Derby.
|
void |
testPrepareCallPath()
This test merely checks that creating a logical callable statement does
not fail.
|
void |
testPrepareCallWithNoCallPath()
This test merely checks that creating a logical callable statement, which
is not really a call, does not fail.
|
void |
testPrepareStatementPath()
This test merely checks that creating a logical prepared statement does
not fail.
|
void |
testTemporaryTablesAreDeletedInNewLogicalConnection()
Tests that a temporary table created in one logical connection is gone
in the next logical connection.
|
assertCallError, assertCheckTable, assertCommitError, assertCompileError, assertEquals, assertEquals, assertEquals, assertEquivalentDataType, assertErrorCode, assertGetIntError, assertNextError, assertPreparedStatementError, assertResults, assertResults, assertSQLExceptionEquals, assertSQLState, assertSQLState, assertStatementError, assertStatementError, assertStatementError, assertStatementError, assertStatementErrorUnordered, assertTableRowCount, assertUpdateCount, assertUpdateCount, assertWarning, chattyPrepare, chattyPrepareCall, checkAllConsistency, checkEstimatedRowCount, closeStatement, commit, createStatement, createStatement, createStatement, dropTable, dropTable, dropView, dropView, dumpRs, dumpRs, emptyStatementCache, executeQuery, expectCompilationError, expectCompilationError, expectExecutionError, getClientTransactionID, getConnection, getDatabaseProperty, getLastSQLException, goodStatement, goodUpdate, initializeConnection, openConnection, openDefaultConnection, openDefaultConnection, openDefaultConnection, openUserConnection, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, rollback, runBare, runBareOverridable, runScript, runScript, runSQLCommands, setAutoCommit, usingDB2Client, usingDerbyNetClient, usingEmbedded
alarm, assertDirectoryDeleted, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertExecJavaCmdAsExpected, assertLaunchedJUnitTestMethod, assertLaunchedJUnitTestMethod, assertSameNullness, assertSecurityManager, assertThrowableEquals, currentDirectory, execJavaCmd, execJavaCmd, execJavaCmd, fail, getClassVersionMajor, getEmmaJar, getFailureFolder, getFilesWith, getJavaExecutableName, getSystemProperty, getTestConfiguration, getTestResource, hasInterruptibleIO, isCVM, isIBMJVM, isJ9Platform, isJava5, isJava7, isPhoneME, isPlatform, isSunJVM, isWindowsPlatform, newAssertionFailedError, openTestResource, println, printStackTrace, readProcessOutput, removeDirectory, removeDirectory, removeFiles, removeSystemProperty, runsWithEmma, runsWithJaCoCo, setSystemErr, setSystemOut, setSystemProperty, sleep, sleepAtLeastOneTick, traceit, vmAtLeast
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, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runTest, setName, setUp, toString
private StatementPoolingTest.LogicalPooledConnectionFactory lpcf
public void tearDown() throws java.lang.Exception
BaseJDBCTestCase
tearDown
in class BaseJDBCTestCase
java.lang.Exception
private void closePooledConnectionFactory() throws java.sql.SQLException
java.sql.SQLException
private java.sql.Connection getCachingConnection() throws java.sql.SQLException
java.sql.SQLException
- if obtaining the connection failsprivate java.sql.Connection getCachingConnection(int cacheSize) throws java.sql.SQLException
cacheSize
- statement cache sizejava.sql.SQLException
- if obtaining the connection failspublic void testCacheOverflow() throws java.sql.SQLException
java.sql.SQLException
- if something goes wrong...public void testPoolingEnabledByCheckingImplementationDetails() throws java.sql.SQLException
java.sql.SQLException
- if creating the JDBC objects failprivate static void assertClassName(java.lang.Object obj, java.lang.String expectedName)
The assert does not consider package names, only the name passed in as
expectedName
and the passed in name concatenated with "40".
WARNING: This method is not a general utility method. Please look at the implementation to determine if you can use it.
obj
- object to checkexpectedName
- the expected name of the classAssertionFailedError
- if the class name is not as expectedpublic void testPrepareStatementPath() throws java.sql.SQLException
java.sql.SQLException
- if creating the prepared statement failspublic void testPrepareCallPath() throws java.sql.SQLException
java.sql.SQLException
- if creating the callable statement failspublic void testPrepareCallWithNoCallPath() throws java.sql.SQLException
java.sql.SQLException
- if creating the callable statement failspublic void testClosingPSClosesRS() throws java.sql.SQLException
java.sql.SQLException
- if something goes wrong...public void testHoldabilityIsResetExplicitClose() throws java.sql.SQLException
java.sql.SQLException
- if something goes wrong...public void testHoldabilityIsResetNoExplicitClose() throws java.sql.SQLException
java.sql.SQLException
- if something goes wrong...private void doTestHoldabilityIsReset(boolean closeConnection) throws java.sql.SQLException
closeConnection
- determines if the logical connection is
explicitly closed before a new one is obtainedjava.sql.SQLException
- if something goes wrong...public void testIsolationLevelIsResetExplicitCloseQuery() throws java.sql.SQLException
java.sql.SQLException
public void testIsolationLevelIsResetExplicitCloseNoQuery() throws java.sql.SQLException
java.sql.SQLException
public void testIsolationLevelIsResetNoExplicitCloseNoQuery() throws java.sql.SQLException
java.sql.SQLException
public void testIsolationLevelIsResetNoExplicitCloseQuery() throws java.sql.SQLException
java.sql.SQLException
private void doTestIsolationLevelIsReset(boolean closeConnection, boolean executeQuery) throws java.sql.SQLException
The two arguments are introduced to test different scenarios; explicit and implicit connection closing, and session data caching (piggybacked information).
closeConnection
- tells if the connection is explicitly closed
before a new one is obtainedexecuteQuery
- tells if a query is executed on the connection before
a new connection is obtained.java.sql.SQLException
- if something goes wrong...public void testCachingLogicalConnectionCloseLeavesPhysicalStatementsOpen() throws java.sql.SQLException
Since there are no public interface methods to test this, the approach taken will be as follows:
java.sql.SQLException
- if something goes wrong...public void resTestCloseDoesNotAffectOtherStatement() throws java.sql.SQLException
java.sql.SQLException
- if something goes wrong...public void testDeleteReferringTableWhenOpen() throws java.sql.SQLException
In this test, the prepared statement that will be made invalid by the delete is held open by the user.
java.sql.SQLException
- if something goes wrong...public void testDeleteReferringTableWhenInCache() throws java.sql.SQLException
In this test, the prepared statement that will be made invalid by the delete is in the statement cache when the delete happens.
java.sql.SQLException
- if something goes wrong...public void resTestCloseCursorsAtCommit() throws java.sql.SQLException
java.sql.SQLException
public void resTestHoldCursorsOverCommit() throws java.sql.SQLException
java.sql.SQLException
public void testTemporaryTablesAreDeletedInNewLogicalConnection() throws java.sql.SQLException
java.sql.SQLException
- if the test fails for some reasonprivate void doTestResultSetCloseForHoldability(int holdability) throws java.sql.SQLException
holdability
- result set holdability as specified by
ResultSet
java.sql.SQLException
- if something goes wrong...public void testGetStatementCallable() throws java.sql.SQLException
ResultSet.getStatement()
returns the same object as the
one that created the result set.java.sql.SQLException
public void testGetStatementPrepared() throws java.sql.SQLException
ResultSet.getStatement()
returns the same object as the
one that created the result set.java.sql.SQLException
private void doTestGetStatement(java.sql.PreparedStatement ps) throws java.sql.SQLException
ResultSet.getStatement()
returns the same object as the
one that created the result set.ps
- prepared or callable statement to test withjava.sql.SQLException
- if something goes wrong...public void resTestLogicalConnectionCloseInvalidatesLogicalStatement() throws java.sql.SQLException
java.sql.SQLException
- if something goes wrong...public void resTestNoCommitOnReuse() throws java.sql.SQLException
java.sql.SQLException
- if something goes wrong...public void resTestCommitOnReuse() throws java.sql.SQLException
java.sql.SQLException
- if something goes wrong...public void resTestNoDataCommittedOnInvalidTransactionState() throws java.sql.SQLException
java.sql.SQLException
- if something goes wrong...private void cleanTableExceptedToBeEmpty() throws java.sql.SQLException
java.sql.SQLException
- if a database operation failspublic static junit.framework.Test suite()
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.