Source Code Cross Referenced for KillTest.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 java.util.Properties;
009:        import java.sql.Connection;
010:        import java.sql.DriverManager;
011:
012:        /**
013:         * Tests whether we can kill connections when we want to
014:         * @version $Revision: 1.2 $, $Date: 2006/05/23 21:33:52 $
015:         * @author <a href="mailto:bill@logicalcobwebs.co.uk">Bill Horsman</a>
016:         * @author $Author: billhorsman $ (current maintainer)
017:         * @since Proxool 0.9
018:         */
019:        public class KillTest extends AbstractProxoolTest {
020:            private static final boolean MERCIFUL = true;
021:            private static final boolean MERCILESS = false;
022:            private static final boolean DETAILED = true;
023:
024:            /**
025:             * @see AbstractProxoolTest
026:             */
027:            public KillTest(String alias) {
028:                super (alias);
029:            }
030:
031:            /**
032:             * @see ProxoolFacade#killAllConnections(java.lang.String, java.lang.String, boolean)
033:             */
034:            public void testKillAllMercifully() throws Exception {
035:                String alias = "killAllMercifully";
036:                String url = TestHelper.buildProxoolUrl(alias,
037:                        TestConstants.HYPERSONIC_DRIVER,
038:                        TestConstants.HYPERSONIC_TEST_URL);
039:                Properties info = new Properties();
040:                info.setProperty(ProxoolConstants.USER_PROPERTY,
041:                        TestConstants.HYPERSONIC_USER);
042:                info.setProperty(ProxoolConstants.PASSWORD_PROPERTY,
043:                        TestConstants.HYPERSONIC_PASSWORD);
044:                info
045:                        .setProperty(
046:                                ProxoolConstants.MAXIMUM_CONNECTION_COUNT_PROPERTY,
047:                                "2");
048:                Connection c1 = DriverManager.getConnection(url, info);
049:                Connection c2 = DriverManager.getConnection(url, info);
050:                c1.close();
051:                c2.close();
052:                // There should now be two connections built
053:                assertEquals("Connection count", 2, ProxoolFacade.getSnapshot(
054:                        alias, DETAILED).getConnectionInfos().length);
055:                ProxoolFacade.killAllConnections(alias, "testing", MERCIFUL);
056:                // None left
057:                assertEquals("Connection count", 0, ProxoolFacade.getSnapshot(
058:                        alias, DETAILED).getConnectionInfos().length);
059:            }
060:
061:            /**
062:             * @see ProxoolFacade#killAllConnections(java.lang.String, java.lang.String, boolean)
063:             */
064:            public void testKillAllMercilessly() throws Exception {
065:                String alias = "killAllMercilessly";
066:                String url = TestHelper.buildProxoolUrl(alias,
067:                        TestConstants.HYPERSONIC_DRIVER,
068:                        TestConstants.HYPERSONIC_TEST_URL);
069:                Properties info = new Properties();
070:                info.setProperty(ProxoolConstants.USER_PROPERTY,
071:                        TestConstants.HYPERSONIC_USER);
072:                info.setProperty(ProxoolConstants.PASSWORD_PROPERTY,
073:                        TestConstants.HYPERSONIC_PASSWORD);
074:                info
075:                        .setProperty(
076:                                ProxoolConstants.MAXIMUM_CONNECTION_COUNT_PROPERTY,
077:                                "2");
078:                Connection c1 = DriverManager.getConnection(url, info);
079:                Connection c2 = DriverManager.getConnection(url, info);
080:                // There should now be two connections built
081:                assertEquals("Connection count", 2, ProxoolFacade.getSnapshot(
082:                        alias, DETAILED).getConnectionInfos().length);
083:                ProxoolFacade.killAllConnections(alias, "testing", MERCILESS);
084:                // None left
085:                assertEquals("Connection count", 0, ProxoolFacade.getSnapshot(
086:                        alias, DETAILED).getConnectionInfos().length);
087:                c1.close();
088:                c2.close();
089:            }
090:
091:            /**
092:             * @see ProxoolFacade#killConnecton(java.lang.String, long, boolean)
093:             */
094:            public void testKillOneById() throws Exception {
095:                String alias = "killOneById";
096:                String url = TestHelper.buildProxoolUrl(alias,
097:                        TestConstants.HYPERSONIC_DRIVER,
098:                        TestConstants.HYPERSONIC_TEST_URL);
099:                Properties info = new Properties();
100:                info.setProperty(ProxoolConstants.USER_PROPERTY,
101:                        TestConstants.HYPERSONIC_USER);
102:                info.setProperty(ProxoolConstants.PASSWORD_PROPERTY,
103:                        TestConstants.HYPERSONIC_PASSWORD);
104:                info
105:                        .setProperty(
106:                                ProxoolConstants.MAXIMUM_CONNECTION_COUNT_PROPERTY,
107:                                "2");
108:                Connection c1 = DriverManager.getConnection(url, info);
109:                Connection c2 = DriverManager.getConnection(url, info);
110:                c1.close();
111:                c2.close();
112:                // There should now be two connections built
113:                assertEquals("Connection count", 2, ProxoolFacade.getSnapshot(
114:                        alias, DETAILED).getConnectionInfos().length);
115:                long id1 = ProxoolFacade.getId(c1);
116:                long id2 = ProxoolFacade.getId(c2);
117:                ProxoolFacade.killConnecton(alias, id1, MERCIFUL);
118:                // One left
119:                assertEquals("Connection count", 1, ProxoolFacade.getSnapshot(
120:                        alias, DETAILED).getConnectionInfos().length);
121:                assertEquals("Active count", 0, ProxoolFacade.getSnapshot(
122:                        alias, DETAILED).getActiveConnectionCount());
123:                Connection c3 = DriverManager.getConnection(url, info);
124:                assertEquals("Active count", 1, ProxoolFacade.getSnapshot(
125:                        alias, DETAILED).getActiveConnectionCount());
126:                long id3 = ProxoolFacade.getId(c3);
127:                Connection c4 = DriverManager.getConnection(url, info);
128:                assertEquals("Active count", 2, ProxoolFacade.getSnapshot(
129:                        alias, DETAILED).getActiveConnectionCount());
130:                long id4 = ProxoolFacade.getId(c4);
131:                c3.close();
132:                c4.close();
133:                assertTrue("Killed ID served", id3 != id1);
134:                assertTrue("Killed ID served", id4 != id1);
135:            }
136:
137:            /**
138:             * @see ProxoolFacade#killConnecton(java.lang.String, long, boolean)
139:             */
140:            public void testKillOneByConnection() throws Exception {
141:                String alias = "killOneByConnection";
142:                String url = TestHelper.buildProxoolUrl(alias,
143:                        TestConstants.HYPERSONIC_DRIVER,
144:                        TestConstants.HYPERSONIC_TEST_URL);
145:                Properties info = new Properties();
146:                info.setProperty(ProxoolConstants.USER_PROPERTY,
147:                        TestConstants.HYPERSONIC_USER);
148:                info.setProperty(ProxoolConstants.PASSWORD_PROPERTY,
149:                        TestConstants.HYPERSONIC_PASSWORD);
150:                info
151:                        .setProperty(
152:                                ProxoolConstants.MAXIMUM_CONNECTION_COUNT_PROPERTY,
153:                                "2");
154:                Connection c1 = DriverManager.getConnection(url, info);
155:                Connection c2 = DriverManager.getConnection(url, info);
156:                c1.close();
157:                c2.close();
158:                // There should now be two connections built
159:                assertEquals("Connection count", 2, ProxoolFacade.getSnapshot(
160:                        alias, DETAILED).getConnectionInfos().length);
161:                long id1 = ProxoolFacade.getId(c1);
162:                long id2 = ProxoolFacade.getId(c2);
163:                ProxoolFacade.killConnecton(c1, MERCIFUL);
164:                // One left
165:                assertEquals("Connection count", 1, ProxoolFacade.getSnapshot(
166:                        alias, DETAILED).getConnectionInfos().length);
167:                Connection c3 = DriverManager.getConnection(url, info);
168:                long id3 = ProxoolFacade.getId(c3);
169:                Connection c4 = DriverManager.getConnection(url, info);
170:                long id4 = ProxoolFacade.getId(c4);
171:                c3.close();
172:                c4.close();
173:                assertTrue("Killed ID served", id3 != id1);
174:                assertTrue("Killed ID served", id4 != id1);
175:            }
176:
177:        }
178:        /*
179:         Revision history:
180:         $Log: KillTest.java,v $
181:         Revision 1.2  2006/05/23 21:33:52  billhorsman
182:         More asserts
183:
184:         Revision 1.1  2004/03/23 21:14:24  billhorsman
185:         new tests
186:
187:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.