01: /**
02: * Copyright 2006 Webmedia Group Ltd.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: **/package org.araneaframework.tests.framework.router;
16:
17: import java.util.HashMap;
18: import java.util.Map;
19: import junit.framework.TestCase;
20: import org.araneaframework.framework.SessionServiceContext;
21: import org.araneaframework.framework.router.StandardSessionServiceRouterService;
22: import org.araneaframework.http.core.StandardServletInputData;
23: import org.araneaframework.http.core.StandardServletOutputData;
24: import org.araneaframework.mock.MockUtil;
25: import org.araneaframework.mock.core.MockEventfulStandardService;
26: import org.springframework.mock.web.MockHttpServletRequest;
27: import org.springframework.mock.web.MockHttpServletResponse;
28:
29: /**
30: *
31: * @author "Toomas Römer" <toomas@webmedia.ee>
32: */
33: public class StandardSessionServiceRouterServiceTests extends TestCase {
34: private StandardSessionServiceRouterService service;
35: private MockEventfulStandardService child1;
36: private MockEventfulStandardService child2;
37:
38: private StandardServletInputData input;
39: private StandardServletOutputData output;
40:
41: private MockHttpServletRequest req;
42: private MockHttpServletResponse res;
43:
44: private Map map;
45:
46: public void setUp() throws Exception {
47: service = new StandardSessionServiceRouterService();
48: map = new HashMap();
49:
50: child1 = new MockEventfulStandardService();
51: child2 = new MockEventfulStandardService();
52:
53: req = new MockHttpServletRequest();
54: res = new MockHttpServletResponse();
55:
56: input = new StandardServletInputData(req);
57: output = new StandardServletOutputData(req, res);
58:
59: map.put("child1", child1);
60: map.put("child2", child2);
61:
62: service.setServiceMap(map);
63: service._getComponent().init(null, MockUtil.getEnv());
64:
65: service.setDefaultServiceId("child1");
66: }
67:
68: public void testCloseRemoves() throws Exception {
69: service._getService().action(MockUtil.getPath(), input, output);
70: SessionServiceContext sess = (SessionServiceContext) child1
71: .getTheEnvironment().getEntry(
72: SessionServiceContext.class);
73: sess.close("child1");
74: assertTrue(child1.getDestroyCalled());
75: }
76: }
|