1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.seasar.cubby.unit; |
17 | |
|
18 | |
import java.io.InputStream; |
19 | |
import java.net.MalformedURLException; |
20 | |
import java.net.URL; |
21 | |
import java.util.Enumeration; |
22 | |
import java.util.Hashtable; |
23 | |
import java.util.Set; |
24 | |
|
25 | |
import javax.servlet.RequestDispatcher; |
26 | |
import javax.servlet.Servlet; |
27 | |
import javax.servlet.ServletContext; |
28 | |
import javax.servlet.ServletException; |
29 | |
|
30 | |
import org.slf4j.Logger; |
31 | |
import org.slf4j.LoggerFactory; |
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | 3 | class MockServletContext implements ServletContext { |
39 | |
|
40 | 1 | private static final Logger logger = LoggerFactory |
41 | |
.getLogger(MockServletContext.class); |
42 | |
|
43 | 3 | private Hashtable<String, String> initParameters = new Hashtable<String, String>(); |
44 | |
|
45 | 3 | private Hashtable<String, Object> attributes = new Hashtable<String, Object>(); |
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
public String getContextPath() { |
51 | 0 | throw new UnsupportedOperationException(); |
52 | |
} |
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
public ServletContext getContext(String uripath) { |
58 | 0 | throw new UnsupportedOperationException(); |
59 | |
} |
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
public int getMajorVersion() { |
65 | 0 | return 2; |
66 | |
} |
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
public int getMinorVersion() { |
72 | 0 | return 5; |
73 | |
} |
74 | |
|
75 | |
|
76 | |
|
77 | |
|
78 | |
public String getMimeType(String file) { |
79 | 0 | throw new UnsupportedOperationException(); |
80 | |
} |
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
@SuppressWarnings("unchecked") |
86 | |
public Set getResourcePaths(String path) { |
87 | 0 | throw new UnsupportedOperationException(); |
88 | |
} |
89 | |
|
90 | |
|
91 | |
|
92 | |
|
93 | |
public URL getResource(String path) throws MalformedURLException { |
94 | 0 | throw new UnsupportedOperationException(); |
95 | |
} |
96 | |
|
97 | |
|
98 | |
|
99 | |
|
100 | |
public InputStream getResourceAsStream(String path) { |
101 | 0 | throw new UnsupportedOperationException(); |
102 | |
} |
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | |
public RequestDispatcher getRequestDispatcher(String path) { |
108 | 0 | throw new UnsupportedOperationException(); |
109 | |
} |
110 | |
|
111 | |
|
112 | |
|
113 | |
|
114 | |
public RequestDispatcher getNamedDispatcher(String name) { |
115 | 0 | throw new UnsupportedOperationException(); |
116 | |
} |
117 | |
|
118 | |
|
119 | |
|
120 | |
|
121 | |
public Servlet getServlet(String name) throws ServletException { |
122 | 0 | throw new UnsupportedOperationException(); |
123 | |
} |
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | |
@SuppressWarnings("unchecked") |
129 | |
public Enumeration getServlets() { |
130 | 0 | throw new UnsupportedOperationException(); |
131 | |
} |
132 | |
|
133 | |
|
134 | |
|
135 | |
|
136 | |
@SuppressWarnings("unchecked") |
137 | |
public Enumeration getServletNames() { |
138 | 0 | throw new UnsupportedOperationException(); |
139 | |
} |
140 | |
|
141 | |
|
142 | |
|
143 | |
|
144 | |
public void log(String msg) { |
145 | 0 | logger.info(msg); |
146 | 0 | } |
147 | |
|
148 | |
|
149 | |
|
150 | |
|
151 | |
public void log(Exception exception, String msg) { |
152 | 0 | this.log(msg, exception); |
153 | 0 | } |
154 | |
|
155 | |
|
156 | |
|
157 | |
|
158 | |
public void log(String message, Throwable throwable) { |
159 | 0 | logger.info(message, throwable); |
160 | 0 | } |
161 | |
|
162 | |
|
163 | |
|
164 | |
|
165 | |
public String getRealPath(String path) { |
166 | 0 | throw new UnsupportedOperationException(); |
167 | |
} |
168 | |
|
169 | |
|
170 | |
|
171 | |
|
172 | |
public String getServerInfo() { |
173 | 0 | throw new UnsupportedOperationException(); |
174 | |
} |
175 | |
|
176 | |
|
177 | |
|
178 | |
|
179 | |
public String getInitParameter(String name) { |
180 | 0 | return initParameters.get(name); |
181 | |
} |
182 | |
|
183 | |
|
184 | |
|
185 | |
|
186 | |
@SuppressWarnings("unchecked") |
187 | |
public Enumeration getInitParameterNames() { |
188 | 0 | return initParameters.keys(); |
189 | |
} |
190 | |
|
191 | |
|
192 | |
|
193 | |
|
194 | |
public Object getAttribute(String name) { |
195 | 0 | return attributes.get(name); |
196 | |
} |
197 | |
|
198 | |
|
199 | |
|
200 | |
|
201 | |
@SuppressWarnings("unchecked") |
202 | |
public Enumeration getAttributeNames() { |
203 | 0 | return attributes.keys(); |
204 | |
} |
205 | |
|
206 | |
|
207 | |
|
208 | |
|
209 | |
public void setAttribute(String name, Object object) { |
210 | 0 | attributes.put(name, object); |
211 | 0 | } |
212 | |
|
213 | |
|
214 | |
|
215 | |
|
216 | |
public void removeAttribute(String name) { |
217 | 0 | attributes.remove(name); |
218 | 0 | } |
219 | |
|
220 | |
|
221 | |
|
222 | |
|
223 | |
public String getServletContextName() { |
224 | 0 | throw new UnsupportedOperationException(); |
225 | |
} |
226 | |
|
227 | |
} |