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