ServletActionContextTestpublic class ServletActionContextTest extends TestCase implements StrutsStaticsUnit test for ServletActionContext. Based loosly on Jason's ActionContextTest.
My first attempt at unit testing. Please hack away as needed. |
Fields Summary |
---|
com.opensymphony.xwork2.ActionContext | actionContext | ServletActionContext | servletActionContext | private HttpServletRequest | request | private HttpServletResponse | response | private com.mockobjects.servlet.MockServletContext | servletContext |
Methods Summary |
---|
public void | setUp()
Map extraContext = new HashMap();
request = new MockHttpServletRequest();
response = new MockHttpServletResponse();
servletContext = new MockServletContext();
extraContext.put(HTTP_REQUEST, request);
extraContext.put(HTTP_RESPONSE, response);
extraContext.put(SERVLET_CONTEXT, servletContext);
actionContext = new ActionContext(extraContext);
ServletActionContext.setContext(actionContext);
| public void | testContextParams()
assertEquals(ServletActionContext.getRequest(), request);
assertEquals(ServletActionContext.getResponse(), response);
assertEquals(ServletActionContext.getServletContext(), servletContext);
| public void | testGetContext()
ActionContext threadContext = ServletActionContext.getContext();
assertEquals(actionContext, threadContext);
|
|