summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/java/org/apache/tuscany/tomcat/integration/TomcatStandaloneTestCase.java
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/java/org/apache/tuscany/tomcat/integration/TomcatStandaloneTestCase.java')
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/java/org/apache/tuscany/tomcat/integration/TomcatStandaloneTestCase.java63
1 files changed, 63 insertions, 0 deletions
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/java/org/apache/tuscany/tomcat/integration/TomcatStandaloneTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/java/org/apache/tuscany/tomcat/integration/TomcatStandaloneTestCase.java
new file mode 100644
index 0000000000..b623b2e7b5
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/java/org/apache/tuscany/tomcat/integration/TomcatStandaloneTestCase.java
@@ -0,0 +1,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();
+ }
+
+}