KickJava   Java API By Example, From Geeks To Geeks.

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


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
11 import java.sql.DriverManager JavaDoc;
12 import java.util.Properties JavaDoc;
13
14 /**
15  * Tests {@link ProxoolDriver}
16  *
17  * @version $Revision: 1.6 $, $Date: 2006/01/18 14:40:06 $
18  * @author bill
19  * @author $Author: billhorsman $ (current maintainer)
20  * @since Proxool 0.8
21  */

22 public class DriverTest extends AbstractProxoolTest {
23
24     private static final Log LOG = LogFactory.getLog(DriverTest.class);
25
26     public DriverTest(String JavaDoc alias) {
27         super(alias);
28     }
29
30     /**
31      * Can we refer to the same pool by either the complete URL or the alias?
32      */

33     public void testAlias() throws Exception JavaDoc {
34
35         String JavaDoc testName = "alias";
36         String JavaDoc alias = testName;
37
38         // Register pool
39
String JavaDoc url = TestHelper.buildProxoolUrl(alias,
40                 TestConstants.HYPERSONIC_DRIVER,
41                 TestConstants.HYPERSONIC_TEST_URL);
42         Properties JavaDoc info = new Properties JavaDoc();
43         info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER);
44         info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD);
45         DriverManager.getConnection(url, info).close();
46         assertEquals("servedCount", 1, ProxoolFacade.getSnapshot(alias).getServedCount());
47
48         // Get it back by url
49
url = TestHelper.buildProxoolUrl(alias,
50                 TestConstants.HYPERSONIC_DRIVER,
51                 TestConstants.HYPERSONIC_TEST_URL);
52         DriverManager.getConnection(url).close();
53         assertEquals("servedCount", 2, ProxoolFacade.getSnapshot(alias).getServedCount());
54
55         // Get it back by name
56
url = TestHelper.buildProxoolUrl(alias);
57         DriverManager.getConnection(ProxoolConstants.PROXOOL + "." + alias).close();
58         assertEquals("servedCount", 3, ProxoolFacade.getSnapshot(alias).getServedCount());
59
60     }
61
62
63 }
64
65
66 /*
67  Revision history:
68  $Log: DriverTest.java,v $
69  Revision 1.6 2006/01/18 14:40:06 billhorsman
70  Unbundled Jakarta's Commons Logging.
71
72  Revision 1.5 2003/04/29 12:04:18 billhorsman
73  fix test
74
75  Revision 1.4 2003/03/04 10:24:40 billhorsman
76  removed try blocks around each test
77
78  Revision 1.3 2003/03/03 17:08:57 billhorsman
79  all tests now extend AbstractProxoolTest
80
81  Revision 1.2 2003/03/03 11:12:04 billhorsman
82  fixed licence
83
84  Revision 1.1 2003/02/27 18:01:48 billhorsman
85  completely rethought the test structure. it's now
86  more obvious. no new tests yet though.
87
88  */
Popular Tags