1 5 package com.opensymphony.webwork.views.jsp; 6 7 import com.mockobjects.servlet.MockPageContext; 8 9 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 23 public class WebWorkMockPageContext extends MockPageContext { 24 26 private Map attributes = new HashMap (); 27 private ServletResponse response; 28 29 31 public void setAttribute(String s, Object o) { 32 if ((s == null) || (o == null)) { 33 throw new NullPointerException ("PageContext does not accept null attributes"); 34 } 35 36 this.attributes.put(s, o); 37 } 38 39 public Object getAttribute(String key) { 40 return attributes.get(key); 41 } 42 43 public Object getAttributes(String key) { 44 return this.attributes.get(key); 45 } 46 47 public void setResponse(ServletResponse response) { 48 this.response = response; 49 } 50 51 public ServletResponse getResponse() { 52 return response; 53 } 54 55 public HttpSession getSession() { 56 HttpSession session = super.getSession(); 57 58 if (session == null) { 59 session = ((HttpServletRequest ) getRequest()).getSession(true); 60 } 61 62 return session; 63 } 64 65 public Object findAttribute(String s) { 66 return attributes.get(s); 67 } 68 69 public void removeAttribute(String key) { 70 this.attributes.remove(key); 71 } 72 } 73 | Popular Tags |