KickJava   Java API By Example, From Geeks To Geeks.

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


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.Connection JavaDoc;
12 import java.sql.DatabaseMetaData JavaDoc;
13 import java.sql.DriverManager JavaDoc;
14 import java.util.Properties JavaDoc;
15
16 /**
17  * Test whether ProxyDatabaseMetaData works
18  *
19  * @version $Revision: 1.6 $, $Date: 2006/01/18 14:40:06 $
20  * @author bill
21  * @author $Author: billhorsman $ (current maintainer)
22  * @since Proxool 0.8
23  */

24 public class ProxyDatabaseMetaDataTest extends AbstractProxoolTest {
25
26     private static final Log LOG = LogFactory.getLog(ProxyDatabaseMetaDataTest.class);
27
28     public ProxyDatabaseMetaDataTest(String JavaDoc alias) {
29         super(alias);
30     }
31
32     /**
33      * Test whether we can get the Proxool connection back from the
34      * DatabaseMetaData object (rather than the delegate connection)
35      */

36     public void testGetConnection() throws Exception JavaDoc {
37
38         String JavaDoc testName = "getConnection";
39         String JavaDoc alias = testName;
40
41         // Register pool
42
String JavaDoc url = TestHelper.buildProxoolUrl(alias,
43                 TestConstants.HYPERSONIC_DRIVER,
44                 TestConstants.HYPERSONIC_TEST_URL);
45         Properties JavaDoc info = new Properties JavaDoc();
46         info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER);
47         info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD);
48         ProxoolFacade.registerConnectionPool(url, info);
49
50         Connection JavaDoc connection = DriverManager.getConnection(url);
51         DatabaseMetaData JavaDoc dmd = connection.getMetaData();
52         Connection JavaDoc retrievedConnection = dmd.getConnection();
53
54         assertEquals("Retrieved connection not the same", connection, retrievedConnection);
55         assertEquals("Retrieved connection not the same", connection.getClass(), retrievedConnection.getClass());
56
57         connection.close();
58
59     }
60
61 }
62
63
64 /*
65  Revision history:
66  $Log: ProxyDatabaseMetaDataTest.java,v $
67  Revision 1.6 2006/01/18 14:40:06 billhorsman
68  Unbundled Jakarta's Commons Logging.
69
70  Revision 1.5 2003/03/04 10:24:40 billhorsman
71  removed try blocks around each test
72
73  Revision 1.4 2003/03/03 17:09:05 billhorsman
74  all tests now extend AbstractProxoolTest
75
76  Revision 1.3 2003/03/03 11:12:05 billhorsman
77  fixed licence
78
79  Revision 1.2 2003/03/01 15:27:24 billhorsman
80  checkstyle
81
82  Revision 1.1 2003/02/27 18:01:48 billhorsman
83  completely rethought the test structure. it's now
84  more obvious. no new tests yet though.
85
86  */
Popular Tags