Clover Coverage Report - KS Admin 1.1.0-M10
Coverage timestamp: Wed Dec 31 1969 19:00:00 EST
../../../../../img/srcFileCovDistChart0.png 0% of files have more coverage
23   96   9   4.6
8   67   0.39   5
5     1.8  
1    
 
  BaseCase       Line # 29 23 0% 9 36 0% 0.0
 
No Tests
 
1    package org.kuali.student.core.test;
2   
3    import java.util.Map;
4   
5    import org.junit.After;
6    import org.junit.AfterClass;
7    import org.junit.Assert;
8    import org.junit.Before;
9    import org.junit.BeforeClass;
10    import org.kuali.rice.core.config.Config;
11    import org.kuali.rice.core.config.ConfigContext;
12    import org.kuali.rice.core.resourceloader.GlobalResourceLoader;
13    import org.kuali.rice.core.resourceloader.ResourceLoader;
14    import org.kuali.rice.core.web.jetty.JettyServer;
15    import org.kuali.rice.test.TransactionalLifecycle;
16    import org.mortbay.jetty.webapp.WebAppClassLoader;
17   
18    /**
19    * A base test class which adds the following capabilities to the test harness:
20    *
21    * <li>
22    * <ol>Automatically starts an embedded Jetty server which loads the application.</ol>
23    * <ol>Starts a transaction before the test begins and rolls the transaction back after
24    * the test completes so that nothing is written to the database.</ol>
25    * </li>
26    *
27    * @author Eric Westfall
28    */
 
29    public class BaseCase extends Assert {
30   
31    private static final int DEFAULT_PORT = 8090;
32    private static final String CONTEXT_NAME = "/ks-test-dev";
33    private static final String WEBAPP_ROOT = "/src/main/webapp";
34   
35    private static JettyServer server;
36   
37    private TransactionalLifecycle transactionalLifecycle;
38   
 
39  0 toggle @Before
40    public void setUp() throws Exception {
41  0 transactionalLifecycle = new TransactionalLifecycle();
42  0 transactionalLifecycle.start();
43    }
44   
 
45  0 toggle @After
46    public void tearDown() throws Exception {
47  0 try {
48  0 if (transactionalLifecycle != null) {
49  0 transactionalLifecycle.stop();
50    }
51    } finally {
52  0 transactionalLifecycle = null;
53    }
54    }
55   
 
56  0 toggle @BeforeClass
57    public static void startJettyServer() throws Exception {
58  0 System.setProperty("kew.bootstrap.spring.file", "SpringBeans.xml");
59   
60  0 BaseCase.server = new JettyServer(DEFAULT_PORT, CONTEXT_NAME, WEBAPP_ROOT);
61  0 server.setFailOnContextFailure(true);
62  0 server.setTestMode(true);
63  0 server.start();
64    // establish the GlobalResourceLoader and ConfigContext for the classloader of the test harness
65  0 addWebappsToContext();
66    }
67   
68    /**
69    * Adds all ResourceLoaders registered to WebAppClassLoaders to the GlobalResourceLoader.
70    * Overrides the current context config with the Config registered to the (last) WebAppClassLoader
71    */
 
72  0 toggle public static void addWebappsToContext() {
73  0 for (Map.Entry<ClassLoader, Config> configEntry : ConfigContext.getConfigs()) {
74  0 if (configEntry.getKey() instanceof WebAppClassLoader) {
75  0 ResourceLoader rl = GlobalResourceLoader.getResourceLoader(configEntry.getKey());
76  0 if (rl == null) {
77  0 Assert.fail("didn't find resource loader for workflow test harness web app");
78    }
79  0 ConfigContext.overrideConfig(Thread.currentThread().getContextClassLoader(), configEntry.getValue());
80  0 GlobalResourceLoader.addResourceLoader(rl);
81    }
82    }
83    }
84   
 
85  0 toggle @AfterClass
86    public static void stopJettyServer() throws Exception {
87  0 try {
88  0 if (server != null) {
89  0 server.stop();
90    }
91    } finally {
92  0 server = null;
93    }
94    }
95   
96    }