Source Code Cross Referenced for InjectableInterfaceTest.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.util.Properties;
012:        import java.sql.Connection;
013:        import java.sql.DriverManager;
014:        import java.sql.Statement;
015:        import java.sql.PreparedStatement;
016:        import java.sql.CallableStatement;
017:
018:        /**
019:         * Tests whether we can inject a new interface into one of the proxy objects
020:         * @version $Revision: 1.3 $, $Date: 2006/01/18 14:40:06 $
021:         * @author <a href="mailto:bill@logicalcobwebs.co.uk">Bill Horsman</a>
022:         * @author $Author: billhorsman $ (current maintainer)
023:         * @since Proxool 0.9
024:         */
025:        public class InjectableInterfaceTest extends AbstractProxoolTest {
026:
027:            private static final Log LOG = LogFactory
028:                    .getLog(InjectableInterfaceTest.class);
029:
030:            /**
031:             * @see AbstractProxoolTest
032:             */
033:            public InjectableInterfaceTest(String alias) {
034:                super (alias);
035:            }
036:
037:            /**
038:             * Get a connection and cast it into the appropriate interface
039:             */
040:            public void testInjectableConnectionInterface() throws Exception {
041:                String alias = "injectableConnectionInterface";
042:                String url = TestHelper.buildProxoolUrl(alias,
043:                        TestConstants.HYPERSONIC_DRIVER,
044:                        TestConstants.HYPERSONIC_TEST_URL);
045:                Properties info = new Properties();
046:                info.setProperty(ProxoolConstants.USER_PROPERTY,
047:                        TestConstants.HYPERSONIC_USER);
048:                info.setProperty(ProxoolConstants.PASSWORD_PROPERTY,
049:                        TestConstants.HYPERSONIC_PASSWORD);
050:                info
051:                        .setProperty(
052:                                ProxoolConstants.INJECTABLE_CONNECTION_INTERFACE_NAME_PROPERTY,
053:                                HsqlConnectionIF.class.getName());
054:                Connection c1 = DriverManager.getConnection(url, info);
055:                // Can we cast it?
056:                HsqlConnectionIF hc = (HsqlConnectionIF) c1;
057:                // TODO - need to test a vendor specific method?
058:                // Does close() still work?
059:                hc.close();
060:                assertTrue("c1.isClosed()", c1.isClosed());
061:            }
062:
063:            /**
064:             * Get a statement and cast it into the appropriate interface
065:             */
066:            public void testInjectableStatementInterface() throws Exception {
067:                String alias = "injectableStatementInterface";
068:                String url = TestHelper.buildProxoolUrl(alias,
069:                        TestConstants.HYPERSONIC_DRIVER,
070:                        TestConstants.HYPERSONIC_TEST_URL);
071:                Properties info = new Properties();
072:                info.setProperty(ProxoolConstants.USER_PROPERTY,
073:                        TestConstants.HYPERSONIC_USER);
074:                info.setProperty(ProxoolConstants.PASSWORD_PROPERTY,
075:                        TestConstants.HYPERSONIC_PASSWORD);
076:                info
077:                        .setProperty(
078:                                ProxoolConstants.INJECTABLE_STATEMENT_INTERFACE_NAME_PROPERTY,
079:                                HsqlStatementIF.class.getName());
080:                Connection c1 = DriverManager.getConnection(url, info);
081:                Statement s = c1.createStatement();
082:                // Can we cast it?
083:                HsqlStatementIF hs = (HsqlStatementIF) s;
084:                // TODO : call a vendor specific method?
085:                // hs.checkClosed();
086:                // Does close() still work?
087:                hs.close();
088:                c1.close();
089:            }
090:
091:            /**
092:             * Get a statement and cast it into the appropriate interface
093:             */
094:            public void testInjectablePreparedStatementInterface()
095:                    throws Exception {
096:                String alias = "injectablePreparedStatementInterface";
097:                String url = TestHelper.buildProxoolUrl(alias,
098:                        TestConstants.HYPERSONIC_DRIVER,
099:                        TestConstants.HYPERSONIC_TEST_URL);
100:                Properties info = new Properties();
101:                info.setProperty(ProxoolConstants.USER_PROPERTY,
102:                        TestConstants.HYPERSONIC_USER);
103:                info.setProperty(ProxoolConstants.PASSWORD_PROPERTY,
104:                        TestConstants.HYPERSONIC_PASSWORD);
105:                info
106:                        .setProperty(
107:                                ProxoolConstants.INJECTABLE_PREPARED_STATEMENT_INTERFACE_NAME_PROPERTY,
108:                                HsqlPreparedStatementIF.class.getName());
109:                Connection c1 = DriverManager.getConnection(url, info);
110:                PreparedStatement ps = c1
111:                        .prepareStatement(TestConstants.HYPERSONIC_TEST_SQL);
112:                // Can we cast it?
113:                HsqlPreparedStatementIF hps = (HsqlPreparedStatementIF) ps;
114:                // TODO : call a vendor specific method?
115:                // hps.build();
116:                // Does close() still work?
117:                hps.close();
118:                c1.close();
119:            }
120:
121:            /**
122:             * Get a statement and cast it into the appropriate interface
123:             */
124:            public void testInjectableCallableStatementInterface()
125:                    throws Exception {
126:                String alias = "injectableCallableStatementInterface";
127:                String url = TestHelper.buildProxoolUrl(alias,
128:                        TestConstants.HYPERSONIC_DRIVER,
129:                        TestConstants.HYPERSONIC_TEST_URL);
130:                Properties info = new Properties();
131:                info.setProperty(ProxoolConstants.USER_PROPERTY,
132:                        TestConstants.HYPERSONIC_USER);
133:                info.setProperty(ProxoolConstants.PASSWORD_PROPERTY,
134:                        TestConstants.HYPERSONIC_PASSWORD);
135:                info
136:                        .setProperty(
137:                                ProxoolConstants.INJECTABLE_CALLABLE_STATEMENT_INTERFACE_NAME_PROPERTY,
138:                                HsqlPreparedStatementIF.class.getName());
139:                Connection c1 = DriverManager.getConnection(url, info);
140:                CallableStatement cs = c1
141:                        .prepareCall(TestConstants.HYPERSONIC_TEST_SQL);
142:                // Can we cast it? (Note: HSQLDB uses the same class for  both Prepared and Callable statements)
143:                HsqlPreparedStatementIF hps = (HsqlPreparedStatementIF) cs;
144:                // TODO - call a vendor specific method?
145:                // Does close() still work?
146:                hps.close();
147:                c1.close();
148:            }
149:
150:        }
151:        /*
152:         Revision history:
153:         $Log: InjectableInterfaceTest.java,v $
154:         Revision 1.3  2006/01/18 14:40:06  billhorsman
155:         Unbundled Jakarta's Commons Logging.
156:
157:         Revision 1.2  2004/06/17 21:36:39  billhorsman
158:         Removed call to private methods. They're going to fail anyway.
159:
160:         Revision 1.1  2004/06/02 20:59:52  billhorsman
161:         New injectable interface tests
162:
163:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.