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.tc.test.server.util.TcConfigBuilder;
13: import com.tctest.webapp.servlets.NewSessionAfterInvalidateTestServlet;
14:
15: import junit.framework.Test;
16:
17: public class NewSessionAfterInvalidateTest extends
18: AbstractTwoServerDeploymentTest {
19:
20: private static final String CONTEXT = "NewSession";
21: private static final String MAPPING = "new";
22:
23: public static Test suite() {
24: return new NewSessionTestSetup();
25: }
26:
27: public final void testSessions() throws Exception {
28: WebConversation conversation = new WebConversation();
29:
30: WebResponse response1 = request(server0, "step=1", conversation);
31: assertEquals("OK", response1.getText().trim());
32:
33: WebResponse response2 = request(server1, "step=2", 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: private static class NewSessionTestSetup extends TwoServerTestSetup {
44:
45: public NewSessionTestSetup() {
46: super (NewSessionAfterInvalidateTest.class, CONTEXT);
47: }
48:
49: protected void configureWar(DeploymentBuilder builder) {
50: builder.addServlet("NewSessionAfterInvalidateTestServlet",
51: "/" + MAPPING + "/*",
52: NewSessionAfterInvalidateTestServlet.class, null,
53: false);
54: }
55:
56: protected void configureTcConfig(TcConfigBuilder tcConfigBuilder) {
57: tcConfigBuilder.addWebApplication(CONTEXT);
58: }
59:
60: }
61: }
|