001/**
002 * Copyright 2005-2014 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.krms.test;
017
018import org.junit.Before;
019import org.junit.Test;
020import org.junit.runner.RunWith;
021import org.kuali.rice.core.api.lifecycle.Lifecycle;
022import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
023import org.kuali.rice.core.framework.resourceloader.SpringResourceLoader;
024import org.kuali.rice.core.impl.cache.DistributedCacheManagerDecorator;
025import org.kuali.rice.krms.api.KrmsConstants;
026import org.kuali.rice.test.BaselineTestCase;
027import org.kuali.rice.test.BaselineTestCase.BaselineMode;
028import org.kuali.rice.test.BaselineTestCase.Mode;
029import org.kuali.rice.test.runners.BootstrapTest;
030import org.kuali.rice.test.runners.LoadTimeWeavableTestRunner;
031
032import javax.xml.namespace.QName;
033import java.util.ArrayList;
034import java.util.List;
035
036/**
037 * This is test base that should be used for all KRMS integration tests.
038 *
039 * @author Kuali Rice Team (rice.collab@kuali.org)
040 */
041@BaselineMode(Mode.ROLLBACK_CLEAR_DB)
042@RunWith(LoadTimeWeavableTestRunner.class)
043@BootstrapTest(KRMSTestCase.BootstrapTest.class)
044public abstract class KRMSTestCase extends BaselineTestCase {
045
046        private static final String KRMS_MODULE_NAME = "krms";
047        
048        private SpringResourceLoader krmsTestResourceLoader;
049        
050        public KRMSTestCase() {
051                super(KRMS_MODULE_NAME);
052        }
053
054        @Override
055        protected List<Lifecycle> getSuiteLifecycles() {
056                List<Lifecycle> suiteLifecycles = super.getSuiteLifecycles();
057                return suiteLifecycles;
058        }
059        
060        @Override
061        protected void loadSuiteTestData() throws Exception {
062                super.loadSuiteTestData();
063        }
064        
065        
066        
067        @Override
068        protected Lifecycle getLoadApplicationLifecycle() {
069            if (krmsTestResourceLoader == null) {
070                krmsTestResourceLoader = new SpringResourceLoader(new QName("KRMSTestHarnessApplicationResourceLoader"), "classpath:KRMSTestHarnessSpringBeans.xml", null);
071                krmsTestResourceLoader.setParentSpringResourceLoader(getTestHarnessSpringResourceLoader());
072                getTestHarnessSpringResourceLoader().addResourceLoader(krmsTestResourceLoader);
073            }
074        return krmsTestResourceLoader;
075        }
076
077        @Override
078        protected List<String> getPerTestTablesNotToClear() {
079                List<String> tablesNotToClear = new ArrayList<String>();
080
081        tablesNotToClear.addAll(super.getPerTestTablesNotToClear());
082        tablesNotToClear.add("KRIM_.*");
083                tablesNotToClear.add("KRNS_.*");
084                tablesNotToClear.add("KREW_.*");
085                tablesNotToClear.add("KREN_.*");
086        tablesNotToClear.add("KRCR_.*");
087
088                return tablesNotToClear;
089        }
090
091    protected List<String> getPerTestTablesToClear() {
092        List<String> tablesToClear = new ArrayList<String>();
093
094        tablesToClear.addAll(super.getPerTestTablesToClear());
095        tablesToClear.add("KRMS_.*");
096
097        return tablesToClear;
098    }
099
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}