| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| RiceInternalSuiteDataTestCase |
|
| 2.0;2 |
| 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.test; | |
| 17 | ||
| 18 | import org.apache.commons.lang.StringUtils; | |
| 19 | import org.springframework.core.io.DefaultResourceLoader; | |
| 20 | ||
| 21 | import java.io.BufferedReader; | |
| 22 | import java.io.InputStreamReader; | |
| 23 | ||
| 24 | /** | |
| 25 | * A TestCase superclass to be used internally by Rice for tests that need to | |
| 26 | * load all of the Rice suite-level test data. | |
| 27 | * | |
| 28 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
| 29 | */ | |
| 30 | 0 | public abstract class RiceInternalSuiteDataTestCase extends RiceTestCase { |
| 31 | private static final String HASH_PREFIX = "#"; | |
| 32 | private static final String SLASH_PREFIX = "//"; | |
| 33 | ||
| 34 | /** | |
| 35 | * Loads the suite test data from the shared DefaultSuiteTestData.sql | |
| 36 | */ | |
| 37 | @Override | |
| 38 | protected void loadSuiteTestData() throws Exception { | |
| 39 | 0 | new SQLDataLoader(getKRADDefaultSuiteTestData(), "/").runSql(); |
| 40 | ||
| 41 | //ClassPathResource cpr = new ClassPathResource(getKIMDataLoadOrderFile()); | |
| 42 | 0 | DefaultResourceLoader resourceLoader = new DefaultResourceLoader(); |
| 43 | //BufferedReader reader = new BufferedReader(new FileReader(cpr.getFile())); | |
| 44 | //BufferedReader reader = new BufferedReader(new FileReader(cpr.getFile())); | |
| 45 | 0 | BufferedReader reader = new BufferedReader(new InputStreamReader(resourceLoader.getResource(getKIMDataLoadOrderFile()).getInputStream())); |
| 46 | 0 | String line = null; |
| 47 | 0 | while ((line = reader.readLine()) != null) { |
| 48 | 0 | if (!StringUtils.isBlank(line) && !line.startsWith(HASH_PREFIX) && !line.startsWith(SLASH_PREFIX)) { |
| 49 | 0 | new SQLDataLoader(getKIMSqlFileBaseLocation() + "/" + line, "/").runSql(); |
| 50 | } | |
| 51 | } | |
| 52 | 0 | } |
| 53 | ||
| 54 | protected String getKRADDefaultSuiteTestData() { | |
| 55 | //return "file:" + getBaseDir() + "/../src/test/config/data/DefaultSuiteTestDataKRAD.sql"; | |
| 56 | 0 | return "classpath:/config/data/DefaultSuiteTestDataKRAD.sql"; |
| 57 | } | |
| 58 | ||
| 59 | protected String getKIMDataLoadOrderFile() { | |
| 60 | 0 | return "classpath:/config/data/KIMDataLoadOrder.txt"; |
| 61 | } | |
| 62 | ||
| 63 | protected String getKIMSqlFileBaseLocation() { | |
| 64 | 0 | return "classpath:/config/data"; |
| 65 | } | |
| 66 | } |