01: package org.logicalcobwebs.proxool;
02:
03: import org.hibernate.Session;
04: import org.hibernate.SessionFactory;
05: import org.hibernate.HibernateException;
06: import org.apache.commons.logging.Log;
07: import org.apache.commons.logging.LogFactory;
08:
09: /**
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
17: AbstractSpringIntegrationTestBase {
18:
19: private static final Log LOG = LogFactory
20: .getLog(Hibernate3SpringTest.class);
21:
22: public void testSimpleConnection() throws ProxoolException {
23: String alias = "memtest";
24:
25: SessionFactory sf = (SessionFactory) applicationContext
26: .getBean("sessionFactory");
27: Session session = null;
28: try {
29: session = sf.openSession();
30: } catch (HibernateException e) {
31: fail("Could not open a Hibernate connection from the pool "
32: + e.getMessage());
33: throw e;
34: } finally {
35: try {
36: session.close();
37: } catch (HibernateException e) {
38: fail("Could not return a Hibernate connection to the pool "
39: + e.getMessage());
40: throw e;
41: }
42: }
43: }
44: }
|