| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| UnitTestDataUtils |
|
| 6.0;6 | ||||
| UnitTestDataUtils$1 |
|
| 6.0;6 |
| 1 | /* | |
| 2 | * Copyright 2007-2008 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.data; | |
| 17 | ||
| 18 | import org.apache.commons.lang.StringUtils; | |
| 19 | import org.kuali.rice.test.SQLDataLoader; | |
| 20 | ||
| 21 | /** | |
| 22 | * Utilities for unit test data annotations. | |
| 23 | * | |
| 24 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
| 25 | * | |
| 26 | */ | |
| 27 | 0 | public class UnitTestDataUtils { |
| 28 | ||
| 29 | public static void executeDataLoader(UnitTestData[] data) throws Exception { | |
| 30 | 0 | for (UnitTestData d: data) { |
| 31 | 0 | executeDataLoader(d); |
| 32 | } | |
| 33 | 0 | } |
| 34 | ||
| 35 | public static void executeDataLoader(UnitTestData data) throws Exception { | |
| 36 | SQLDataLoader sqlDataLoader; | |
| 37 | 0 | for (UnitTestData.Type type : data.order()) { |
| 38 | 0 | switch (type) { |
| 39 | case SQL_FILES : | |
| 40 | 0 | for (UnitTestFile file : data.sqlFiles()) { |
| 41 | 0 | sqlDataLoader = new SQLDataLoader(file.filename(), file.delimiter()); |
| 42 | 0 | sqlDataLoader.runSql(); |
| 43 | } | |
| 44 | 0 | break; |
| 45 | case SQL_STATEMENTS : | |
| 46 | 0 | for (UnitTestSql statement : data.sqlStatements()) { |
| 47 | 0 | sqlDataLoader = new SQLDataLoader(statement.value()); |
| 48 | 0 | sqlDataLoader.runSql(); |
| 49 | } | |
| 50 | 0 | break; |
| 51 | 0 | default: break; |
| 52 | } | |
| 53 | } | |
| 54 | ||
| 55 | 0 | if (!StringUtils.isEmpty(data.filename())) { |
| 56 | 0 | if (!StringUtils.isEmpty(data.value())) |
| 57 | 0 | throw new RuntimeException("UnitTestDataArtifact may not specify both SQL file and content"); |
| 58 | 0 | sqlDataLoader = new SQLDataLoader(data.filename(), data.delimiter()); |
| 59 | 0 | sqlDataLoader.runSql(); |
| 60 | 0 | } else if (!StringUtils.isEmpty(data.value())) { |
| 61 | 0 | sqlDataLoader = new SQLDataLoader(data.value()); |
| 62 | 0 | sqlDataLoader.runSql(); |
| 63 | } | |
| 64 | 0 | } |
| 65 | } |