All pastes #747599 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-10-24 05:13 UTC
rendered paste body
/**
 * $Id: $
 * redax-cms
 * Copyright (c) 2007 ScanPlus GmbH, Ulm, Germany
 */
package com.scanplus.redax.data.dao;

import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;

import com.scanplus.redax.TestConstants;

/**
 * Convenience test case for all DAOs (except ImageDao) that
 * need transactional support.
 * @author Igor Stroh <i.stroh@scan-plus.de>
 *
 */
public class BaseDaoTestCase
extends AbstractTransactionalDataSourceSpringContextTests
{

    private MagazineDao magazineDao;
    private UserDao userDao;
    private ContentDao contentDao;
    private SubmissionResultDao submissionResultDao;
    private ArticleDao articleDao;
    private CommentDao commentDao;
    private SessionFactory hibernateFactory;
    private HibernateTemplate hibernateTemplate;
    
    @Override
    protected String[] getConfigLocations()
    {
        return TestConstants.TEST_CONFIG_LOCATIONS;
    }    
    
    @Override
    protected void onSetUp()
    throws Exception
    {
        super.onSetUp();
        hibernateTemplate = new HibernateTemplate(hibernateFactory);
    }
    
    public BaseDaoTestCase()
    {
        super();
        setAutowireMode(AUTOWIRE_BY_NAME);
    }

    /**
     * @return the magazineDao
     */
    public MagazineDao getMagazineDao()
    {
        return magazineDao;
    }

    /**
     * @param magazineDao the magazineDao to set
     */
    public void setMagazineDao(MagazineDao magazineDao)
    {
        this.magazineDao = magazineDao;
    }
    
    /**
     * @return the userDao
     */
    public UserDao getUserDao()
    {
        return userDao;
    }

    /**
     * @param userDao the userDao to set
     */
    public void setUserDao(UserDao userDao)
    {
        this.userDao = userDao;
    }
    
    /**
     * @return the hibernateFactory
     */
    public SessionFactory getHibernateFactory()
    {
        return hibernateFactory;
    }
    
    /**
     * @param hibernateFactory the hibernateFactory to set
     */
    public void setHibernateFactory(SessionFactory hibernateFactory)
    {
        this.hibernateFactory = hibernateFactory;
    }
    
    /**
     * @return the hibernateTemplate
     */
    public HibernateTemplate getHibernateTemplate()
    {
        return hibernateTemplate;
    }
    
    /**
     * @return the contentDao
     */
    public ContentDao getContentDao()
    {
        return contentDao;
    }

    /**
     * @param contentDao the contentDao to set
     */
    public void setContentDao(ContentDao contentDao)
    {
        this.contentDao = contentDao;
    }

    /**
     * @return the submissionResultDao
     */
    public SubmissionResultDao getSubmissionResultDao()
    {
        return submissionResultDao;
    }
    
    /**
     * @param submissionResultDao the submissionResultDao to set
     */
    public void setSubmissionResultDao(SubmissionResultDao submissionResultDao)
    {
        this.submissionResultDao = submissionResultDao;
    }
    
    /**
     * @return the articleDao
     */
    public ArticleDao getArticleDao()
    {
        return articleDao;
    }
    
    /**
     * @param articleDao the articleDao to set
     */
    public void setArticleDao(ArticleDao articleDao)
    {
        this.articleDao = articleDao;
    }
    
    /**
     * @return the commentDao
     */
    public CommentDao getCommentDao()
    {
        return commentDao;
    }

    
    /**
     * @param commentDao the commentDao to set
     */
    public void setCommentDao(CommentDao commentDao)
    {
        this.commentDao = commentDao;
    }
    
    public void flushSession()
    {
        getHibernateTemplate().getSessionFactory().getCurrentSession().flush();
    }
    
}