01: /*
02: * This software is released under a licence similar to the Apache Software Licence.
03: * See org.logicalcobwebs.proxool.package.html for details.
04: * The latest version is available at http://proxool.sourceforge.net
05: */
06: package org.logicalcobwebs.proxool;
07:
08: import org.apache.commons.logging.Log;
09: import org.apache.commons.logging.LogFactory;
10:
11: import java.sql.Connection;
12: import java.sql.DatabaseMetaData;
13: import java.sql.DriverManager;
14: import java.util.Properties;
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
27: .getLog(ProxyDatabaseMetaDataTest.class);
28:
29: public ProxyDatabaseMetaDataTest(String alias) {
30: super (alias);
31: }
32:
33: /**
34: * Test whether we can get the Proxool connection back from the
35: * DatabaseMetaData object (rather than the delegate connection)
36: */
37: public void testGetConnection() throws Exception {
38:
39: String testName = "getConnection";
40: String alias = testName;
41:
42: // Register pool
43: String url = TestHelper.buildProxoolUrl(alias,
44: TestConstants.HYPERSONIC_DRIVER,
45: TestConstants.HYPERSONIC_TEST_URL);
46: Properties info = new Properties();
47: info.setProperty(ProxoolConstants.USER_PROPERTY,
48: TestConstants.HYPERSONIC_USER);
49: info.setProperty(ProxoolConstants.PASSWORD_PROPERTY,
50: TestConstants.HYPERSONIC_PASSWORD);
51: ProxoolFacade.registerConnectionPool(url, info);
52:
53: Connection connection = DriverManager.getConnection(url);
54: DatabaseMetaData dmd = connection.getMetaData();
55: Connection retrievedConnection = dmd.getConnection();
56:
57: assertEquals("Retrieved connection not the same", connection,
58: retrievedConnection);
59: assertEquals("Retrieved connection not the same", connection
60: .getClass(), retrievedConnection.getClass());
61:
62: connection.close();
63:
64: }
65:
66: }
67:
68: /*
69: Revision history:
70: $Log: ProxyDatabaseMetaDataTest.java,v $
71: Revision 1.6 2006/01/18 14:40:06 billhorsman
72: Unbundled Jakarta's Commons Logging.
73:
74: Revision 1.5 2003/03/04 10:24:40 billhorsman
75: removed try blocks around each test
76:
77: Revision 1.4 2003/03/03 17:09:05 billhorsman
78: all tests now extend AbstractProxoolTest
79:
80: Revision 1.3 2003/03/03 11:12:05 billhorsman
81: fixed licence
82:
83: Revision 1.2 2003/03/01 15:27:24 billhorsman
84: checkstyle
85:
86: Revision 1.1 2003/02/27 18:01:48 billhorsman
87: completely rethought the test structure. it's now
88: more obvious. no new tests yet though.
89:
90: */
|