001 /* 002 * Copyright 2006-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 017 package org.kuali.test; 018 019 import org.kuali.rice.core.api.lifecycle.Lifecycle; 020 import org.kuali.rice.core.api.lifecycle.Lifecycle; 021 import org.kuali.rice.core.impl.resourceloader.SpringResourceLoader; 022 import org.kuali.rice.core.impl.resourceloader.SpringResourceLoader; 023 import org.kuali.rice.test.BaselineTestCase; 024 import org.kuali.rice.test.SQLDataLoader; 025 import org.kuali.rice.test.lifecycles.KEWXmlDataLoaderLifecycle; 026 027 import javax.xml.namespace.QName; 028 import java.util.List; 029 030 031 /** 032 * Default test base for a full KNS enabled unit test. 033 * 034 * @author Kuali Rice Team (rice.collab@kuali.org) 035 */ 036 @BaselineTestCase.BaselineMode(BaselineTestCase.Mode.ROLLBACK_CLEAR_DB) 037 public abstract class KRADTestCase extends BaselineTestCase { 038 039 private static final String SQL_FILE = "classpath:org/kuali/rice/krad/test/DefaultSuiteTestData.sql"; 040 private static final String XML_FILE = "classpath:org/kuali/rice/krad/test/DefaultSuiteTestData.xml"; 041 private static final String KRAD_MODULE_NAME = "krad"; 042 043 public KRADTestCase() { 044 super(KRAD_MODULE_NAME); 045 } 046 047 @Override 048 protected List<Lifecycle> getSuiteLifecycles() { 049 List<Lifecycle> suiteLifecycles = super.getSuiteLifecycles(); 050 suiteLifecycles.add(new KEWXmlDataLoaderLifecycle(XML_FILE)); 051 return suiteLifecycles; 052 } 053 054 @Override 055 protected void loadSuiteTestData() throws Exception { 056 super.loadSuiteTestData(); 057 new SQLDataLoader(SQL_FILE, ";").runSql(); 058 } 059 060 @Override 061 protected Lifecycle getLoadApplicationLifecycle() { 062 SpringResourceLoader springResourceLoader = new SpringResourceLoader(new QName("KRADTestResourceLoader"), "classpath:KradTestSpringBeans.xml", null); 063 springResourceLoader.setParentSpringResourceLoader(getTestHarnessSpringResourceLoader()); 064 return springResourceLoader; 065 } 066 }