1 6 package org.logicalcobwebs.proxool; 7 8 import org.logicalcobwebs.logging.Log; 9 import org.logicalcobwebs.logging.LogFactory; 10 11 import javax.sql.DataSource ; 12 import javax.naming.InitialContext ; 13 import javax.naming.Context ; 14 import javax.naming.NamingException ; 15 import java.sql.SQLException ; 16 import java.sql.Connection ; 17 import java.util.Hashtable ; 18 19 26 public class DataSourceTest extends AbstractProxoolTest { 27 28 private static final Log LOG = LogFactory.getLog(DataSourceTest.class); 29 30 private static final String JNDI_NAME = "java:comp/env/jdbc/myDB"; 31 32 private Context context; 33 34 37 public DataSourceTest(String alias) { 38 super(alias); 39 } 40 41 protected void setUp() throws Exception { 42 super.setUp(); 43 44 Hashtable jndiEnvironment = new Hashtable (); 45 48 context = new InitialContext (jndiEnvironment); 49 LOG.debug("Found context " + context.getClass().getName()); 50 } 51 52 58 public void testDataSourceLookup() throws SQLException , NamingException { 59 60 DataSource ds = (DataSource ) context.lookup(JNDI_NAME); 61 Connection connection = ds.getConnection(); 62 connection.close(); 63 64 } 65 66 } 67 68 | Popular Tags |