You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2013/02/19 11:59:23 UTC
svn commit: r1447667 - in
/db/derby/code/trunk/java/testing/org/apache/derbyTesting:
functionTests/tests/jdbcapi/StatementPoolingTest.java
junit/ConnectionPoolDataSourceConnector.java
Author: kahatlen
Date: Tue Feb 19 10:59:23 2013
New Revision: 1447667
URL: http://svn.apache.org/r1447667
Log:
DERBY-6073: Test ordering instability in StatementPoolingTest
ConnectionPoolDataSourceConnector should enable statement pooling
also if the database doesn't already exist.
Modified:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/StatementPoolingTest.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ConnectionPoolDataSourceConnector.java
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/StatementPoolingTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/StatementPoolingTest.java?rev=1447667&r1=1447666&r2=1447667&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/StatementPoolingTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/StatementPoolingTest.java Tue Feb 19 10:59:23 2013
@@ -53,7 +53,7 @@ public class StatementPoolingTest
*
* @throws SQLException if something goes wrong...
*/
- public void t01_testCacheOverflow()
+ public void testCacheOverflow()
throws SQLException {
final int stmtCount = 150;
ConnectionPoolDataSource cpDs =
@@ -79,7 +79,7 @@ public class StatementPoolingTest
*
* @throws SQLException if creating the JDBC objects fail
*/
- public void t02_testPoolingEnabledByCheckingImplementationDetails()
+ public void testPoolingEnabledByCheckingImplementationDetails()
throws SQLException {
final String conClass = "CachingLogicalConnection";
final String psClass = "LogicalPreparedStatement";
@@ -159,7 +159,7 @@ public class StatementPoolingTest
*
* @throws SQLException if creating the prepared statement fails
*/
- public void t03_testPrepareStatementPath()
+ public void testPrepareStatementPath()
throws SQLException {
PreparedStatement ps = prepareStatement("values 9708");
ps.close();
@@ -171,7 +171,7 @@ public class StatementPoolingTest
*
* @throws SQLException if creating the callable statement fails
*/
- public void t04_testPrepareCallPath()
+ public void testPrepareCallPath()
throws SQLException {
CallableStatement cs = prepareCall(
"CALL SYSCS_UTIL.SYSCS_SET_RUNTIMESTATISTICS(0)");
@@ -184,7 +184,7 @@ public class StatementPoolingTest
*
* @throws SQLException if creating the callable statement fails
*/
- public void t05_testPrepareCallWithNoCallPath()
+ public void testPrepareCallWithNoCallPath()
throws SQLException {
CallableStatement cs = prepareCall("values 1");
cs.close();
@@ -195,7 +195,7 @@ public class StatementPoolingTest
*
* @throws SQLException if something goes wrong...
*/
- public void t06_testClosingPSClosesRS()
+ public void testClosingPSClosesRS()
throws SQLException {
PreparedStatement ps = prepareStatement("values 99");
ResultSet rs = ps.executeQuery();
@@ -214,7 +214,7 @@ public class StatementPoolingTest
*
* @throws SQLException if something goes wrong...
*/
- public void t07_testHoldabilityIsResetExplicitClose()
+ public void testHoldabilityIsResetExplicitClose()
throws SQLException {
doTestHoldabilityIsReset(true);
}
@@ -226,7 +226,7 @@ public class StatementPoolingTest
*
* @throws SQLException if something goes wrong...
*/
- public void t08_testHoldabilityIsResetNoExplicitClose()
+ public void testHoldabilityIsResetNoExplicitClose()
throws SQLException {
doTestHoldabilityIsReset(false);
}
@@ -263,22 +263,22 @@ public class StatementPoolingTest
pc.close();
}
- public void t09_testIsolationLevelIsResetExplicitCloseQuery()
+ public void testIsolationLevelIsResetExplicitCloseQuery()
throws SQLException {
doTestIsolationLevelIsReset(true, true);
}
- public void t11_testIsolationLevelIsResetExplicitCloseNoQuery()
+ public void testIsolationLevelIsResetExplicitCloseNoQuery()
throws SQLException {
doTestIsolationLevelIsReset(true, false);
}
- public void t12_testIsolationLevelIsResetNoExplicitCloseNoQuery()
+ public void testIsolationLevelIsResetNoExplicitCloseNoQuery()
throws SQLException {
doTestIsolationLevelIsReset(false, false);
}
- public void t13_testIsolationLevelIsResetNoExplicitCloseQuery()
+ public void testIsolationLevelIsResetNoExplicitCloseQuery()
throws SQLException {
doTestIsolationLevelIsReset(false, true);
}
@@ -351,7 +351,7 @@ public class StatementPoolingTest
*
* @throws SQLException if something goes wrong...
*/
- public void t14_testCachingLogicalConnectionCloseLeavesPhysicalStatementsOpen()
+ public void testCachingLogicalConnectionCloseLeavesPhysicalStatementsOpen()
throws SQLException {
final String SELECT_SQL = "select * from clcclso";
ConnectionPoolDataSource cpDs =
@@ -456,7 +456,7 @@ public class StatementPoolingTest
*
* @throws SQLException if something goes wrong...
*/
- public void t15_testDeleteReferringTableWhenOpen()
+ public void testDeleteReferringTableWhenOpen()
throws SQLException {
getConnection().setAutoCommit(false);
// Create a table, insert a row, then create a statement selecting it.
@@ -492,7 +492,7 @@ public class StatementPoolingTest
*
* @throws SQLException if something goes wrong...
*/
- public void t16_testDeleteReferringTableWhenInCache()
+ public void testDeleteReferringTableWhenInCache()
throws SQLException {
getConnection().setAutoCommit(false);
// Create a table, insert a row, then create a statement selecting it.
@@ -536,7 +536,7 @@ public class StatementPoolingTest
*
* @throws SQLException if the test fails for some reason
*/
- public void t17_testTemporaryTablesAreDeletedInNewLogicalConnection()
+ public void testTemporaryTablesAreDeletedInNewLogicalConnection()
throws SQLException {
ConnectionPoolDataSource cpds =
J2EEDataSource.getConnectionPoolDataSource();
@@ -609,7 +609,7 @@ public class StatementPoolingTest
* Make sure {@link ResultSet#getStatement} returns the same object as the
* one that created the result set.
*/
- public void t18_testGetStatementCallable()
+ public void testGetStatementCallable()
throws SQLException {
doTestGetStatement(prepareCall("values 7653"));
}
@@ -618,7 +618,7 @@ public class StatementPoolingTest
* Make sure {@link ResultSet#getStatement} returns the same object as the
* one that created the result set.
*/
- public void t19_testGetStatementPrepared()
+ public void testGetStatementPrepared()
throws SQLException {
doTestGetStatement(prepareStatement("values 7652"));
}
@@ -817,28 +817,6 @@ public class StatementPoolingTest
}
}
- public void testAll() throws Exception
- {
- t01_testCacheOverflow();
- t02_testPoolingEnabledByCheckingImplementationDetails();
- t03_testPrepareStatementPath();
- t04_testPrepareCallPath();
- t05_testPrepareCallWithNoCallPath();
- t06_testClosingPSClosesRS();
- t07_testHoldabilityIsResetExplicitClose();
- t08_testHoldabilityIsResetNoExplicitClose();
- t09_testIsolationLevelIsResetExplicitCloseQuery();
- t11_testIsolationLevelIsResetExplicitCloseNoQuery();
- t12_testIsolationLevelIsResetNoExplicitCloseNoQuery();
- t13_testIsolationLevelIsResetNoExplicitCloseQuery();
- t14_testCachingLogicalConnectionCloseLeavesPhysicalStatementsOpen();
- t15_testDeleteReferringTableWhenOpen();
- t16_testDeleteReferringTableWhenInCache();
- t17_testTemporaryTablesAreDeletedInNewLogicalConnection();
- t18_testGetStatementCallable();
- t19_testGetStatementPrepared();
- }
-
public static Test suite() {
TestSuite suite = new TestSuite("StatementPoolingTest suite");
TestSuite baseSuite = new TestSuite(StatementPoolingTest.class);
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ConnectionPoolDataSourceConnector.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ConnectionPoolDataSourceConnector.java?rev=1447667&r1=1447666&r2=1447667&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ConnectionPoolDataSourceConnector.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ConnectionPoolDataSourceConnector.java Tue Feb 19 10:59:23 2013
@@ -51,7 +51,21 @@ public class ConnectionPoolDataSourceCon
this.config = config;
ds = J2EEDataSource.getConnectionPoolDataSource(config, (HashMap) null);
+
// Enable statement pooling by default.
+ enableStatementPooling(ds);
+
+ // NOTE: Any other setup of the data source that gets added here,
+ // probably also needs to be added to singleUseDS(). Otherwise, that
+ // setup won't be performed on data sources that are used to create
+ // or shut down a database.
+
+ }
+
+ /**
+ * Enable statement pooling on the specified data source.
+ */
+ private static void enableStatementPooling(ConnectionPoolDataSource ds) {
// Note that this does not automatically test the pooling itself, but it
// should test basic JDBC operations on the logical wrapper classes.
try {
@@ -184,6 +198,12 @@ public class ConnectionPoolDataSourceCon
{
ConnectionPoolDataSource sds =
J2EEDataSource.getConnectionPoolDataSource(config, hm);
+
+ // Enable statement pooling by default for single-use data sources
+ // too, just like it's enabled for the default data source in
+ // setConfiguration().
+ enableStatementPooling(sds);
+
return sds;
}