1   /***
2    * @(#)ProductHibernateDAOImplTest.java
3    * 
4    * JFoxSOAF, Service-Oriented Application Framework
5    * 
6    * Copyright(c) JFoxSOAF Team
7    * 
8    * Licensed under the GNU LGPL, Version 2.1 (the "License"); 
9    * you may not use this file except in compliance with the License. 
10   * You may obtain a copy of the License at  
11   * 
12   * http://www.gnu.org/copyleft/lesser.html
13   * 
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS, 
16   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
17   * See the License for the specific language governing permissions and 
18   * limitations under the License. 
19   * 
20   * For more information, please visit:
21   * http://www.jfox.cn/confluence/display/JFoxSOAF/Home
22   * http://www.huihoo.org/jfox/jfoxsoaf
23   */
24  
25  package org.huihoo.jfox.soaf.services.dao;
26  
27  import java.util.List;
28  
29  import junit.framework.TestCase;
30  
31  import org.huihoo.jfox.soaf.container.ServiceLoader;
32  
33  /***
34   * JUnit test case for the
35   * {@link org.huihoo.jfox.soaf.services.dao.ProductHibernateDAOImpl).
36   * 
37   * @author <a href="mailto:founder_chen@yahoo.com.cn">Peter Cheng </a>
38   * @version $Revision: 1.1 $ $Date: 2005/04/27 08:32:47 $
39   * @version Revision: 1.0
40   */
41  
42  public class ProductHibernateDAOImplTest extends TestCase {
43  
44      private ProductDAO productDAO;
45  
46      private ServiceLoader sl = ServiceLoader.getInstance();
47  
48      /***
49       * @see TestCase#setUp()
50       */
51      protected void setUp() throws Exception {
52  
53          if (!sl.isServiceLoaded()) {            
54              sl.initService("jfoxsoaf-config.xml");
55          }
56          productDAO = new ProductHibernateDAOImpl();
57      }
58  
59      /***
60       * @see TestCase#tearDown()
61       */
62      protected void tearDown() throws Exception {
63          super.tearDown();        
64      }
65  
66      /***
67       * Test for method: getProduct(String productId)
68       * 
69       * @see ProductHibernateDAOImpl#getProduct(String productId)
70       */
71      public void testGetProduct() {
72          Product product = new Product();
73          product.setId("10002");        
74          product.setName("cd");        
75          productDAO.saveProduct(product);
76          Product productResult = productDAO.getProduct("10002");
77          assertEquals(productResult.getName(), "cd");
78      }
79  
80      /***
81       * Test for method: getProductList()
82       * 
83       * @see ProductHibernateDAOImpl#getProductList()
84       */
85      public void testGetProductList() {
86          List productList = productDAO.getProductList();        
87          boolean listSize = false;
88          if ( productList.size() > 0 ) {
89              listSize = true;
90          }
91          assertTrue(listSize);
92      }
93  
94      /***
95       * Test for method: saveProduct(Product product)
96       * 
97       * @see ProductHibernateDAOImpl#saveProduct(Product product)
98       */
99      public void testSaveProduct() {
100         Product product = new Product();
101         product.setId("10001");        
102         product.setName("book");        
103         productDAO.saveProduct(product);       
104     }
105 
106     /***
107      * Test for method: removeProduct(String productId)
108      * 
109      * @see ProductHibernateDAOImpl#removeProduct(String productId)
110      */
111     public void testRemoveProduct() {        
112         //productDAO.removeProduct("10001");       
113     }
114 
115 }