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 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
@author |
28 |
|
|
|
|
| 0% |
Uncovered Elements: 36 (36) |
Complexity: 9 |
Complexity Density: 0.39 |
|
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 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
39 |
0
|
@Before... |
40 |
|
public void setUp() throws Exception { |
41 |
0
|
transactionalLifecycle = new TransactionalLifecycle(); |
42 |
0
|
transactionalLifecycle.start(); |
43 |
|
} |
44 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
45 |
0
|
@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 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
56 |
0
|
@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 |
|
|
65 |
0
|
addWebappsToContext(); |
66 |
|
} |
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
72 |
0
|
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 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
85 |
0
|
@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 |
|
} |