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