001    /**
002     * Copyright 2005-2011 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     */
016    package org.kuali.test;
017    
018    import org.kuali.rice.core.api.lifecycle.Lifecycle;
019    import org.kuali.rice.core.framework.resourceloader.SpringResourceLoader;
020    import org.kuali.rice.test.BaselineTestCase;
021    import org.kuali.rice.test.SQLDataLoader;
022    import org.kuali.rice.test.lifecycles.KEWXmlDataLoaderLifecycle;
023    
024    import javax.xml.namespace.QName;
025    import java.util.List;
026    
027    
028    /**
029     * Default test base for a full KNS enabled unit test.
030     * 
031     * @author Kuali Rice Team (rice.collab@kuali.org)
032     */
033    @BaselineTestCase.BaselineMode(BaselineTestCase.Mode.ROLLBACK_CLEAR_DB)
034    public abstract class KRADTestCase extends BaselineTestCase {
035    
036            private static final String SQL_FILE = "classpath:org/kuali/rice/krad/test/DefaultSuiteTestData.sql";
037            private static final String XML_FILE = "classpath:org/kuali/rice/krad/test/DefaultSuiteTestData.xml";
038        private static final String KRAD_MODULE_NAME = "krad";
039    
040        public KRADTestCase() {
041                    super(KRAD_MODULE_NAME);
042            }
043    
044        @Override
045            protected List<Lifecycle> getSuiteLifecycles() {
046                    List<Lifecycle> suiteLifecycles = super.getSuiteLifecycles();
047                    suiteLifecycles.add(new KEWXmlDataLoaderLifecycle(XML_FILE));
048                    return suiteLifecycles;
049            }
050    
051            @Override
052            protected void loadSuiteTestData() throws Exception {
053                    super.loadSuiteTestData();
054            new SQLDataLoader(SQL_FILE, ";").runSql();
055            }
056    
057            @Override
058            protected Lifecycle getLoadApplicationLifecycle() {
059            SpringResourceLoader springResourceLoader = new SpringResourceLoader(new QName("KRADTestResourceLoader"), "classpath:KradTestSpringBeans.xml", null);
060            springResourceLoader.setParentSpringResourceLoader(getTestHarnessSpringResourceLoader());
061            return springResourceLoader;
062            }
063    }