1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.apache.jetspeed.mocks;
18
19 import java.util.HashMap;
20 import java.util.Map;
21
22 import javax.servlet.ServletContext;
23
24 import com.mockrunner.mock.web.MockServletContext;
25
26
27 public abstract class BaseMockServletContext extends MockServletContext implements ServletContext
28 {
29 private final Map attributes = new HashMap();
30
31 public BaseMockServletContext()
32 {
33 super();
34 }
35 public Object getAttribute(String arg0)
36 {
37 return attributes.get(arg0);
38 }
39
40 /*
41 public Enumeration getAttributeNames()
42 {
43 unsupported();
44 return null;
45 }
46
47 public ServletContext getContext(String arg0)
48 {
49 unsupported();
50 return null;
51 }
52
53 public String getInitParameter(String arg0)
54 {
55 unsupported();
56 return null;
57 }
58
59 public Enumeration getInitParameterNames()
60 {
61 unsupported();
62 return null;
63 }
64
65 public int getMajorVersion()
66 {
67 return 2;
68 }
69
70 public String getMimeType(String arg0)
71 {
72 unsupported();
73 return null;
74 }
75
76 public int getMinorVersion()
77 {
78 return 3;
79 }
80
81 public RequestDispatcher getNamedDispatcher(String arg0)
82 {
83 unsupported();
84 return null;
85 }
86
87 public String getRealPath(String arg0)
88 {
89 unsupported();
90 return null;
91 }
92
93 public RequestDispatcher getRequestDispatcher(String arg0)
94 {
95 unsupported();
96 return null;
97 }
98
99 public URL getResource(String arg0) throws MalformedURLException
100 {
101 unsupported();
102 return null;
103 }
104
105 public InputStream getResourceAsStream(String arg0)
106 {
107 unsupported();
108 return null;
109 }
110
111 public Set getResourcePaths(String arg0)
112 {
113 unsupported();
114 return null;
115 }
116
117 public String getServerInfo()
118 {
119 unsupported();
120 return null;
121 }
122
123 public Servlet getServlet(String arg0) throws ServletException
124 {
125 unsupported();
126 return null;
127 }
128
129 public String getServletContextName()
130 {
131 unsupported();
132 return null;
133 }
134
135 public Enumeration getServletNames()
136 {
137 unsupported();
138 return null;
139 }
140
141 public Enumeration getServlets()
142 {
143 unsupported();
144 return null;
145 }
146
147 public void log(Exception arg0, String arg1)
148 {
149 unsupported();
150
151 }
152
153 public void log(String arg0, Throwable arg1)
154 {
155 unsupported();
156
157 }
158
159 public void log(String arg0)
160 {
161 unsupported();
162
163 }
164 */
165 public void removeAttribute(String arg0)
166 {
167 attributes.remove(arg0);
168
169 }
170
171 public void setAttribute(String arg0, Object arg1)
172 {
173 attributes.put(arg0, arg1);
174
175 }
176
177 protected final void unsupported() throws UnsupportedOperationException
178 {
179 throw new UnsupportedOperationException("The method called has not been implemented.");
180 }
181
182 }