KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > struts > mock > MockActionServlet


1 /*
2  * $Id: MockActionServlet.java 54929 2004-10-16 16:38:42Z germuska $
3  *
4  * Copyright 1999-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19
20 package org.apache.struts.mock;
21
22
23 import javax.servlet.ServletContext JavaDoc;
24 import javax.servlet.ServletConfig JavaDoc;
25
26
27 import org.apache.struts.action.ActionServlet;
28
29 /**
30  * <p>Mock <strong>ActionServlet</strong> object for low-level unit tests
31  * of Struts controller components. Coarser grained tests should be
32  * implemented in terms of the Cactus framework, instead of the mock
33  * object classes.</p>
34  *
35  * <p><strong>WARNING</strong> - Only getter methods for servletContext and
36  * servletConfig are provided, plus additional methods to configure this
37  * object as necessary. Methods for unsupported operations will throw
38  * <code>UnsupportedOperationException</code>.</p>
39  *
40  * <p><strong>WARNING</strong> - Because unit tests operate in a single
41  * threaded environment, no synchronization is performed.</p>
42  *
43  * @version $Rev: 54929 $ $Date: 2004-10-16 17:38:42 +0100 (Sat, 16 Oct 2004) $
44  */

45 public class MockActionServlet extends ActionServlet
46 {
47   protected ServletContext JavaDoc servletContext;
48   protected ServletConfig JavaDoc servletConfig;
49
50     /**
51      * Constructor.
52      */

53   public MockActionServlet( ServletContext JavaDoc servletContext, ServletConfig JavaDoc servletConfig )
54   {
55   this.servletContext = servletContext;
56   this.servletConfig = servletConfig;
57   }
58
59     /**
60      * Constructor.
61      */

62   public MockActionServlet( )
63   {
64   }
65
66     /**
67      * Set property
68      * @param servletContext
69      */

70   public void setServletContext( ServletContext JavaDoc servletContext )
71   {
72   this.servletContext = servletContext;
73   }
74
75     /**
76      * Get property
77      * @return
78      */

79   public ServletContext JavaDoc getServletContext( )
80   {
81   return servletContext;
82   }
83
84     /**
85      * Set property
86      * @param servletConfig
87      */

88   public void setServletConfig( ServletConfig JavaDoc servletConfig )
89   {
90   this.servletConfig = servletConfig;
91   }
92
93     /**
94      * Get property
95      * @return
96      */

97   public ServletConfig JavaDoc getServletConfig( )
98   {
99   return servletConfig;
100   }
101 }
102
Popular Tags