View Javadoc

1   /**
2    * Copyright 2005-2011 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.test;
17  
18  import org.kuali.rice.core.api.lifecycle.Lifecycle;
19  import org.kuali.rice.core.api.lifecycle.Lifecycle;
20  import org.kuali.rice.core.impl.resourceloader.SpringResourceLoader;
21  import org.kuali.rice.core.impl.resourceloader.SpringResourceLoader;
22  import org.kuali.rice.test.BaselineTestCase;
23  import org.kuali.rice.test.SQLDataLoader;
24  import org.kuali.rice.test.lifecycles.KEWXmlDataLoaderLifecycle;
25  
26  import javax.xml.namespace.QName;
27  import java.util.List;
28  
29  
30  /**
31   * Default test base for a full KNS enabled unit test.
32   * 
33   * @author Kuali Rice Team (rice.collab@kuali.org)
34   */
35  @BaselineTestCase.BaselineMode(BaselineTestCase.Mode.ROLLBACK_CLEAR_DB)
36  public abstract class KRADTestCase extends BaselineTestCase {
37  
38  	private static final String SQL_FILE = "classpath:org/kuali/rice/krad/test/DefaultSuiteTestData.sql";
39  	private static final String XML_FILE = "classpath:org/kuali/rice/krad/test/DefaultSuiteTestData.xml";
40      private static final String KRAD_MODULE_NAME = "krad";
41  
42      public KRADTestCase() {
43  		super(KRAD_MODULE_NAME);
44  	}
45  
46      @Override
47  	protected List<Lifecycle> getSuiteLifecycles() {
48  		List<Lifecycle> suiteLifecycles = super.getSuiteLifecycles();
49  		suiteLifecycles.add(new KEWXmlDataLoaderLifecycle(XML_FILE));
50  		return suiteLifecycles;
51  	}
52  
53  	@Override
54  	protected void loadSuiteTestData() throws Exception {
55  		super.loadSuiteTestData();
56          new SQLDataLoader(SQL_FILE, ";").runSql();
57  	}
58  
59  	@Override
60  	protected Lifecycle getLoadApplicationLifecycle() {
61          SpringResourceLoader springResourceLoader = new SpringResourceLoader(new QName("KRADTestResourceLoader"), "classpath:KradTestSpringBeans.xml", null);
62      	springResourceLoader.setParentSpringResourceLoader(getTestHarnessSpringResourceLoader());
63      	return springResourceLoader;
64  	}
65  }