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.container;
16:
17: import junit.framework.TestCase;
18: import org.araneaframework.Path;
19: import org.araneaframework.framework.container.StandardContainerService;
20: import org.araneaframework.http.core.StandardServletInputData;
21: import org.araneaframework.http.core.StandardServletOutputData;
22: import org.araneaframework.mock.MockLifeCycle;
23: import org.araneaframework.mock.MockUtil;
24: import org.araneaframework.mock.core.MockEventfulStandardService;
25: import org.springframework.mock.web.MockHttpServletRequest;
26: import org.springframework.mock.web.MockHttpServletResponse;
27:
28: /**
29: * @author "Toomas Römer" <toomas@webmedia.ee>
30: *
31: */
32: public class StandardServiceContainerServiceTests extends TestCase {
33: private StandardContainerService parent;
34: private MockEventfulStandardService child;
35:
36: private StandardServletInputData input;
37: private StandardServletOutputData output;
38:
39: private MockHttpServletRequest req;
40: private MockHttpServletResponse res;
41:
42: private Path path;
43:
44: public void setUp() throws Exception {
45: child = new MockEventfulStandardService();
46: parent = new StandardContainerService();
47: parent.setChildService(child);
48: MockLifeCycle.begin(parent);
49:
50: req = new MockHttpServletRequest();
51: res = new MockHttpServletResponse();
52:
53: input = new StandardServletInputData(req);
54: output = new StandardServletOutputData(req, res);
55:
56: path = MockUtil.getPath();
57: }
58:
59: public void testActionGetsCalled() throws Exception {
60: String pathStr = "i.am.a.path.who.are.you";
61: req
62: .addParameter(
63: StandardContainerService.ACTION_PATH_INPUT_DATA_PARAMETER,
64: pathStr);
65: input = new StandardServletInputData(req);
66:
67: parent._getService().action(path, input, output);
68: assertTrue(child.getActionCalled());
69: assertTrue(pathStr.equals(child.getPath().toString()));
70: }
71:
72: public void testActionDoesNotGetCalled() throws Exception {
73: input = new StandardServletInputData(req);
74:
75: parent._getService().action(path, input, output);
76: assertFalse(child.getActionCalled());
77: }
78:
79: public void testDestroyGetsCalled() throws Exception {
80: parent._getComponent().destroy();
81: assertTrue(child.getDestroyCalled());
82: }
83: }
|