1 6 package org.logicalcobwebs.proxool; 7 8 import org.apache.commons.logging.Log; 9 import org.apache.commons.logging.LogFactory; 10 11 import java.util.Properties ; 12 import java.sql.Connection ; 13 import java.sql.DriverManager ; 14 import java.sql.Statement ; 15 import java.sql.PreparedStatement ; 16 import java.sql.CallableStatement ; 17 18 25 public class InjectableInterfaceTest extends AbstractProxoolTest { 26 27 private static final Log LOG = LogFactory.getLog(InjectableInterfaceTest.class); 28 29 32 public InjectableInterfaceTest(String alias) { 33 super(alias); 34 } 35 36 39 public void testInjectableConnectionInterface() throws Exception { 40 String alias = "injectableConnectionInterface"; 41 String url = TestHelper.buildProxoolUrl(alias, 42 TestConstants.HYPERSONIC_DRIVER, 43 TestConstants.HYPERSONIC_TEST_URL); 44 Properties info = new Properties (); 45 info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); 46 info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); 47 info.setProperty(ProxoolConstants.INJECTABLE_CONNECTION_INTERFACE_NAME_PROPERTY, HsqlConnectionIF.class.getName()); 48 Connection c1 = DriverManager.getConnection(url, info); 49 HsqlConnectionIF hc = (HsqlConnectionIF) c1; 51 hc.close(); 54 assertTrue("c1.isClosed()", c1.isClosed()); 55 } 56 57 60 public void testInjectableStatementInterface() throws Exception { 61 String alias = "injectableStatementInterface"; 62 String url = TestHelper.buildProxoolUrl(alias, 63 TestConstants.HYPERSONIC_DRIVER, 64 TestConstants.HYPERSONIC_TEST_URL); 65 Properties info = new Properties (); 66 info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); 67 info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); 68 info.setProperty(ProxoolConstants.INJECTABLE_STATEMENT_INTERFACE_NAME_PROPERTY, HsqlStatementIF.class.getName()); 69 Connection c1 = DriverManager.getConnection(url, info); 70 Statement s = c1.createStatement(); 71 HsqlStatementIF hs = (HsqlStatementIF) s; 73 hs.close(); 77 c1.close(); 78 } 79 80 83 public void testInjectablePreparedStatementInterface() throws Exception { 84 String alias = "injectablePreparedStatementInterface"; 85 String url = TestHelper.buildProxoolUrl(alias, 86 TestConstants.HYPERSONIC_DRIVER, 87 TestConstants.HYPERSONIC_TEST_URL); 88 Properties info = new Properties (); 89 info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); 90 info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); 91 info.setProperty(ProxoolConstants.INJECTABLE_PREPARED_STATEMENT_INTERFACE_NAME_PROPERTY, HsqlPreparedStatementIF.class.getName()); 92 Connection c1 = DriverManager.getConnection(url, info); 93 PreparedStatement ps = c1.prepareStatement(TestConstants.HYPERSONIC_TEST_SQL); 94 HsqlPreparedStatementIF hps = (HsqlPreparedStatementIF) ps; 96 hps.close(); 100 c1.close(); 101 } 102 103 106 public void testInjectableCallableStatementInterface() throws Exception { 107 String alias = "injectableCallableStatementInterface"; 108 String url = TestHelper.buildProxoolUrl(alias, 109 TestConstants.HYPERSONIC_DRIVER, 110 TestConstants.HYPERSONIC_TEST_URL); 111 Properties info = new Properties (); 112 info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); 113 info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); 114 info.setProperty(ProxoolConstants.INJECTABLE_CALLABLE_STATEMENT_INTERFACE_NAME_PROPERTY, HsqlPreparedStatementIF.class.getName()); 115 Connection c1 = DriverManager.getConnection(url, info); 116 CallableStatement cs = c1.prepareCall(TestConstants.HYPERSONIC_TEST_SQL); 117 HsqlPreparedStatementIF hps = (HsqlPreparedStatementIF) cs; 119 hps.close(); 122 c1.close(); 123 } 124 125 } 126 | Popular Tags |