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.framework.resourceloader.SpringResourceLoader;
20  import org.kuali.rice.test.BaselineTestCase;
21  import org.kuali.rice.test.SQLDataLoader;
22  import org.kuali.rice.test.lifecycles.KEWXmlDataLoaderLifecycle;
23  
24  import javax.xml.namespace.QName;
25  import java.util.List;
26  
27  
28  /**
29   * Default test base for a full KNS enabled unit test.
30   * 
31   * @author Kuali Rice Team (rice.collab@kuali.org)
32   */
33  @BaselineTestCase.BaselineMode(BaselineTestCase.Mode.ROLLBACK_CLEAR_DB)
34  public abstract class KRADTestCase extends BaselineTestCase {
35  
36  	private static final String SQL_FILE = "classpath:org/kuali/rice/krad/test/DefaultSuiteTestData.sql";
37  	private static final String XML_FILE = "classpath:org/kuali/rice/krad/test/DefaultSuiteTestData.xml";
38      private static final String KRAD_MODULE_NAME = "krad";
39  
40      public KRADTestCase() {
41  		super(KRAD_MODULE_NAME);
42  	}
43  
44      @Override
45  	protected List<Lifecycle> getSuiteLifecycles() {
46  		List<Lifecycle> suiteLifecycles = super.getSuiteLifecycles();
47  		suiteLifecycles.add(new KEWXmlDataLoaderLifecycle(XML_FILE));
48  		return suiteLifecycles;
49  	}
50  
51  	@Override
52  	protected void loadSuiteTestData() throws Exception {
53  		super.loadSuiteTestData();
54          new SQLDataLoader(SQL_FILE, ";").runSql();
55  	}
56  
57  	@Override
58  	protected Lifecycle getLoadApplicationLifecycle() {
59          SpringResourceLoader springResourceLoader = new SpringResourceLoader(new QName("KRADTestResourceLoader"), "classpath:KradTestSpringBeans.xml", null);
60      	springResourceLoader.setParentSpringResourceLoader(getTestHarnessSpringResourceLoader());
61      	return springResourceLoader;
62  	}
63  }