01: /*
02: * Copyright (c) 2002-2003 by OpenSymphony
03: * All rights reserved.
04: */
05: package com.opensymphony.webwork.views.jsp;
06:
07: import com.mockobjects.servlet.MockPageContext;
08:
09: import javax.servlet.ServletResponse;
10: import javax.servlet.http.HttpServletRequest;
11: import javax.servlet.http.HttpSession;
12: import java.util.HashMap;
13: import java.util.Map;
14:
15: /**
16: * Created by IntelliJ IDEA.
17: * User: Administrator
18: * Date: 14-Mar-2003
19: * Time: 5:52:36 PM
20: * To change this template use Options | File Templates.
21: */
22: public class WebWorkMockPageContext extends MockPageContext {
23:
24: private Map attributes = new HashMap();
25: private ServletResponse response;
26:
27: public void setAttribute(String s, Object o) {
28: if ((s == null) || (o == null)) {
29: throw new NullPointerException(
30: "PageContext does not accept null attributes");
31: }
32:
33: this .attributes.put(s, o);
34: }
35:
36: public Object getAttribute(String key) {
37: return attributes.get(key);
38: }
39:
40: public Object getAttributes(String key) {
41: return this .attributes.get(key);
42: }
43:
44: public void setResponse(ServletResponse response) {
45: this .response = response;
46: }
47:
48: public ServletResponse getResponse() {
49: return response;
50: }
51:
52: public HttpSession getSession() {
53: HttpSession session = super .getSession();
54:
55: if (session == null) {
56: session = ((HttpServletRequest) getRequest())
57: .getSession(true);
58: }
59:
60: return session;
61: }
62:
63: public Object findAttribute(String s) {
64: return attributes.get(s);
65: }
66:
67: public void removeAttribute(String key) {
68: this.attributes.remove(key);
69: }
70: }
|