[Proxool-cvs] proxool/src/java-test/org/logicalcobwebs/proxool UpdateDefinitionTest.java,1.7,1.8
UNMAINTAINED!
Brought to you by:
billhorsman
From: <bil...@us...> - 2005-09-25 21:48:19
|
Update of /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23975/src/java-test/org/logicalcobwebs/proxool Modified Files: UpdateDefinitionTest.java Log Message: New test to check that asking for a connection using the same URL and properties doesn't redefine the pool. Index: UpdateDefinitionTest.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool/UpdateDefinitionTest.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** UpdateDefinitionTest.java 26 May 2004 17:19:10 -0000 1.7 --- UpdateDefinitionTest.java 25 Sep 2005 21:48:09 -0000 1.8 *************** *** 10,13 **** --- 10,15 ---- import java.sql.DriverManager; + import java.sql.Connection; + import java.sql.SQLException; import java.util.Properties; *************** *** 107,110 **** --- 109,155 ---- /** + * If we request a connection using exactly the same URL and properties check that it doesn't trigger an update + * which forces the pool to be restarted (all existing connections destroyed). + */ + public void testDefinitionNotChanging() throws SQLException, ProxoolException { + + String testName = "definitionNotChanging"; + String alias = testName; + + + Connection c1 = null; + try { + String url = TestHelper.buildProxoolUrl(alias, + TestConstants.HYPERSONIC_DRIVER, + TestConstants.HYPERSONIC_TEST_URL); + Properties info = new Properties(); + info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); + info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); + info.setProperty(ProxoolConstants.MAXIMUM_CONNECTION_COUNT_PROPERTY, "1"); + c1 = DriverManager.getConnection(url, info); + assertEquals("id=1", 1L, ProxoolFacade.getId(c1)); + } finally { + c1.close(); + } + // The second attempt (using the same definition) should give back the same connection ID + Connection c2 = null; + try { + String url = TestHelper.buildProxoolUrl(alias, + TestConstants.HYPERSONIC_DRIVER, + TestConstants.HYPERSONIC_TEST_URL); + Properties info = new Properties(); + info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); + info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); + info.setProperty(ProxoolConstants.MAXIMUM_CONNECTION_COUNT_PROPERTY, "1"); + c2 = DriverManager.getConnection(url, info); + assertEquals("id=1", 1L, ProxoolFacade.getId(c2)); + } finally { + c2.close(); + } + // Not the same object. It's wrapped. + assertNotSame("c1!=c2", c1, c2); + } + + /** * Can we update a pool definition by calling updateConnectionPool? */ *************** *** 151,154 **** --- 196,202 ---- Revision history: $Log$ + Revision 1.8 2005/09/25 21:48:09 billhorsman + New test to check that asking for a connection using the same URL and properties doesn't redefine the pool. + Revision 1.7 2004/05/26 17:19:10 brenuart Allow JUnit tests to be executed against another database. |