1   /***
2    * JFoxSOAF, Service-Oriented Application Framework
3    * 
4    * Copyright (C) www.huihoo.org
5    * 
6    * Distributable under GNU LGPL For more information, please visit:
7    * http://www.huihoo.org/jfox/jfoxsoaf
8    */
9   
10  package org.huihoo.jfox.soaf.services.persistence;
11  
12  import junit.framework.TestCase;
13  
14  import net.sf.hibernate.HibernateException;
15  
16  import org.huihoo.jfox.soaf.container.ServiceFactory;
17  import org.huihoo.jfox.soaf.services.logging.LoggingService;
18  
19  /***
20   * JUnit test case for the
21   * {@link org.huihoo.jfox.soaf.services.persistence.HibernateService).
22   * 
23   * @author <a href="mailto:founder_chen@yahoo.com">Peter Cheng </a>
24   * @version $Revision: 1.1 $ $Date: 2004/10/19 14:06:48 $
25   * @version Revision: 1.0
26   */
27  
28  public class HibernateServiceTest extends TestCase {
29  
30      private ServiceFactory serviceFacotry = ServiceFactory.getInstance();
31  
32      private HibernateService hService = null;
33  
34      /***
35       * @see TestCase#setUp()
36       */
37      protected void setUp() throws Exception {
38          super.setUp();
39          hService = new HibernateServiceImpl((LoggingService) serviceFacotry
40                  .getService(LoggingService.class));
41      }
42  
43      /***
44       * @see TestCase#tearDown()
45       */
46      protected void tearDown() throws Exception {
47          super.tearDown();
48      }
49  
50      /***
51       * Test for Session openSession()
52       */
53      public void testOpenSession() {
54          try {
55              assertNotNull(hService.openSession());
56          } catch (HibernateException e) {
57              e.printStackTrace();
58          }
59      }
60  
61      /***
62       * Test for Configuration getConfiguration()
63       */
64      public void testGetConfiguration() {
65          try {
66              assertNotNull(hService.getConfiguration());
67          } catch (HibernateException e) {
68              e.printStackTrace();
69          }
70      }
71  
72      /***
73       * Test for SessionFactory getSessionFactory()
74       */
75      public void testGetSessionFactory() {
76          try {
77              assertNotNull(hService.getSessionFactory());
78          } catch (HibernateException e) {
79              e.printStackTrace();
80          }
81      }
82  
83  }