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