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 周銳 閱讀(313) 評論(0)  編輯  收藏 所屬分類: JunitSpring
          主站蜘蛛池模板: 莱西市| 遂宁市| 甘泉县| 宾阳县| 西宁市| 彰化市| 佛山市| 手机| 古交市| 娄底市| 普安县| 玛多县| 鹿泉市| 阿鲁科尔沁旗| 大邑县| 云南省| 台东县| 孙吴县| 华蓥市| 扶绥县| 咸宁市| 拜泉县| 黑龙江省| 洮南市| 同仁县| 麻城市| 章丘市| 灵寿县| 灌阳县| 绥滨县| 太白县| 江都市| 双柏县| 连城县| 会泽县| 玉龙| 葫芦岛市| 曲阜市| 简阳市| 贵南县| 静安区|