KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.logicalcobwebs.proxool;
2
3 import org.hibernate.Session;
4 import org.hibernate.SessionFactory;
5 import org.hibernate.HibernateException;
6 import org.apache.commons.logging.Log;
7 import org.apache.commons.logging.LogFactory;
8
9 /**
10  * Tests the Proxool pool configured as a datasource in Spring and tested against Hibernate 3.1.x
11  *
12  * @author Mark Eagle
13  * @author Phil Barnes
14  * @since Mar 16, 2006 @ 8:19:48 AM
15  */

16 public class Hibernate3SpringTest extends AbstractSpringIntegrationTestBase {
17
18     private static final Log LOG = LogFactory.getLog(Hibernate3SpringTest.class);
19
20     public void testSimpleConnection() throws ProxoolException {
21         String JavaDoc alias = "memtest";
22
23         SessionFactory sf = (SessionFactory) applicationContext.getBean("sessionFactory");
24         Session session = null;
25         try {
26             session = sf.openSession();
27         } catch (HibernateException e) {
28             fail("Could not open a Hibernate connection from the pool " + e.getMessage());
29             throw e;
30         } finally {
31             try {
32                 session.close();
33             } catch (HibernateException e) {
34                 fail("Could not return a Hibernate connection to the pool " + e.getMessage());
35                 throw e;
36             }
37         }
38     }
39 }
40
Popular Tags