1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.struts.mock;
19
20 import org.apache.struts.action.ActionServlet;
21
22 import javax.servlet.ServletConfig;
23 import javax.servlet.ServletContext;
24 import javax.servlet.ServletException;
25
26 /***
27 * <p>Mock <strong>ActionServlet</strong> object for low-level unit tests of
28 * Struts controller components. Coarser grained tests should be implemented
29 * in terms of the Cactus framework, instead of the mock object classes.</p>
30 *
31 * <p><strong>WARNING</strong> - Only getter methods for servletContext and
32 * servletConfig are provided, plus additional methods to configure this
33 * object as necessary. Methods for unsupported operations will throw
34 * <code>UnsupportedOperationException</code>.</p>
35 *
36 * <p><strong>WARNING</strong> - Because unit tests operate in a single
37 * threaded environment, no synchronization is performed.</p>
38 *
39 * @version $Rev: 421119 $ $Date: 2005-05-14 02:09:06 -0400 (Sat, 14 May 2005)
40 * $
41 */
42 public class MockActionServlet extends ActionServlet {
43 protected ServletContext servletContext;
44 protected ServletConfig servletConfig;
45
46 /***
47 * <p>Constructor.</p>
48 */
49 public MockActionServlet(ServletContext servletContext,
50 ServletConfig servletConfig) {
51 this.servletContext = servletContext;
52 this.servletConfig = servletConfig;
53 }
54
55 /***
56 * <p>Constructor.</p>
57 */
58 public MockActionServlet() {
59 ;
60 }
61
62 /***
63 * <p> Set property </p>
64 *
65 * @param servletContext
66 */
67 public void setServletContext(ServletContext servletContext) {
68 this.servletContext = servletContext;
69 }
70
71 /***
72 * <p> Get property </p>
73 *
74 * @return
75 */
76 public ServletContext getServletContext() {
77 return servletContext;
78 }
79
80 /***
81 * <p> Set property
82 *
83 * @param servletConfig
84 */
85 public void setServletConfig(ServletConfig servletConfig) {
86 this.servletConfig = servletConfig;
87 }
88
89 /***
90 * <p> Get property </p>
91 *
92 * @return
93 */
94 public ServletConfig getServletConfig() {
95 return servletConfig;
96 }
97
98 /***
99 * <p> Expose as public so that test classes can exercise things which
100 * retrieve messages. </p>
101 */
102 public void initInternal()
103 throws ServletException {
104 super.initInternal();
105 }
106 }