KickJava   Java API By Example, From Geeks To Geeks.

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


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.logicalcobwebs.logging.Log;
9 import org.logicalcobwebs.logging.LogFactory;
10
11 import javax.sql.DataSource JavaDoc;
12 import javax.naming.InitialContext JavaDoc;
13 import javax.naming.Context JavaDoc;
14 import javax.naming.NamingException JavaDoc;
15 import java.sql.SQLException JavaDoc;
16 import java.sql.Connection JavaDoc;
17 import java.util.Hashtable JavaDoc;
18
19 /**
20  * Test for {@link org.logicalcobwebs.proxool.BasicDataSource}
21  * @version $Revision: 1.4 $, $Date: 2003/08/27 18:03:35 $
22  * @author bill
23  * @author $Author: billhorsman $ (current maintainer)
24  * @since Proxool 0.8
25  */

26 public class DataSourceTest extends AbstractProxoolTest {
27
28     private static final Log LOG = LogFactory.getLog(DataSourceTest.class);
29
30     private static final String JavaDoc JNDI_NAME = "java:comp/env/jdbc/myDB";
31
32     private Context JavaDoc context;
33
34     /**
35      * @see AbstractProxoolTest#AbstractProxoolTest
36      */

37     public DataSourceTest(String JavaDoc alias) {
38         super(alias);
39     }
40
41     protected void setUp() throws Exception JavaDoc {
42         super.setUp();
43
44         Hashtable JavaDoc jndiEnvironment = new Hashtable JavaDoc();
45 /*
46         jndiEnvironment.put(InitialContext.INITIAL_CONTEXT_FACTORY, org.shiftone.ooc.InitialContextFactoryImpl.class.getName());
47 */

48         context = new InitialContext JavaDoc(jndiEnvironment);
49         LOG.debug("Found context " + context.getClass().getName());
50     }
51
52     /**
53      * Test to see whether we can lookup the DataSource and get
54      * a connection from it
55      * @throws SQLException if there was a problem with the connection
56      * @throws NamingException if we couldn't find the DataSource
57      */

58     public void testDataSourceLookup() throws SQLException JavaDoc, NamingException JavaDoc {
59
60         DataSource JavaDoc ds = (DataSource JavaDoc) context.lookup(JNDI_NAME);
61         Connection JavaDoc connection = ds.getConnection();
62         connection.close();
63
64     }
65
66 }
67
68 /*
69  Revision history:
70  $Log:
71  */
Popular Tags