View Javadoc

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