1 6 package org.logicalcobwebs.proxool; 7 8 import org.apache.commons.logging.Log; 9 import org.apache.commons.logging.LogFactory; 10 import org.logicalcobwebs.proxool.admin.SnapshotResultMonitor; 11 import org.logicalcobwebs.proxool.admin.SnapshotIF; 12 13 import java.util.Properties ; 14 15 23 public class ManyPoolsTest extends AbstractProxoolTest { 24 25 private static final Log LOG = LogFactory.getLog(ManyPoolsTest.class); 26 27 public ManyPoolsTest(String alias) { 28 super(alias); 29 } 30 31 public void testManyPools() throws ProxoolException { 32 33 final String testName = "manyPools"; 34 35 Properties info = new Properties (); 36 info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); 37 info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); 38 info.setProperty(ProxoolConstants.VERBOSE_PROPERTY, Boolean.TRUE.toString()); 39 info.setProperty(ProxoolConstants.MINIMUM_CONNECTION_COUNT_PROPERTY, "0"); 40 info.setProperty(ProxoolConstants.MAXIMUM_CONNECTION_COUNT_PROPERTY, "5"); 41 info.setProperty(ProxoolConstants.PROTOTYPE_COUNT_PROPERTY, "2"); 42 info.setProperty(ProxoolConstants.HOUSE_KEEPING_SLEEP_TIME_PROPERTY, "30000"); 43 info.setProperty(ProxoolConstants.HOUSE_KEEPING_TEST_SQL_PROPERTY, TestConstants.HYPERSONIC_TEST_SQL); 44 45 final int poolCount = 100; 46 String alias[] = new String [poolCount]; 47 for (int i = 0; i < poolCount; i++) { 48 alias[i] = testName + "_" + i; 49 String url = ProxoolConstants.PROXOOL 50 + ProxoolConstants.ALIAS_DELIMITER 51 + alias[i] 52 + ProxoolConstants.URL_DELIMITER 53 + TestConstants.HYPERSONIC_DRIVER 54 + ProxoolConstants.URL_DELIMITER 55 + TestConstants.HYPERSONIC_URL_PREFIX + i; 56 ProxoolFacade.registerConnectionPool(url, info); 57 } 58 59 SnapshotResultMonitor srm = new SnapshotResultMonitor(alias[poolCount - 1]) { 60 public boolean check(SnapshotIF snapshot) throws Exception { 61 LOG.debug("Checking availableConnectionCount: " + snapshot.getAvailableConnectionCount()); 62 return (snapshot.getAvailableConnectionCount() == 2); 63 } 64 }; 65 srm.setDelay(2000); 66 srm.setTimeout(300000); 67 assertEquals("Timeout", ResultMonitor.SUCCESS, srm.getResult()); 68 assertEquals("activeConnectionCount", 0, srm.getSnapshot().getActiveConnectionCount()); 69 70 } 71 } 72 73 74 | Popular Tags |