KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mockobjects > helpers > AbstractServletTestHelper


1 package com.mockobjects.helpers;
2
3 import com.mockobjects.servlet.*;
4
5 /**
6  * $Revision: 1.1 $
7  */

8 public abstract class AbstractServletTestHelper {
9     protected final MockHttpServletRequest request = new MockHttpServletRequest();
10     protected final MockHttpServletResponse response = new MockHttpServletResponse();
11     protected final MockHttpSession httpSession = new MockHttpSession();
12     protected final MockRequestDispatcher requestDispatcher = new MockRequestDispatcher();
13     protected final MockServletContext servletContext = new MockServletContext();
14     protected final MockServletConfig servletConfig = new MockServletConfig();
15
16     public AbstractServletTestHelper() {
17         request.setSession(httpSession);
18         servletContext.setupGetRequestDispatcher(requestDispatcher);
19         request.setupGetRequestDispatcher(requestDispatcher);
20         httpSession.setupServletContext(servletContext);
21         servletConfig.setServletContext(servletContext);
22     }
23
24     public MockHttpServletRequest getRequest() {
25         return request;
26     }
27
28     public MockHttpSession getHttpSession() {
29         return httpSession;
30     }
31
32     public MockRequestDispatcher getRequestDispatcher() {
33         return requestDispatcher;
34     }
35
36     public MockHttpServletResponse getResponse() {
37         return response;
38     }
39
40     public MockServletContext getServletContext() {
41         return servletContext;
42     }
43
44     public MockServletConfig getServletConfig() {
45         return servletConfig;
46     }
47 }
48
Popular Tags