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.rice.krms.test;
17  
18  import org.junit.Before;
19  import org.kuali.rice.core.api.lifecycle.Lifecycle;
20  import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
21  import org.kuali.rice.core.framework.resourceloader.SpringResourceLoader;
22  import org.kuali.rice.core.impl.cache.DistributedCacheManagerDecorator;
23  import org.kuali.rice.krms.api.KrmsConstants;
24  import org.kuali.rice.test.BaselineTestCase;
25  import org.kuali.rice.test.BaselineTestCase.BaselineMode;
26  import org.kuali.rice.test.BaselineTestCase.Mode;
27  
28  import javax.xml.namespace.QName;
29  import java.util.ArrayList;
30  import java.util.List;
31  
32  /**
33   * This is test base that should be used for all KRMS integration tests.
34   *
35   * @author Kuali Rice Team (rice.collab@kuali.org)
36   */
37  @BaselineMode(Mode.ROLLBACK_CLEAR_DB)
38  public abstract class KRMSTestCase extends BaselineTestCase {
39  
40  	private static final String KRMS_MODULE_NAME = "krms";
41  	
42  	private SpringResourceLoader krmsTestResourceLoader;
43  	
44  	public KRMSTestCase() {
45  		super(KRMS_MODULE_NAME);
46  	}
47  
48  	@Override
49  	protected List<Lifecycle> getSuiteLifecycles() {
50  		List<Lifecycle> suiteLifecycles = super.getSuiteLifecycles();
51  		return suiteLifecycles;
52  	}
53  	
54  	@Override
55  	protected void loadSuiteTestData() throws Exception {
56  		super.loadSuiteTestData();
57  	}
58  	
59  	
60  	
61  	@Override
62  	protected Lifecycle getLoadApplicationLifecycle() {
63  	    if (krmsTestResourceLoader == null) {
64  	        krmsTestResourceLoader = new SpringResourceLoader(new QName("KRMSTestHarnessApplicationResourceLoader"), "classpath:KRMSTestHarnessSpringBeans.xml", null);
65  	        krmsTestResourceLoader.setParentSpringResourceLoader(getTestHarnessSpringResourceLoader());
66  	        getTestHarnessSpringResourceLoader().addResourceLoader(krmsTestResourceLoader);
67  	    }
68      	return krmsTestResourceLoader;
69  	}
70  
71  	
72  	protected List<String> getPerTestTablesNotToClear() {
73  		List<String> tablesNotToClear = new ArrayList<String>();
74  
75          tablesNotToClear.addAll(super.getPerTestTablesNotToClear());
76          tablesNotToClear.add("KRIM_.*");
77  		tablesNotToClear.add("KRNS_.*");
78  		tablesNotToClear.add("KREW_.*");
79  		tablesNotToClear.add("KREN_.*");
80          tablesNotToClear.add("KRCR_.*");
81  
82  		return tablesNotToClear;
83  	}
84  
85      protected List<String> getPerTestTablesToClear() {
86          List<String> tablesToClear = new ArrayList<String>();
87  
88          tablesToClear.addAll(super.getPerTestTablesToClear());
89          tablesToClear.add("KRMS_.*");
90  
91          return tablesToClear;
92      }
93  
94      /**
95       * @see org.kuali.rice.test.RiceTestCase#getModuleName()
96       */
97  	@Override
98  	protected String getModuleName() {
99  		return KRMS_MODULE_NAME;
100 	}
101 }