posts - 431,  comments - 344,  trackbacks - 0

          package com.founder.common;

          import Java.text.SimpleDateFormat;
          import Java.util.TimeZone;

          import org.hibernate.SessionFactory;
          import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;

          /**
           * This class is the base class of all the tests,
           * we can use the dependency injection functionality of spring in all the tests,
           * and the default transaction mode is rollback, so we don't need to write special code to restore data after calling some methods affected database data.
           *
           * @author Rui Zhou, Copyright © 2008 foundersoftware. All Rights Reserved.
           * @version 1.00, 2008-03-22 15:46
           */
          public abstract class SpringTestCaseBase extends AbstractTransactionalDataSourceSpringContextTests {
           
           protected SimpleDateFormat sdf;
           
           public SpringTestCaseBase() {
            // query the protected variables to implement denpendency injection automatically,
            // so we don't need to write settor and gettor methods anymore.
            this.setPopulateProtectedVariables(true);
            
            sdf = new SimpleDateFormat("yyyy-MM-dd");
            sdf.setTimeZone(TimeZone.getDefault());
           }
           
           protected String[] getConfigLocations() {
            return new String[] { "file:WebRoot/WEB-INF/applicationContext*.xml"};
              }
           
           protected void flushSession(){
            SessionFactory sessionFactory = (SessionFactory)applicationContext.getBean("sessionFactory");  
                  sessionFactory.getCurrentSession().flush();
              }
          }

          posted on 2008-04-21 13:15 周銳 閱讀(303) 評論(0)  編輯  收藏 所屬分類: JunitSpring
          主站蜘蛛池模板: 抚远县| 峨边| 二连浩特市| 安国市| 汉川市| 黑龙江省| 张家口市| 新兴县| 三穗县| 三门县| 玉屏| 宜兴市| 广饶县| 政和县| 慈利县| 祥云县| 乌什县| 平利县| 文安县| 沙雅县| 镇安县| 凭祥市| 鹤庆县| 安陆市| 邹平县| 颍上县| 平定县| 聂荣县| 淮南市| 静海县| 曲水县| 岱山县| 河间市| 竹山县| 两当县| 保德县| 金山区| 盐亭县| 姚安县| 尚义县| 收藏|