Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 47988 invoked from network); 26 May 2008 11:43:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 May 2008 11:43:39 -0000 Received: (qmail 83710 invoked by uid 500); 26 May 2008 11:43:40 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 83682 invoked by uid 500); 26 May 2008 11:43:40 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 83673 invoked by uid 99); 26 May 2008 11:43:40 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 May 2008 04:43:40 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 May 2008 11:42:54 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 8D6DD23889F1; Mon, 26 May 2008 04:43:15 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r660165 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/StatementPoolingTest.java Date: Mon, 26 May 2008 11:43:15 -0000 To: derby-commits@db.apache.org From: kristwaa@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080526114315.8D6DD23889F1@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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. *

- * Since there are not public interface methods to test this, the approcah - * taken will be this: - *

  1. Create a new table
  2. + * Since there are no public interface methods to test this, the approach + * taken will be as follows: + *
    1. Create a new table.
    2. *
    3. Prepare a statement selecting from the table.
    4. *
    5. Close the statement, putting it into the cache.
    6. *
    7. Delete the table.
    8. @@ -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) {