Source Code Cross Referenced for RegistrationTest.java in  » Database-JDBC-Connection-Pool » proxool » org » logicalcobwebs » proxool » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database JDBC Connection Pool » proxool » org.logicalcobwebs.proxool 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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:
011:        import java.sql.DriverManager;
012:        import java.sql.SQLException;
013:        import java.util.Properties;
014:
015:        /**
016:         * Test whether we can register and remove a pool in various ways
017:         *
018:         * @version $Revision: 1.7 $, $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 RegistrationTest extends AbstractProxoolTest {
024:
025:            private static final Log LOG = LogFactory
026:                    .getLog(RegistrationTest.class);
027:
028:            public RegistrationTest(String alias) {
029:                super (alias);
030:            }
031:
032:            /**
033:             * Test whether we can implicitly register a pool by
034:             */
035:            public void testRegister() throws Exception {
036:
037:                String testName = "register";
038:                String alias = testName;
039:
040:                String url = TestHelper.buildProxoolUrl(alias,
041:                        TestConstants.HYPERSONIC_DRIVER,
042:                        TestConstants.HYPERSONIC_TEST_URL);
043:                Properties info = new Properties();
044:                info.setProperty(ProxoolConstants.USER_PROPERTY,
045:                        TestConstants.HYPERSONIC_USER);
046:                info.setProperty(ProxoolConstants.PASSWORD_PROPERTY,
047:                        TestConstants.HYPERSONIC_PASSWORD);
048:
049:                ProxoolFacade.registerConnectionPool(url, info);
050:
051:                assertNotNull("snapshot exists", ProxoolFacade
052:                        .getSnapshot(alias));
053:
054:                // TODO check that properties are configured properly
055:
056:            }
057:
058:            /**
059:             * Can we register, remove and then re-register the same pool?
060:             */
061:            public void testRemove() throws Exception {
062:
063:                String testName = "remove";
064:                String alias = testName;
065:
066:                // Register
067:                String url = TestHelper.buildProxoolUrl(alias,
068:                        TestConstants.HYPERSONIC_DRIVER,
069:                        TestConstants.HYPERSONIC_TEST_URL);
070:                Properties info = new Properties();
071:                info.setProperty(ProxoolConstants.USER_PROPERTY,
072:                        TestConstants.HYPERSONIC_USER);
073:                info.setProperty(ProxoolConstants.PASSWORD_PROPERTY,
074:                        TestConstants.HYPERSONIC_PASSWORD);
075:                ProxoolFacade.registerConnectionPool(url, info);
076:
077:                try {
078:                    DriverManager.getConnection(url).close();
079:                } catch (SQLException e) {
080:                    fail("Couldn't get connection");
081:                }
082:
083:                // Remove using alias
084:                ProxoolFacade.removeConnectionPool(alias);
085:                try {
086:                    ProxoolFacade.getConnectionPoolDefinition(alias);
087:                    fail("Didn't expect to get definition of pool that was just removed");
088:                } catch (ProxoolException e) {
089:                    LOG.debug("Ignore expected exception", e);
090:                }
091:
092:                // Register again
093:                ProxoolFacade.registerConnectionPool(url, info);
094:                try {
095:                    DriverManager.getConnection(url).close();
096:                } catch (SQLException e) {
097:                    fail("Couldn't get connection");
098:                }
099:                // Should only be one served (the earlier one is forgotten)
100:                assertEquals("servedCount", 1L, ProxoolFacade
101:                        .getSnapshot(alias).getServedCount());
102:
103:                // Remove using alias
104:                ProxoolFacade.removeConnectionPool(alias);
105:                try {
106:                    ProxoolFacade.getConnectionPoolDefinition(alias);
107:                    fail("Didn't expect to get definition of pool that was just removed");
108:                } catch (ProxoolException e) {
109:                    LOG.debug("Ignore expected exception", e);
110:                }
111:
112:                // Register again
113:                ProxoolFacade.registerConnectionPool(url, info);
114:                try {
115:                    DriverManager.getConnection(url).close();
116:                } catch (SQLException e) {
117:                    fail("Couldn't get connection");
118:                }
119:                // Should only be one served (the earlier one is forgotten)
120:                assertEquals("servedCount", 1L, ProxoolFacade
121:                        .getSnapshot(alias).getServedCount());
122:
123:            }
124:
125:            /**
126:             * Can we have multiple pools?
127:             */
128:            public void testMultiple() throws Exception, ClassNotFoundException {
129:
130:                String testName = "multiple";
131:                String alias1 = testName + "1";
132:                String alias2 = testName + "2";
133:
134:                // Register
135:                String url1 = TestHelper.buildProxoolUrl(alias1,
136:                        TestConstants.HYPERSONIC_DRIVER,
137:                        TestConstants.HYPERSONIC_TEST_URL);
138:                String url2 = TestHelper.buildProxoolUrl(alias2,
139:                        TestConstants.HYPERSONIC_DRIVER,
140:                        TestConstants.HYPERSONIC_TEST_URL);
141:                Properties info = new Properties();
142:                info.setProperty(ProxoolConstants.USER_PROPERTY,
143:                        TestConstants.HYPERSONIC_USER);
144:                info.setProperty(ProxoolConstants.PASSWORD_PROPERTY,
145:                        TestConstants.HYPERSONIC_PASSWORD);
146:                ProxoolFacade.registerConnectionPool(url1, info);
147:                ProxoolFacade.registerConnectionPool(url2, info);
148:
149:                // Open 2 connections on #1
150:                DriverManager.getConnection(url1).close();
151:                DriverManager.getConnection(url1).close();
152:
153:                // Open 1 connection on #2
154:                DriverManager.getConnection(url2).close();
155:
156:                assertEquals("connectionsServedCount #1", 2L, ProxoolFacade
157:                        .getSnapshot(alias1).getServedCount());
158:                assertEquals("connectionsServedCount #2", 1L, ProxoolFacade
159:                        .getSnapshot(alias2).getServedCount());
160:
161:            }
162:
163:        }
164:
165:        /*
166:         Revision history:
167:         $Log: RegistrationTest.java,v $
168:         Revision 1.7  2006/01/18 14:40:06  billhorsman
169:         Unbundled Jakarta's Commons Logging.
170:
171:         Revision 1.6  2003/03/04 10:58:44  billhorsman
172:         checkstyle
173:
174:         Revision 1.5  2003/03/04 10:24:40  billhorsman
175:         removed try blocks around each test
176:
177:         Revision 1.4  2003/03/03 17:09:06  billhorsman
178:         all tests now extend AbstractProxoolTest
179:
180:         Revision 1.3  2003/03/03 11:12:05  billhorsman
181:         fixed licence
182:
183:         Revision 1.2  2003/03/01 15:27:24  billhorsman
184:         checkstyle
185:
186:         Revision 1.1  2003/02/27 18:01:48  billhorsman
187:         completely rethought the test structure. it's now
188:         more obvious. no new tests yet though.
189:
190:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.