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;
16:
17: import java.util.HashMap;
18: import java.util.Map;
19: import junit.framework.TestCase;
20: import org.araneaframework.InputData;
21: import org.araneaframework.http.core.StandardServletInputData;
22: import org.araneaframework.http.core.StandardServletOutputData;
23: import org.araneaframework.http.util.ServletUtil;
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 StandardServletOutputDataTests extends TestCase {
32: private StandardServletOutputData out;
33: private MockHttpServletRequest req;
34: private MockHttpServletResponse resp;
35:
36: public void setUp() {
37: req = new MockHttpServletRequest();
38: StandardServletInputData inputData = new StandardServletInputData(
39: req);
40: req.setAttribute(InputData.INPUT_DATA_KEY, inputData);
41: resp = new MockHttpServletResponse();
42:
43: out = new StandardServletOutputData(req, resp);
44: }
45:
46: public void testGetRequest() {
47: assertEquals(req, ServletUtil.getRequest(out.getInputData()));
48: }
49:
50: public void testGetResponse() {
51: assertEquals(resp, ServletUtil.getResponse(out));
52: }
53:
54: public void testExtendNarrow() {
55: Map map = new HashMap();
56: out.extend(Map.class, map);
57: assertEquals(map, out.narrow(Map.class));
58: }
59:
60: public void testSetMimeType() {
61: String mime = "application/xhtml+xml";
62: out.setContentType(mime);
63: assertEquals(mime, resp.getContentType());
64: }
65:
66: public void testGetOutputStream() throws Exception {
67: assertEquals(resp.getOutputStream(), out.getOutputStream());
68: }
69: }
|