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 kr...@apache.org on 2008/05/26 13:43:15 UTC
svn commit: r660165 -
/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/StatementPoolingTest.java
Author: kristwaa
Date: Mon May 26 04:43:13 2008
New Revision: 660165
URL: http://svn.apache.org/viewvc?rev=660165&view=rev
Log:
DERBY-3596: Test cleanup only.
Renamed test (added the word 'Physical'), added a missing fail(), changed some comments and added a constant for a SQL statement used multiple times.
Patch file: derby-3596-3a-test_cleanup.diff
Modified:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/StatementPoolingTest.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=660165&r1=660164&r2=660165&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 Mon May 26 04:43:13 2008
@@ -321,12 +321,12 @@
}
/**
- * Tests that closing the connection closes the logical prepared statement,
- * but not the physical statement.
+ * Tests that closing the caching logical connection closes the logical
+ * prepared statement, but not the physical prepared statement.
* <p>
- * Since there are not public interface methods to test this, the approcah
- * taken will be this:
- * <ol> <li>Create a new table</li>
+ * Since there are no public interface methods to test this, the approach
+ * taken will be as follows:
+ * <ol> <li>Create a new table.</li>
* <li>Prepare a statement selecting from the table.</li>
* <li>Close the statement, putting it into the cache.</li>
* <li>Delete the table.</li>
@@ -336,12 +336,13 @@
* If the physical statement was closed when closing the caching logical
* connection, the prepare will fail. If it was left open, the prepare will
* succeed because the statement is fetched from the cache, but the
- * execution will fail becuase the table no longer exists.
+ * execution will fail because the table no longer exists.
*
* @throws SQLException if something goes wrong...
*/
- public void testCachingLogicalConnectionCloseLeavesStatementsOpen()
+ public void testCachingLogicalConnectionCloseLeavesPhysicalStatementsOpen()
throws SQLException {
+ final String SELECT_SQL = "select * from clcclso";
ConnectionPoolDataSource cpDs =
J2EEDataSource.getConnectionPoolDataSource();
J2EEDataSource.setBeanProperty(cpDs, "maxStatements", new Integer(7));
@@ -354,11 +355,13 @@
con.setAutoCommit(false);
Statement stmt = createStatement();
stmt.executeUpdate("create table clcclso (id int)");
- PreparedStatement ps = con.prepareStatement("select * from clcclso");
+ PreparedStatement ps = con.prepareStatement(SELECT_SQL);
commit();
con.close();
try {
+ // Should fail because the logical statement has been closed.
ps.execute();
+ fail("Logical connection close did not close logical statement.");
} catch (SQLException sqle) {
// Already closed.
assertSQLState("XJ012", sqle);
@@ -369,8 +372,9 @@
// If an exception is thrown here, statement pooling is disabled or not
// working correctly.
con = pc.getConnection();
- ps = con.prepareStatement("select * from clcclso");
+ ps = con.prepareStatement(SELECT_SQL); // From cache.
try {
+ // Should fail here because the referenced table has been deleted.
ps.execute();
fail("Execution should have failed");
} catch (SQLException sqle) {