001: /*
002: * This software is released under a licence similar to the Apache Software Licence.
003: * See org.logicalcobwebs.proxool.package.html for details.
004: * The latest version is available at http://proxool.sourceforge.net
005: */
006: package org.logicalcobwebs.proxool;
007:
008: import org.apache.commons.logging.Log;
009: import org.apache.commons.logging.LogFactory;
010: import org.logicalcobwebs.proxool.admin.SnapshotResultMonitor;
011: import org.logicalcobwebs.proxool.admin.SnapshotIF;
012:
013: import java.util.Properties;
014:
015: /**
016: * Test whether Proxool is happy to run lots of pools. Is it scalable?
017: *
018: * @version $Revision: 1.4 $, $Date: 2006/01/18 14:40:06 $
019: * @author bill
020: * @author $Author: billhorsman $ (current maintainer)
021: * @since Proxool 0.8
022: */
023: public class ManyPoolsTest extends AbstractProxoolTest {
024:
025: private static final Log LOG = LogFactory
026: .getLog(ManyPoolsTest.class);
027:
028: public ManyPoolsTest(String alias) {
029: super (alias);
030: }
031:
032: public void testManyPools() throws ProxoolException {
033:
034: final String testName = "manyPools";
035:
036: Properties info = new Properties();
037: info.setProperty(ProxoolConstants.USER_PROPERTY,
038: TestConstants.HYPERSONIC_USER);
039: info.setProperty(ProxoolConstants.PASSWORD_PROPERTY,
040: TestConstants.HYPERSONIC_PASSWORD);
041: info.setProperty(ProxoolConstants.VERBOSE_PROPERTY,
042: Boolean.TRUE.toString());
043: info
044: .setProperty(
045: ProxoolConstants.MINIMUM_CONNECTION_COUNT_PROPERTY,
046: "0");
047: info
048: .setProperty(
049: ProxoolConstants.MAXIMUM_CONNECTION_COUNT_PROPERTY,
050: "5");
051: info
052: .setProperty(ProxoolConstants.PROTOTYPE_COUNT_PROPERTY,
053: "2");
054: info.setProperty(
055: ProxoolConstants.HOUSE_KEEPING_SLEEP_TIME_PROPERTY,
056: "30000");
057: info.setProperty(
058: ProxoolConstants.HOUSE_KEEPING_TEST_SQL_PROPERTY,
059: TestConstants.HYPERSONIC_TEST_SQL);
060:
061: final int poolCount = 100;
062: String alias[] = new String[poolCount];
063: for (int i = 0; i < poolCount; i++) {
064: alias[i] = testName + "_" + i;
065: String url = ProxoolConstants.PROXOOL
066: + ProxoolConstants.ALIAS_DELIMITER + alias[i]
067: + ProxoolConstants.URL_DELIMITER
068: + TestConstants.HYPERSONIC_DRIVER
069: + ProxoolConstants.URL_DELIMITER
070: + TestConstants.HYPERSONIC_URL_PREFIX + i;
071: ProxoolFacade.registerConnectionPool(url, info);
072: }
073:
074: SnapshotResultMonitor srm = new SnapshotResultMonitor(
075: alias[poolCount - 1]) {
076: public boolean check(SnapshotIF snapshot) throws Exception {
077: LOG.debug("Checking availableConnectionCount: "
078: + snapshot.getAvailableConnectionCount());
079: return (snapshot.getAvailableConnectionCount() == 2);
080: }
081: };
082: srm.setDelay(2000);
083: srm.setTimeout(300000);
084: assertEquals("Timeout", ResultMonitor.SUCCESS, srm.getResult());
085: assertEquals("activeConnectionCount", 0, srm.getSnapshot()
086: .getActiveConnectionCount());
087:
088: }
089: }
090:
091: /*
092: Revision history:
093: $Log: ManyPoolsTest.java,v $
094: Revision 1.4 2006/01/18 14:40:06 billhorsman
095: Unbundled Jakarta's Commons Logging.
096:
097: Revision 1.3 2004/07/13 20:36:57 billhorsman
098: Open a different database for each pool. Otherwise Hypersonic has some threading issues.
099:
100: Revision 1.2 2004/05/26 17:19:09 brenuart
101: Allow JUnit tests to be executed against another database.
102: By default the test configuration will be taken from the 'testconfig-hsqldb.properties' file located in the org.logicalcobwebs.proxool package.
103: This behavior can be overriden by setting the 'testConfig' environment property to another location.
104:
105: Revision 1.1 2003/03/05 18:49:27 billhorsman
106: moved test to right tree
107:
108: Revision 1.1 2003/03/05 18:42:33 billhorsman
109: big refactor of prototyping and house keeping to
110: drastically reduce the number of threads when using
111: many pools
112:
113: */
|