[Proxool-cvs] proxool/src/java-test/org/logicalcobwebs/proxool HouseKeeperTest.java,1.9,1.10
UNMAINTAINED!
Brought to you by:
billhorsman
From: <bil...@us...> - 2005-10-02 23:00:22
|
Update of /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10914/src/java-test/org/logicalcobwebs/proxool Modified Files: HouseKeeperTest.java Log Message: Improved test by checking connectionCount Index: HouseKeeperTest.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool/HouseKeeperTest.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** HouseKeeperTest.java 2 Jun 2004 21:05:19 -0000 1.9 --- HouseKeeperTest.java 2 Oct 2005 12:30:59 -0000 1.10 *************** *** 8,11 **** --- 8,12 ---- import org.logicalcobwebs.logging.Log; import org.logicalcobwebs.logging.LogFactory; + import org.logicalcobwebs.proxool.admin.SnapshotIF; import java.sql.Connection; *************** *** 47,50 **** --- 48,53 ---- info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); info.setProperty(ProxoolConstants.MAXIMUM_ACTIVE_TIME_PROPERTY, "1000"); + info.setProperty(ProxoolConstants.MINIMUM_CONNECTION_COUNT_PROPERTY, "1"); + info.setProperty(ProxoolConstants.TRACE_PROPERTY, "true"); info.setProperty(ProxoolConstants.HOUSE_KEEPING_SLEEP_TIME_PROPERTY, "1000"); ProxoolFacade.registerConnectionPool(url, info); *************** *** 53,57 **** final Connection connection = DriverManager.getConnection(url); ! ; long start = System.currentTimeMillis(); --- 56,60 ---- final Connection connection = DriverManager.getConnection(url); ! connection.createStatement().executeQuery(TestConstants.HYPERSONIC_TEST_SQL); long start = System.currentTimeMillis(); *************** *** 71,77 **** long elapsed = System.currentTimeMillis() - start; assertTrue("Connection has not been closed after " + elapsed + " milliseconds as expected", connection.isClosed()); - assertEquals("Expected the connection to be inactive", 0, ProxoolFacade.getSnapshot(alias, false).getActiveConnectionCount()); } --- 74,102 ---- long elapsed = System.currentTimeMillis() - start; assertTrue("Connection has not been closed after " + elapsed + " milliseconds as expected", connection.isClosed()); assertEquals("Expected the connection to be inactive", 0, ProxoolFacade.getSnapshot(alias, false).getActiveConnectionCount()); + try { + connection.createStatement().executeQuery(TestConstants.HYPERSONIC_TEST_SQL); + fail("Calling createStatement() on a closed connection should fail"); + } catch (Exception e) { + // s'okay. We expected this + LOG.debug("Ignoring expected exception: " + e.getMessage()); + } + + // Now close the connection ourselves. It's already been closed by the House Keeper but nothing bad should + // happen if we do it again now. + connection.close(); + + // Let's see if the prototyper builds another one + try { + Thread.sleep(3000); + } catch (InterruptedException e) { + LOG.debug("Awoken."); + } + SnapshotIF snapshot = ProxoolFacade.getSnapshot(alias, false); + assertEquals("activeConnectionCount", 0, snapshot.getActiveConnectionCount()); + assertEquals("availableConnectionCount", 1, snapshot.getAvailableConnectionCount()); + assertEquals("connectionCount", 1, snapshot.getConnectionCount()); + } *************** *** 226,229 **** --- 251,257 ---- Revision history: $Log$ + Revision 1.10 2005/10/02 12:30:59 billhorsman + Improved test by checking connectionCount + Revision 1.9 2004/06/02 21:05:19 billhorsman Don't log worrying stack traces for expected exceptions. |