Clover Coverage Report - KS Web 1.1.0-SNAPSHOT (Aggregated)
Coverage timestamp: Mon Feb 14 2011 06:15:39 EST
../../../../img/srcFileCovDistChart0.png 0% of files have more coverage
26   122   14   2.6
4   73   0.54   5
10     1.4  
2    
 
  StudentStandaloneTestBase       Line # 41 23 0% 13 36 0% 0.0
  StudentStandaloneTestBase.ClearCacheLifecycle       Line # 72 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    /**
17    *
18    */
19    package org.kuali.rice.student;
20   
21    import java.io.BufferedReader;
22    import java.io.FileReader;
23    import java.util.List;
24   
25    import javax.xml.namespace.QName;
26   
27    import org.apache.commons.lang.StringUtils;
28    import org.kuali.rice.core.lifecycle.BaseLifecycle;
29    import org.kuali.rice.core.lifecycle.Lifecycle;
30    import org.kuali.rice.core.resourceloader.SpringResourceLoader;
31    import org.kuali.rice.kew.batch.KEWXmlDataLoader;
32    import org.kuali.rice.kew.exception.WorkflowRuntimeException;
33    import org.kuali.rice.kim.service.KIMServiceLocator;
34    import org.kuali.rice.test.BaselineTestCase;
35    import org.kuali.rice.test.SQLDataLoader;
36   
37    /**
38    * @author delyea
39    *
40    */
 
41    public class StudentStandaloneTestBase extends BaselineTestCase {
42   
43    private static final String MODULE_NAME = "standalone";
44   
 
45  0 toggle public StudentStandaloneTestBase() {
46  0 super(MODULE_NAME);
47    }
48   
49    /* (non-Javadoc)
50    * @see org.kuali.rice.test.RiceTestCase#getLoadApplicationLifecycle()
51    */
 
52  0 toggle @Override
53    protected Lifecycle getLoadApplicationLifecycle() {
54  0 SpringResourceLoader springResourceLoader = new SpringResourceLoader(new QName("StudentStandaloneTestResourceLoader"), "classpath:StandaloneTestSpringBeans.xml");
55  0 springResourceLoader.setParentSpringResourceLoader(getTestHarnessSpringResourceLoader());
56  0 return springResourceLoader;
57    }
58   
59    /**
60    * Override the standard per-test lifecycles to prepend ClearDatabaseLifecycle and ClearCacheLifecycle
61    * @see org.kuali.rice.test.RiceTestCase#getPerTestLifecycles()
62    */
 
63  0 toggle @Override
64    protected List<Lifecycle> getPerTestLifecycles() {
65  0 List<Lifecycle> lifecycles = super.getPerTestLifecycles();
66    // lifecycles.add(new KEWXmlDataLoaderLifecycle("file:" + getBaseDir() + "/../src/main/config/workflowXml/searchAttributes.xml"));
67    // lifecycles.add(new KEWXmlDataLoaderLifecycle("file:" + getBaseDir() + "/../src/main/config/workflowXml/documentType.xml"));
68  0 lifecycles.add(new ClearCacheLifecycle());
69  0 return lifecycles;
70    }
71   
 
72    public class ClearCacheLifecycle extends BaseLifecycle {
 
73  0 toggle public void stop() throws Exception {
74  0 KIMServiceLocator.getIdentityManagementService().flushAllCaches();
75  0 KIMServiceLocator.getRoleManagementService().flushRoleCaches();
76  0 super.stop();
77    }
78    }
79   
80    // below method to be removed when moving to Rice 1.0.1
 
81  0 toggle @Override
82    protected void loadSuiteTestData() throws Exception {
83  0 new SQLDataLoader(getKNSDefaultSuiteTestData(), "/").runSql();
84  0 BufferedReader reader = new BufferedReader(new FileReader(getKIMDataLoadOrderFile()));
85  0 String line = null;
86  0 while ((line = reader.readLine()) != null) {
87  0 if (!StringUtils.isBlank(line)) {
88  0 new SQLDataLoader(getKIMSqlFileBaseLocation() + "/" + line, "/").runSql();
89    }
90    }
91  0 new SQLDataLoader("file:" + getBaseDir() + "/../src/main/config/sql/kim.sql", ";").runSql();
92    }
93   
 
94  0 toggle protected String getKNSDefaultSuiteTestData() {
95  0 return "file:" + getBaseDir() + "/../src/test/config/data/DefaultSuiteTestDataKNS.sql";
96    }
97   
 
98  0 toggle protected String getKIMDataLoadOrderFile() {
99  0 return getBaseDir() + "/../src/test/config/data/KIMDataLoadOrder.txt";
100    }
101   
 
102  0 toggle protected String getKIMSqlFileBaseLocation() {
103  0 return "file:" + getBaseDir() + "/../src/test/config/data";
104    }
105   
 
106  0 toggle protected void loadXmlFile(String fileName) {
107  0 try {
108  0 KEWXmlDataLoader.loadXmlClassLoaderResource(getClass(), fileName);
109    } catch (Exception e) {
110  0 throw new WorkflowRuntimeException(e);
111    }
112    }
113   
 
114  0 toggle protected void loadXmlFileFromFileSystem(String fileName) {
115  0 try {
116  0 KEWXmlDataLoader.loadXmlFile(fileName);
117    } catch (Exception e) {
118  0 throw new WorkflowRuntimeException(e);
119    }
120    }
121   
122    }