001    /*
002     * Copyright 2007-2009 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.rice.test;
017    
018    import java.io.BufferedReader;
019    import java.io.FileReader;
020    
021    import org.apache.commons.lang.StringUtils;
022    
023    /**
024     * A TestCase superclass to be used internally by Rice for tests that need to
025     * load all of the Rice suite-level test data.
026     * 
027     * @author Kuali Rice Team (rice.collab@kuali.org)
028     */
029    public abstract class RiceInternalSuiteDataTestCase extends RiceTestCase {
030    
031            /**
032             * Loads the suite test data from the shared DefaultSuiteTestData.sql
033             */
034            @Override
035            protected void loadSuiteTestData() throws Exception {
036                    new SQLDataLoader(getKNSDefaultSuiteTestData(), "/").runSql();
037                    BufferedReader reader = new BufferedReader(new FileReader(getKIMDataLoadOrderFile()));
038                    String line = null;
039                    while ((line = reader.readLine()) != null) {
040                            if (!StringUtils.isBlank(line)) {
041                                    new SQLDataLoader(getKIMSqlFileBaseLocation() + "/" + line, "/").runSql();
042                            }
043                    }
044            }
045            
046            protected String getKNSDefaultSuiteTestData() {
047                return "file:" + getBaseDir() + "/../impl/src/test/config/data/DefaultSuiteTestDataKNS.sql";
048            }
049    
050            protected String getKIMDataLoadOrderFile() {
051                return getBaseDir() + "/../impl/src/test/config/data/KIMDataLoadOrder.txt";
052            }
053    
054            protected String getKIMSqlFileBaseLocation() {
055                return "file:" + getBaseDir() + "/../impl/src/test/config/data";
056            }
057    }