Clover Coverage Report - Pebble 2.5-SNAPSHOT
Coverage timestamp: Sat Jun 12 2010 09:39:29 EST
../../../../img/srcFileCovDistChart3.png 44% of files have more coverage
68   328   65   1,08
4   220   0,96   63
63     1,03  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  MockHttpServletRequest       Line # 50 68 0% 65 98 27,4% 0.27407408
 
  (142)
 
1    /*
2    * Copyright (c) 2003-2006, Simon Brown
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions are met:
7    *
8    * - Redistributions of source code must retain the above copyright
9    * notice, this list of conditions and the following disclaimer.
10    *
11    * - Redistributions in binary form must reproduce the above copyright
12    * notice, this list of conditions and the following disclaimer in
13    * the documentation and/or other materials provided with the
14    * distribution.
15    *
16    * - Neither the name of Pebble nor the names of its contributors may
17    * be used to endorse or promote products derived from this software
18    * without specific prior written permission.
19    *
20    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21    * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22    * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23    * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24    * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25    * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26    * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27    * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28    * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29    * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30    * POSSIBILITY OF SUCH DAMAGE.
31    */
32    package net.sourceforge.pebble.mock;
33   
34    import javax.servlet.RequestDispatcher;
35    import javax.servlet.ServletInputStream;
36    import javax.servlet.http.Cookie;
37    import javax.servlet.http.HttpServletRequest;
38    import javax.servlet.http.HttpSession;
39    import java.io.BufferedReader;
40    import java.io.IOException;
41    import java.io.UnsupportedEncodingException;
42    import java.security.Principal;
43    import java.util.*;
44   
45    /**
46    * A mock HttpServletRequest implementation.
47    *
48    * @author Simon Brown
49    */
 
50    public class MockHttpServletRequest implements HttpServletRequest {
51   
52    private Properties headers = new Properties();
53    private HashMap parameters = new HashMap();
54    private HashMap attributes = new HashMap();
55   
56    private HttpSession session = new MockHttpSession();
57   
58    private String contextPath;
59    private String requestUri = "";
60    private StringBuffer requestUrl = new StringBuffer();
61    private RequestDispatcher requestDispatcher;
62   
63    private MockPrincipal userPrincipal;
64   
 
65  0 toggle public String getAuthType() {
66  0 return null;
67    }
68   
 
69  6 toggle public Cookie[] getCookies() {
70  6 return new Cookie[0];
71    }
72   
 
73  0 toggle public long getDateHeader(String name) {
74  0 String value = getHeader(name);
75  0 if (value != null) {
76  0 return Long.parseLong(getHeader(name));
77    } else {
78  0 return -1;
79    }
80    }
81   
 
82  28 toggle public String getHeader(String s) {
83  28 return headers.getProperty(s);
84    }
85   
 
86  0 toggle public Enumeration getHeaders(String s) {
87  0 return null;
88    }
89   
 
90  0 toggle public Enumeration getHeaderNames() {
91  0 return headers.keys();
92    }
93   
 
94  4 toggle public void setHeader(String name, String value) {
95  4 headers.put(name, value);
96    }
97   
 
98  0 toggle public void setDateHeader(String name, long value) {
99  0 setHeader(name, "" + value);
100    }
101   
 
102  0 toggle public int getIntHeader(String s) {
103  0 return 0;
104    }
105   
 
106  0 toggle public String getMethod() {
107  0 return null;
108    }
109   
 
110  0 toggle public String getPathInfo() {
111  0 return null;
112    }
113   
 
114  0 toggle public String getPathTranslated() {
115  0 return null;
116    }
117   
 
118  30 toggle public String getContextPath() {
119  30 return this.contextPath;
120    }
121   
 
122  12 toggle public void setContextPath(String contextPath) {
123  12 this.contextPath = contextPath;
124    }
125   
 
126  16 toggle public String getQueryString() {
127  16 return null;
128    }
129   
 
130  0 toggle public String getRemoteUser() {
131  0 return null;
132    }
133   
 
134  0 toggle public boolean isUserInRole(String s) {
135  0 if (this.userPrincipal != null) {
136  0 return userPrincipal.isUserInRole(s);
137    } else {
138  0 return false;
139    }
140    }
141   
 
142  0 toggle public Principal getUserPrincipal() {
143  0 return this.userPrincipal;
144    }
145   
 
146  0 toggle public void setUserPrincipal(Principal p) {
147  0 this.userPrincipal = (MockPrincipal)p;
148    }
149   
 
150  0 toggle public String getRequestedSessionId() {
151  0 return null;
152    }
153   
 
154  30 toggle public String getRequestURI() {
155  30 return this.requestUri;
156    }
157   
 
158  40 toggle public void setRequestUri(String requestUri) {
159  40 this.requestUri = requestUri;
160    }
161   
 
162  0 toggle public StringBuffer getRequestURL() {
163  0 return this.requestUrl;
164    }
165   
 
166  0 toggle public void setRequestUrl(String requestUrl) {
167  0 this.requestUrl = new StringBuffer(requestUrl);
168    }
169   
 
170  0 toggle public String getServletPath() {
171  0 return null;
172    }
173   
 
174  0 toggle public HttpSession getSession(boolean b) {
175  0 return session;
176    }
177   
 
178  32 toggle public HttpSession getSession() {
179  32 return session;
180    }
181   
 
182  0 toggle public boolean isRequestedSessionIdValid() {
183  0 return false;
184    }
185   
 
186  0 toggle public boolean isRequestedSessionIdFromCookie() {
187  0 return false;
188    }
189   
 
190  0 toggle public boolean isRequestedSessionIdFromURL() {
191  0 return false;
192    }
193   
 
194  0 toggle public boolean isRequestedSessionIdFromUrl() {
195  0 return false;
196    }
197   
 
198  58 toggle public Object getAttribute(String s) {
199  58 return attributes.get(s);
200    }
201   
 
202  0 toggle public Enumeration getAttributeNames() {
203  0 return null;
204    }
205   
 
206  0 toggle public String getCharacterEncoding() {
207  0 return null;
208    }
209   
 
210  0 toggle public void setCharacterEncoding(String s) throws UnsupportedEncodingException {
211    }
212   
 
213  0 toggle public int getContentLength() {
214  0 return 0;
215    }
216   
 
217  0 toggle public String getContentType() {
218  0 return null;
219    }
220   
 
221  0 toggle public ServletInputStream getInputStream() throws IOException {
222  0 return null;
223    }
224   
 
225  256 toggle public void setParameter(String name, String value) {
226  256 parameters.put(name, value);
227    }
228   
 
229  4 toggle public void setParameter(String name, String value[]) {
230  4 parameters.put(name, value);
231    }
232   
 
233  372 toggle public String getParameter(String s) {
234  372 return (String)parameters.get(s);
235    }
236   
 
237  0 toggle public Enumeration getParameterNames() {
238  0 return Collections.enumeration(parameters.keySet());
239    }
240   
 
241  4 toggle public String[] getParameterValues(String s) {
242  4 return (String[])parameters.get(s);
243    }
244   
 
245  0 toggle public Map getParameterMap() {
246  0 return null;
247    }
248   
 
249  0 toggle public String getProtocol() {
250  0 return null;
251    }
252   
 
253  0 toggle public String getScheme() {
254  0 return null;
255    }
256   
 
257  0 toggle public String getServerName() {
258  0 return null;
259    }
260   
 
261  0 toggle public int getServerPort() {
262  0 return 0;
263    }
264   
 
265  0 toggle public BufferedReader getReader() throws IOException {
266  0 return null;
267    }
268   
 
269  12 toggle public String getRemoteAddr() {
270  12 return null;
271    }
272   
 
273  0 toggle public String getRemoteHost() {
274  0 return null;
275    }
276   
 
277  112 toggle public void setAttribute(String s, Object o) {
278  112 attributes.put(s, o);
279    }
280   
 
281  0 toggle public void removeAttribute(String s) {
282  0 attributes.remove(s);
283    }
284   
 
285  0 toggle public Locale getLocale() {
286  0 return null;
287    }
288   
 
289  0 toggle public Enumeration getLocales() {
290  0 return null;
291    }
292   
 
293  0 toggle public boolean isSecure() {
294  0 return false;
295    }
296   
 
297  2 toggle public RequestDispatcher getRequestDispatcher(String s) {
298  2 this.requestDispatcher = new MockRequestDispatcher(s);
299   
300  2 return this.requestDispatcher;
301    }
302   
 
303  2 toggle public RequestDispatcher getRequestDispatcher() {
304  2 return this.requestDispatcher;
305    }
306   
 
307  0 toggle public String getRealPath(String s) {
308  0 return null;
309    }
310   
 
311  0 toggle public int getRemotePort() {
312  0 return 0; //To change body of implemented methods use File | Settings | File Templates.
313    }
314   
 
315  0 toggle public String getLocalName() {
316  0 return null; //To change body of implemented methods use File | Settings | File Templates.
317    }
318   
 
319  0 toggle public String getLocalAddr() {
320  0 return null; //To change body of implemented methods use File | Settings | File Templates.
321    }
322   
 
323  0 toggle public int getLocalPort() {
324  0 return 0; //To change body of implemented methods use File | Settings | File Templates.
325    }
326   
327   
328    }