View Javadoc

    1   /*
    2    * $Id: HttpServletRequestMock.java 502294 2007-02-01 17:28:00Z niallp $
    3    *
    4    * Licensed to the Apache Software Foundation (ASF) under one
    5    * or more contributor license agreements.  See the NOTICE file
    6    * distributed with this work for additional information
    7    * regarding copyright ownership.  The ASF licenses this file
    8    * to you under the Apache License, Version 2.0 (the
    9    * "License"); you may not use this file except in compliance
    10   * with the License.  You may obtain a copy of the License at
    11   *
    12   *  http://www.apache.org/licenses/LICENSE-2.0
    13   *
    14   * Unless required by applicable law or agreed to in writing,
    15   * software distributed under the License is distributed on an
    16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    17   * KIND, either express or implied.  See the License for the
    18   * specific language governing permissions and limitations
    19   * under the License.
    20   */
    21  package org.apache.struts2.portlet.util;
    22
    23  import java.io.BufferedReader;
    24  import java.io.IOException;
    25  import java.io.UnsupportedEncodingException;
    26  import java.security.Principal;
    27  import java.util.Enumeration;
    28  import java.util.Locale;
    29  import java.util.Map;
    30
    31  import javax.servlet.RequestDispatcher;
    32  import javax.servlet.ServletInputStream;
    33  import javax.servlet.http.Cookie;
    34  import javax.servlet.http.HttpServletRequest;
    35  import javax.servlet.http.HttpSession;
    36
    37  /***
    38   * A simple mock class to interact with Struts 2 API's that require a servlet request
    39   */
    40  public class HttpServletRequestMock implements HttpServletRequest {
    41
    42      private String servletPath;
    43      private Map parameterMap;
    44
    45      public String getAuthType() {
    46          return null;
    47      }
    48
    49      public String getContextPath() {
    50          return null;
    51      }
    52
    53      public Cookie[] getCookies() {
    54          return null;
    55      }
    56
    57      public long getDateHeader(String arg0) {
    58          return 0;
    59      }
    60
    61      public String getHeader(String arg0) {
    62          return null;
    63      }
    64
    65      public Enumeration getHeaderNames() {
    66          return null;
    67      }
    68
    69      public Enumeration getHeaders(String arg0) {
    70          return null;
    71      }
    72
    73      public int getIntHeader(String arg0) {
    74          return 0;
    75      }
    76
    77      public String getMethod() {
    78          return null;
    79      }
    80
    81      public String getPathInfo() {
    82          return null;
    83      }
    84
    85      public String getPathTranslated() {
    86          return null;
    87      }
    88
    89      public String getQueryString() {
    90          return null;
    91      }
    92
    93      public String getRemoteUser() {
    94          return null;
    95      }
    96
    97      public String getRequestURI() {
    98          return null;
    99      }
    100
    101     public StringBuffer getRequestURL() {
    102         return null;
    103     }
    104
    105     public String getRequestedSessionId() {
    106         return null;
    107     }
    108
    109     public String getServletPath() {
    110         return servletPath;
    111     }
    112
    113     public HttpSession getSession() {
    114         return null;
    115     }
    116
    117     public HttpSession getSession(boolean arg0) {
    118         return null;
    119     }
    120
    121     public Principal getUserPrincipal() {
    122         return null;
    123     }
    124
    125     public boolean isRequestedSessionIdFromCookie() {
    126         return false;
    127     }
    128
    129     public boolean isRequestedSessionIdFromURL() {
    130         return false;
    131     }
    132
    133     public boolean isRequestedSessionIdFromUrl() {
    134         return false;
    135     }
    136
    137     public boolean isRequestedSessionIdValid() {
    138         return false;
    139     }
    140
    141     public boolean isUserInRole(String arg0) {
    142         return false;
    143     }
    144
    145     public Object getAttribute(String arg0) {
    146         return null;
    147     }
    148
    149     public Enumeration getAttributeNames() {
    150         return null;
    151     }
    152
    153     public String getCharacterEncoding() {
    154         return null;
    155     }
    156
    157     public int getContentLength() {
    158         return 0;
    159     }
    160
    161     public String getContentType() {
    162         return null;
    163     }
    164
    165     public ServletInputStream getInputStream() throws IOException {
    166         return null;
    167     }
    168
    169     public String getLocalAddr() {
    170         return null;
    171     }
    172
    173     public String getLocalName() {
    174         return null;
    175     }
    176
    177     public int getLocalPort() {
    178         return 0;
    179     }
    180
    181     public Locale getLocale() {
    182         return null;
    183     }
    184
    185     public Enumeration getLocales() {
    186         return null;
    187     }
    188
    189     public String getParameter(String arg0) {
    190         return null;
    191     }
    192
    193     public Map getParameterMap() {
    194         return parameterMap;
    195     }
    196
    197     public Enumeration getParameterNames() {
    198         return null;
    199     }
    200
    201     public String[] getParameterValues(String arg0) {
    202         return null;
    203     }
    204
    205     public String getProtocol() {
    206         return null;
    207     }
    208
    209     public BufferedReader getReader() throws IOException {
    210         return null;
    211     }
    212
    213     public String getRealPath(String arg0) {
    214         return null;
    215     }
    216
    217     public String getRemoteAddr() {
    218         return null;
    219     }
    220
    221     public String getRemoteHost() {
    222         return null;
    223     }
    224
    225     public int getRemotePort() {
    226         return 0;
    227     }
    228
    229     public RequestDispatcher getRequestDispatcher(String arg0) {
    230         return null;
    231     }
    232
    233     public String getScheme() {
    234         return null;
    235     }
    236
    237     public String getServerName() {
    238         return null;
    239     }
    240
    241     public int getServerPort() {
    242         return 0;
    243     }
    244
    245     public boolean isSecure() {
    246         return false;
    247     }
    248
    249     public void removeAttribute(String arg0) {
    250     }
    251
    252     public void setAttribute(String arg0, Object arg1) {
    253     }
    254
    255     public void setCharacterEncoding(String arg0)
    256             throws UnsupportedEncodingException {
    257
    258     }
    259
    260     /***
    261      * @param parameterMap the parameterMap to set
    262      */
    263     public HttpServletRequestMock setParameterMap(Map parameterMap) {
    264         this.parameterMap = parameterMap;
    265         return this;
    266     }
    267
    268     /***
    269      * @param servletPath the servletPath to set
    270      */
    271     public HttpServletRequestMock setServletPath(String servletPath) {
    272         this.servletPath = servletPath;
    273         return this;
    274     }
    275
    276
    277
    278 }