1   /***
2    * @(#)DAOFactoryImplTest.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://sourceforge.net/projects/jfox
22   */
23  
24  package org.huihoo.jfox.soaf.services.dao;
25  
26  import junit.framework.TestCase;
27  
28  import org.apache.commons.logging.Log;
29  import org.apache.commons.logging.LogFactory;
30  
31  /***
32   * JUnit test case for the
33   * {@link org.huihoo.jfox.soaf.services.dao.DAOFactoryImpl).
34   * 
35   * @author <a href="mailto:founder_chen@yahoo.com">Peter Cheng </a>
36   * @version $Revision: 1.1 $ $Date: 2005/04/27 08:32:47 $
37   * @version Revision: 1.0
38   */
39  
40  public class DAOFactoryImplTest extends TestCase {
41  
42      private final Log logger = LogFactory.getLog(getClass());
43  
44      DAOFactoryImpl daoFactoryImpl = null;
45  
46      /***
47       * @see TestCase#setUp()
48       */
49      protected void setUp() throws Exception {
50          super.setUp();
51          daoFactoryImpl = new DAOFactoryImpl();
52      }
53  
54      /***
55       * Test for method: getDAO(Class clazz)
56       * 
57       * @see DAOFactoryImpl#getDAO(Class clazz)
58       */
59      public void testGetDAO() {
60          long startTime = System.currentTimeMillis();
61          for (int i = 0; i < 100; i++) {
62              daoFactoryImpl.getDAO(MockDAOImpl.class);
63          }
64          long endTime = System.currentTimeMillis();
65          logger.info("DAO Invoke Time " + (endTime - startTime));
66      }
67  
68      public void testGetAccountDAO() {
69          AccountDAO accountDAO = (AccountDAO) daoFactoryImpl
70                  .getDAO(AccountJdbcDAOImpl.class);
71          accountDAO.createAccount();
72      }
73  
74  }