    1   /***
    2    * @(#)UserHibernateDAOImplTest.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 junit.framework.TestCase;
    28
    29  import net.sf.hibernate.HibernateException;
    30
    31  import org.apache.commons.logging.Log;
    32  import org.apache.commons.logging.LogFactory;
    33  import org.huihoo.jfox.soaf.container.ServiceLoader;
    34
    35  /***
    36   * <p>
    37   * User Hibernate DAO implementation test case
    38   * </p>
    39   *
    40   * @author <a href="mailto:founder_chen@yahoo.com.cn">Peter Cheng </a>
    41   * @version $Revision: 1.1 $ $Date: 2005/04/27 08:32:47 $
    42   * @version Revision: 1.0
    43   */
    44
    45  public class UserHibernateDAOImplTest extends TestCase {
    46
    47  	private final Log log = LogFactory.getLog(getClass());
    48
    49  	private UserDAO userDAO;
    50
    51  	private User user = null;
    52
    53  	private ServiceLoader sl = ServiceLoader.getInstance();
    54
    55  	/***
    56  	 * @see TestCase#setUp()
    57  	 */
    58  	protected void setUp() throws Exception {
    59
    60  		if (!sl.isServiceLoaded()) {
    61  			sl.initService("jfoxsoaf-config.xml");
    62  		}
    63
    64  		userDAO = new UserHibernateDAOImpl();
    65
    66  	}
    67
    68  	public void testGetUsers() {
    69  	}
    70
    71  	/***
    72  	 * Test for method: saveProduct(Product product)
    73  	 *
    74  	 * @see ProductHibernateDAOImpl#saveProduct(Product product)
    75  	 */
    76  	public void testSaveUser() {
    77  		user = userDAO.getUser("jfoxsoaf");
    78  		if (user == null) {
    79  			User saveUser = new User();
    80  			saveUser.setUsername("jfoxsoaf");
    81  			saveUser.setPassword("jfoxsoaf password");
    82
    83  			try {
    84  				userDAO.saveUser(saveUser);
    85  			} catch (HibernateException e) {
    86  				e.printStackTrace();
    87  			}
    88  		}
    89  	}
    90
    91  	public void testGetUser() {
    92  		user = userDAO.getUser("jfoxsoaf");
    93  		log.info("UserName: " + user.getUsername());
    94  		log.info("Password: " + user.getPassword());
    95  	}
    96
    97  	public void testRemoveUser() {
    98  		try {
    99  			userDAO.removeUser("jfoxsoaf");
    100 		} catch (HibernateException e) {
    101 			e.printStackTrace();
    102 		}
    103 	}
    104
    105 }