/* ===================================================================
 * AbstractIeatTestCase.java
 * 
 * Created Oct 3, 2005 9:54:56 PM
 * 
 * Copyright (c) 2005 Matt Magoffin (spamsqr@msqr.us)
 * 
 * This program is free software; you can redistribute it and/or 
 * modify it under the terms of the GNU General Public License as 
 * published by the Free Software Foundation; either version 2 of 
 * the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License 
 * along with this program; if not, write to the Free Software 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 
 * 02111-1307 USA
 * ===================================================================
 * $Id: AbstractIeatTestCase.java 74 2009-05-15 04:44:37Z msqr $
 * ===================================================================
 */

package magoffin.matt.ieat;

import magoffin.matt.ieat.biz.BizContext;
import magoffin.matt.ieat.biz.DomainObjectFactory;
import magoffin.matt.ieat.dao.UserDao;
import magoffin.matt.ieat.test.AppContextInitializer;
import magoffin.matt.ieat.test.TestBizContext;
import magoffin.matt.xweb.util.AppContextSupport;

/**
 * Ieat helper base class for test cases.
 * 
 * @author Matt Magoffin (spamsqr@msqr.us)
 * @version $Revision: 74 $ $Date: 2009-05-15 16:44:37 +1200 (Fri, 15 May 2009) $
 */
public abstract class AbstractIeatTestCase extends AbstractSpringEnabledTransactionalTest {

	@Override
	public boolean isPopulateProtectedVariables() {
		return true;
	}

	/**
	 * @return a TestBizContext
	 */
	protected BizContext getBizContext() {
		AppContextSupport appContextSupport = getAppContextSupport();
		return new TestBizContext(appContextSupport,getDummyUser());
	}

	/**
	 * @return the DomainObjectFactory
	 */
	protected DomainObjectFactory getDomainObjectFactory() {
		return (DomainObjectFactory)getBaseContext().getBean("domainObjectFactory");
	}
	
	/**
	 * @return the AppContextSupport
	 */
	protected AppContextSupport getAppContextSupport() {
		AppContextInitializer init = (AppContextInitializer)getBaseContext()
				.getBean("applicationInitializer",AppContextInitializer.class);
		return init.getAppContextSupport();
	}
	
	/**
	 * @return the UserDao
	 */
	protected UserDao getUserDao() {
		return (UserDao)getBaseContext().getBean("userDao");
	}
	
}
