Coverage Report - org.kuali.rice.test.lifecycles.PerTestDataLoaderLifecycle
 
Classes in this File Line Coverage Branch Coverage Complexity
PerTestDataLoaderLifecycle
0%
0/17
0%
0/6
1.75
 
 1  
 /*
 2  
  * Copyright 2007 The Kuali Foundation
 3  
  * 
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in
 5  
  * compliance with the License. You may obtain a copy of the License at
 6  
  * 
 7  
  * http://www.opensource.org/licenses/ecl2.php
 8  
  * 
 9  
  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS
 10  
  * IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
 11  
  * language governing permissions and limitations under the License.
 12  
  */
 13  
 package org.kuali.rice.test.lifecycles;
 14  
 
 15  
 import java.lang.reflect.Method;
 16  
 
 17  
 import org.kuali.rice.core.api.lifecycle.Lifecycle;
 18  
 import org.kuali.rice.test.data.PerTestUnitTestData;
 19  
 import org.kuali.rice.test.data.UnitTestData;
 20  
 import org.kuali.rice.test.data.UnitTestDataUtils;
 21  
 
 22  
 /**
 23  
  * A lifecycle for loading SQL datasets based on the PerSuiteUnitTestData annotation. The individual SQL statements are
 24  
  * loaded first, followed by the statements inside the files (files are loaded sequentially in the order listed in the
 25  
  * annotation).
 26  
  * 
 27  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 28  
  */
 29  
 public class PerTestDataLoaderLifecycle implements Lifecycle {
 30  
         private boolean started;
 31  
         private Method method;
 32  
 
 33  0
         public PerTestDataLoaderLifecycle(Method method) {
 34  0
                 this.method = method;
 35  0
         }
 36  
 
 37  
         public boolean isStarted() {
 38  0
                 return started;
 39  
         }
 40  
 
 41  
         public void start() throws Exception {
 42  0
                 if (method.getDeclaringClass().isAnnotationPresent(PerTestUnitTestData.class)) {
 43  0
                         UnitTestData[] data = method.getDeclaringClass().getAnnotation(PerTestUnitTestData.class).value();
 44  0
             UnitTestDataUtils.executeDataLoader(data);
 45  
                 }
 46  0
                 if (method.isAnnotationPresent(UnitTestData.class)) {
 47  0
                         UnitTestData data = method.getAnnotation(UnitTestData.class);
 48  0
             UnitTestDataUtils.executeDataLoader(data);
 49  
                 }
 50  0
                 started = true;
 51  0
         }
 52  
 
 53  
         public void stop() throws Exception {
 54  0
             if (method.getDeclaringClass().isAnnotationPresent(PerTestUnitTestData.class)) {
 55  0
             UnitTestData[] data = method.getDeclaringClass().getAnnotation(PerTestUnitTestData.class).tearDown();
 56  0
             UnitTestDataUtils.executeDataLoader(data);
 57  
         }
 58  0
                 started = false;
 59  0
         }
 60  
 }