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

          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 桐城市| 黄骅市| 云梦县| 华阴市| 长白| 遂川县| 博野县| 菏泽市| 崇文区| 康马县| 康平县| 平江县| 雷山县| 特克斯县| 龙海市| 固镇县| 孝感市| 宁国市| 濉溪县| 昌乐县| 合肥市| 精河县| 攀枝花市| 大理市| 宜阳县| 呼伦贝尔市| 义马市| 乌兰浩特市| 隆德县| 巴塘县| 镶黄旗| 南木林县| 汶上县| 乌鲁木齐县| 溆浦县| 六盘水市| 林口县| 民和| 南城县| 和平县| 新龙县|