1   package com.germinus.merlin.dao;
2   
3   import org.hibernate.SessionFactory;
4   import org.springframework.orm.hibernate3.HibernateTemplate;
5   
6   import com.germinus.merlin.BaseTestCase;
7   
8   /**
9    * Base class for running DAO tests.
10   * @author mraible
11   */
12  public abstract class BaseDaoTestCase extends BaseTestCase {
13  
14      /**
15       * Create a HibernateTemplate from the SessionFactory and call flush() and clear() on it.
16       * Designed to be used after "save" methods in tests: http://issues.appfuse.org/browse/APF-178.
17       */
18      protected void flush() {
19          HibernateTemplate hibernateTemplate =
20                  new HibernateTemplate((SessionFactory) applicationContext.getBean("sessionFactory"));
21          hibernateTemplate.flush();
22          hibernateTemplate.clear();
23      }
24  }
25