01: /*
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tctest.server.appserver.unit;
06:
07: import com.meterware.httpunit.WebConversation;
08: import com.meterware.httpunit.WebResponse;
09: import com.tc.test.server.appserver.deployment.AbstractTwoServerDeploymentTest;
10: import com.tc.test.server.appserver.deployment.DeploymentBuilder;
11: import com.tc.test.server.appserver.deployment.WebApplicationServer;
12: import com.tctest.webapp.servlets.ShutdownNormallyServlet;
13:
14: import junit.framework.Test;
15:
16: public class SimpleSessionTest extends AbstractTwoServerDeploymentTest {
17: public static final String CONFIG_FILE_FOR_TEST = "/tc-config-files/simplesession-tc-config.xml";
18: private static final String CONTEXT = "simple";
19: private static final String MAPPING = "doit";
20:
21: public static Test suite() {
22: return new SimpleSessionTestSetup();
23: }
24:
25: public void testSession() throws Exception {
26: WebConversation conversation = new WebConversation();
27:
28: WebResponse response1 = request(server0, "cmd=insert",
29: conversation);
30: assertEquals("OK", response1.getText().trim());
31:
32: WebResponse response2 = request(server1, "cmd=query",
33: conversation);
34: assertEquals("OK", response2.getText().trim());
35: }
36:
37: private WebResponse request(WebApplicationServer server,
38: String params, WebConversation con) throws Exception {
39: return server.ping(
40: "/" + CONTEXT + "/" + MAPPING + "?" + params, con);
41: }
42:
43: /** ****** test setup ********* */
44: private static class SimpleSessionTestSetup extends
45: TwoServerTestSetup {
46:
47: public SimpleSessionTestSetup() {
48: super (SimpleSessionTest.class, CONFIG_FILE_FOR_TEST,
49: CONTEXT);
50: }
51:
52: protected void configureWar(DeploymentBuilder builder) {
53: builder.addServlet("ShutdownNormallyServlet", "/" + MAPPING
54: + "/*", ShutdownNormallyServlet.class, null, false);
55: }
56:
57: }
58:
59: }
|