KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > logicalcobwebs > proxool > ManyPoolsTest


1 /*
2  * This software is released under a licence similar to the Apache Software Licence.
3  * See org.logicalcobwebs.proxool.package.html for details.
4  * The latest version is available at http://proxool.sourceforge.net
5  */

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 JavaDoc;
14
15 /**
16  * Test whether Proxool is happy to run lots of pools. Is it scalable?
17  *
18  * @version $Revision: 1.4 $, $Date: 2006/01/18 14:40:06 $
19  * @author bill
20  * @author $Author: billhorsman $ (current maintainer)
21  * @since Proxool 0.8
22  */

23 public class ManyPoolsTest extends AbstractProxoolTest {
24
25     private static final Log LOG = LogFactory.getLog(ManyPoolsTest.class);
26
27     public ManyPoolsTest(String JavaDoc alias) {
28         super(alias);
29     }
30
31     public void testManyPools() throws ProxoolException {
32
33         final String JavaDoc testName = "manyPools";
34
35         Properties JavaDoc info = new Properties JavaDoc();
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 JavaDoc alias[] = new String JavaDoc[poolCount];
47         for (int i = 0; i < poolCount; i++) {
48             alias[i] = testName + "_" + i;
49             String JavaDoc 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 JavaDoc {
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 /*
75  Revision history:
76  $Log: ManyPoolsTest.java,v $
77  Revision 1.4 2006/01/18 14:40:06 billhorsman
78  Unbundled Jakarta's Commons Logging.
79
80  Revision 1.3 2004/07/13 20:36:57 billhorsman
81  Open a different database for each pool. Otherwise Hypersonic has some threading issues.
82
83  Revision 1.2 2004/05/26 17:19:09 brenuart
84  Allow JUnit tests to be executed against another database.
85  By default the test configuration will be taken from the 'testconfig-hsqldb.properties' file located in the org.logicalcobwebs.proxool package.
86  This behavior can be overriden by setting the 'testConfig' environment property to another location.
87
88  Revision 1.1 2003/03/05 18:49:27 billhorsman
89  moved test to right tree
90
91  Revision 1.1 2003/03/05 18:42:33 billhorsman
92  big refactor of prototyping and house keeping to
93  drastically reduce the number of threads when using
94  many pools
95
96  */
Popular Tags