Clover Coverage Report - KS LUM 1.2-M4-SNAPSHOT (Aggregated)
Coverage timestamp: Wed Jul 20 2011 13:25:47 EDT
../../../../img/srcFileCovDistChart0.png 43% of files have more coverage
30   127   15   3
6   81   0.5   5
10     1.5  
2    
 
  StudentStandaloneTestBase       Line # 38 27 0% 14 42 0% 0.0
  StudentStandaloneTestBase.ClearCacheLifecycle       Line # 69 3 0% 1 4 0% 0.0
 
No Tests
 
1    /**
2    * Copyright 2010 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10    * software distributed under the License is distributed on an "AS IS"
11    * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12    * or implied. See the License for the specific language governing
13    * permissions and limitations under the License.
14    */
15   
16    package org.kuali.rice.student;
17   
18    import java.io.BufferedReader;
19    import java.io.FileReader;
20    import java.util.List;
21   
22    import javax.xml.namespace.QName;
23   
24    import org.apache.commons.lang.StringUtils;
25    import org.kuali.rice.core.lifecycle.BaseLifecycle;
26    import org.kuali.rice.core.lifecycle.Lifecycle;
27    import org.kuali.rice.core.resourceloader.SpringResourceLoader;
28    import org.kuali.rice.kew.batch.KEWXmlDataLoader;
29    import org.kuali.rice.kew.exception.WorkflowRuntimeException;
30    import org.kuali.rice.kim.service.KIMServiceLocator;
31    import org.kuali.rice.test.BaselineTestCase;
32    import org.kuali.rice.test.SQLDataLoader;
33   
34    /**
35    * @author delyea
36    *
37    */
 
38    public class StudentStandaloneTestBase extends BaselineTestCase {
39   
40    private static final String MODULE_NAME = "standalone";
41   
 
42  0 toggle public StudentStandaloneTestBase() {
43  0 super(MODULE_NAME);
44    }
45   
46    /* (non-Javadoc)
47    * @see org.kuali.rice.test.RiceTestCase#getLoadApplicationLifecycle()
48    */
 
49  0 toggle @Override
50    protected Lifecycle getLoadApplicationLifecycle() {
51  0 SpringResourceLoader springResourceLoader = new SpringResourceLoader(new QName("StudentStandaloneTestResourceLoader"), "classpath:StandaloneTestSpringBeans.xml");
52  0 springResourceLoader.setParentSpringResourceLoader(getTestHarnessSpringResourceLoader());
53  0 return springResourceLoader;
54    }
55   
56    /**
57    * Override the standard per-test lifecycles to prepend ClearDatabaseLifecycle and ClearCacheLifecycle
58    * @see org.kuali.rice.test.RiceTestCase#getPerTestLifecycles()
59    */
 
60  0 toggle @Override
61    protected List<Lifecycle> getPerTestLifecycles() {
62  0 List<Lifecycle> lifecycles = super.getPerTestLifecycles();
63    // lifecycles.add(new KEWXmlDataLoaderLifecycle("file:" + getBaseDir() + "/../src/main/config/workflowXml/searchAttributes.xml"));
64    // lifecycles.add(new KEWXmlDataLoaderLifecycle("file:" + getBaseDir() + "/../src/main/config/workflowXml/documentType.xml"));
65  0 lifecycles.add(new ClearCacheLifecycle());
66  0 return lifecycles;
67    }
68   
 
69    public class ClearCacheLifecycle extends BaseLifecycle {
 
70  0 toggle public void stop() throws Exception {
71  0 KIMServiceLocator.getIdentityManagementService().flushAllCaches();
72  0 KIMServiceLocator.getRoleManagementService().flushRoleCaches();
73  0 super.stop();
74    }
75    }
76   
77    // below method to be removed when moving to Rice 1.0.1
 
78  0 toggle @Override
79    protected void loadSuiteTestData() throws Exception {
80  0 new SQLDataLoader(getKNSDefaultSuiteTestData(), "/").runSql();
81  0 BufferedReader reader = null;
82  0 try{
83  0 reader = new BufferedReader(new FileReader(getKIMDataLoadOrderFile()));
84  0 String line = null;
85  0 while ((line = reader.readLine()) != null) {
86  0 if (!StringUtils.isBlank(line)) {
87  0 new SQLDataLoader(getKIMSqlFileBaseLocation() + "/" + line, "/").runSql();
88    }
89    }
90    }finally{
91  0 if(reader!=null){
92  0 reader.close();
93    }
94    }
95   
96  0 new SQLDataLoader("file:" + getBaseDir() + "/src/main/config/sql/kim.sql", ";").runSql();
97    }
98   
 
99  0 toggle protected String getKNSDefaultSuiteTestData() {
100  0 return "file:" + getBaseDir() + "/src/test/config/data/DefaultSuiteTestDataKNS.sql";
101    }
102   
 
103  0 toggle protected String getKIMDataLoadOrderFile() {
104  0 return getBaseDir() + "/src/test/config/data/KIMDataLoadOrder.txt";
105    }
106   
 
107  0 toggle protected String getKIMSqlFileBaseLocation() {
108  0 return "file:" + getBaseDir() + "/src/test/config/data";
109    }
110   
 
111  0 toggle protected void loadXmlFile(String fileName) {
112  0 try {
113  0 KEWXmlDataLoader.loadXmlClassLoaderResource(getClass(), fileName);
114    } catch (Exception e) {
115  0 throw new WorkflowRuntimeException(e);
116    }
117    }
118   
 
119  0 toggle protected void loadXmlFileFromFileSystem(String fileName) {
120  0 try {
121  0 KEWXmlDataLoader.loadXmlFile(fileName);
122    } catch (Exception e) {
123  0 throw new WorkflowRuntimeException(e);
124    }
125    }
126   
127    }