blob: b623b2e7b547222ddf1fb11e3ec3b01659c02d41 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
package org.apache.tuscany.tomcat.integration;
import org.apache.catalina.core.StandardContext;
import org.apache.catalina.core.StandardWrapper;
import org.apache.catalina.core.StandardHost;
import org.apache.catalina.startup.ContextConfig;
import org.apache.catalina.Valve;
import org.apache.catalina.Wrapper;
import org.apache.tuscany.tomcat.TuscanyValve;
import org.apache.tuscany.tomcat.TuscanyHost;
import java.io.File;
/**
* @version $Rev$ $Date$
*/
public class TomcatStandaloneTestCase extends AbstractTomcatTest {
protected File app2;
public void testRuntimeIntegration() throws Exception {
StandardContext ctx = new StandardContext();
// caution: this sets the parent of the webapp loader to the test classloader so it can find TestServlet
// anything that relies on the TCCL may not work correctly
ClassLoader cl = TestServlet.class.getClassLoader();
ctx.setParentClassLoader(cl);
ctx.addLifecycleListener(new ContextConfig());
ctx.setName("testContext");
ctx.setDocBase(app2.getAbsolutePath());
host.addChild(ctx);
boolean found = false;
for (Valve valve: ctx.getPipeline().getValves()) {
if (valve instanceof TuscanyValve) {
found = true;
break;
}
}
assertFalse("TuscanyValve in pipeline", found);
request.setContext(ctx);
request.setWrapper((Wrapper) ctx.findChild("TestServlet"));
host.invoke(request, response);
host.removeChild(ctx);
}
protected void setUp() throws Exception {
super.setUp();
app2 = new File(getClass().getResource("/app2").toURI());
File baseDir = new File(app2, "../../tomcat").getCanonicalFile();
setupTomcat(baseDir, new StandardHost());
engine.start();
}
protected void tearDown() throws Exception {
engine.stop();
super.tearDown();
}
}
|