Coverage Report - org.kuali.rice.test.lifecycles.SQLDataLoaderLifecycle
 
Classes in this File Line Coverage Branch Coverage Complexity
SQLDataLoaderLifecycle
0%
0/17
0%
0/4
1.75
 
 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.lifecycles;
 17  
 
 18  
 import org.apache.log4j.Logger;
 19  
 import org.kuali.rice.core.api.config.property.ConfigContext;
 20  
 import org.kuali.rice.core.api.lifecycle.BaseLifecycle;
 21  
 import org.kuali.rice.test.SQLDataLoader;
 22  
 
 23  
 /**
 24  
  * A lifecycle for loading SQL datasets.
 25  
  * This lifecycle will not be run (even if it is listed in the lifecycles list)
 26  
  * if the 'use.sqlDataLoaderLifecycle' configuration property is defined, and is
 27  
  * not 'true'.  If the property is omitted the lifecycle runs as normal.
 28  
  * 
 29  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 30  
  */
 31  
 public class SQLDataLoaderLifecycle extends BaseLifecycle {
 32  0
     private static final Logger LOG = Logger.getLogger(SQLDataLoaderLifecycle.class);
 33  
 
 34  
     private SQLDataLoader sqlDataLoader;
 35  
 
 36  
     private String filename;
 37  
 
 38  
     private String delimiter;
 39  
 
 40  
     public SQLDataLoaderLifecycle() {
 41  0
         this("classpath:DefaultTestData.sql", ";");
 42  0
     }
 43  
 
 44  0
     public SQLDataLoaderLifecycle(String filename, String delimiter) {
 45  0
         this.filename = filename;
 46  0
         this.delimiter = delimiter;
 47  0
     }
 48  
 
 49  
     public void start() throws Exception {
 50  0
         String useSqlDataLoaderLifecycle = ConfigContext.getCurrentContextConfig().getProperty("use.sqlDataLoaderLifecycle"); 
 51  0
         if (useSqlDataLoaderLifecycle != null && !Boolean.valueOf(useSqlDataLoaderLifecycle)) {
 52  0
             LOG.debug("Skipping SQLDataLoaderLifecycle due to property: use.sqlDataLoaderLifecycle=" + useSqlDataLoaderLifecycle);
 53  0
             return;
 54  
         }
 55  
 
 56  0
         sqlDataLoader = new SQLDataLoader(filename, delimiter);
 57  0
         sqlDataLoader.runSql();
 58  0
         super.start();
 59  0
     }
 60  
 
 61  
     public void stop() throws Exception {
 62  
         // TODO: may way to do something with the dataLoader
 63  0
         super.stop();
 64  0
     }
 65  
 }