001 /** 002 * Copyright 2005-2011 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.test; 017 018 import org.kuali.rice.core.api.lifecycle.Lifecycle; 019 import org.kuali.rice.core.api.lifecycle.Lifecycle; 020 import org.kuali.rice.core.impl.resourceloader.SpringResourceLoader; 021 import org.kuali.rice.core.impl.resourceloader.SpringResourceLoader; 022 import org.kuali.rice.test.BaselineTestCase; 023 import org.kuali.rice.test.SQLDataLoader; 024 import org.kuali.rice.test.lifecycles.KEWXmlDataLoaderLifecycle; 025 026 import javax.xml.namespace.QName; 027 import java.util.List; 028 029 030 /** 031 * Default test base for a full KNS enabled unit test. 032 * 033 * @author Kuali Rice Team (rice.collab@kuali.org) 034 */ 035 @BaselineTestCase.BaselineMode(BaselineTestCase.Mode.ROLLBACK_CLEAR_DB) 036 public abstract class KRADTestCase extends BaselineTestCase { 037 038 private static final String SQL_FILE = "classpath:org/kuali/rice/krad/test/DefaultSuiteTestData.sql"; 039 private static final String XML_FILE = "classpath:org/kuali/rice/krad/test/DefaultSuiteTestData.xml"; 040 private static final String KRAD_MODULE_NAME = "krad"; 041 042 public KRADTestCase() { 043 super(KRAD_MODULE_NAME); 044 } 045 046 @Override 047 protected List<Lifecycle> getSuiteLifecycles() { 048 List<Lifecycle> suiteLifecycles = super.getSuiteLifecycles(); 049 suiteLifecycles.add(new KEWXmlDataLoaderLifecycle(XML_FILE)); 050 return suiteLifecycles; 051 } 052 053 @Override 054 protected void loadSuiteTestData() throws Exception { 055 super.loadSuiteTestData(); 056 new SQLDataLoader(SQL_FILE, ";").runSql(); 057 } 058 059 @Override 060 protected Lifecycle getLoadApplicationLifecycle() { 061 SpringResourceLoader springResourceLoader = new SpringResourceLoader(new QName("KRADTestResourceLoader"), "classpath:KradTestSpringBeans.xml", null); 062 springResourceLoader.setParentSpringResourceLoader(getTestHarnessSpringResourceLoader()); 063 return springResourceLoader; 064 } 065 }