public class


extends Object
implements HttpServletRequest
   ↳ com.atlassian.jira.mock.servlet.MockHttpServletRequest

Class Overview

Mock implementation of HttpServletRequest


Inherited Constants
From interface javax.servlet.http.HttpServletRequest
Public Constructors
MockHttpServletRequest(ServletInputStream servletInputStream)
MockHttpServletRequest(BufferedReader bufferedReader)
MockHttpServletRequest(HttpSession httpSession)
Use this constructor if you want to mock out the session returned from the request
Public Methods
MockHttpServletRequest addCookie(String name, String value)
MockHttpServletRequest addCookie(Cookie cookie)
boolean authenticate(HttpServletResponse response)
AsyncContext getAsyncContext()
Object getAttribute(String key)
Enumeration getAttributeNames()
String getAuthType()
String getCharacterEncoding()
int getContentLength()
String getContentType()
String getContextPath()
Cookie[] getCookies()
long getDateHeader(String string)
DispatcherType getDispatcherType()
String getHeader(String key)
Enumeration getHeaderNames()
Enumeration getHeaders(String string)
ServletInputStream getInputStream()
int getIntHeader(String string)
String getLocalAddr()
String getLocalName()
int getLocalPort()
Locale getLocale()
Enumeration<Locale> getLocales()
String getMethod()
String getParameter(String name)
Map getParameterMap()
Enumeration getParameterNames()
String[] getParameterValues(String name)
Part getPart(String name)
Collection<Part> getParts()
String getPathInfo()
String getPathTranslated()
String getProtocol()
String getQueryString()
BufferedReader getReader()
String getRealPath(String string)
String getRemoteAddr()
String getRemoteHost()
int getRemotePort()
String getRemoteUser()
RequestDispatcher getRequestDispatcher(String string)
String getRequestURI()
StringBuffer getRequestURL()
String getRequestedSessionId()
String getScheme()
String getServerName()
int getServerPort()
ServletContext getServletContext()
String getServletPath()
HttpSession getSession(boolean b)
HttpSession getSession()
Principal getUserPrincipal()
boolean isAsyncStarted()
boolean isAsyncSupported()
boolean isRequestedSessionIdFromCookie()
boolean isRequestedSessionIdFromURL()
boolean isRequestedSessionIdFromUrl()
boolean isRequestedSessionIdValid()
boolean isSecure()
boolean isUserInRole(String string)
void login(String username, String password)
void logout()
void removeAttribute(String string)
void setAttribute(String key, Object value)
void setCharacterEncoding(String encoding)
void setContentType(String contentType)
MockHttpServletRequest setContextPath(String contextPath)
MockHttpServletRequest setCookies(Map<StringString> cookies)
MockHttpServletRequest setCookies(Cookie[] cookies)
void setHeader(String key, String value)
void setLocale(Locale locale)
void setMethod(String method)
void setParameter(String name, String value)
void setProtocol(String protocol)
void setRemoteAddr(String remoteAddr)
void setRequestURL(String requestURL)
void setServletContext(ServletContext servletContext)
void setServletPath(String servletPath)
AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse)
AsyncContext startAsync()
Cookie[] toCookies(Map<StringString> cookieMap)
Converts the key valeus of a map to an array of cookies
Inherited Methods
From class java.lang.Object
From interface javax.servlet.ServletRequest
From interface javax.servlet.http.HttpServletRequest

Public Constructors

public MockHttpServletRequest ()

public MockHttpServletRequest (ServletInputStream servletInputStream)

public MockHttpServletRequest (BufferedReader bufferedReader)

public MockHttpServletRequest (HttpSession httpSession)

Use this constructor if you want to mock out the session returned from the request

httpSession the session. Hint: use MockHttpSession

Public Methods

public MockHttpServletRequest addCookie (String name, String value)

public MockHttpServletRequest addCookie (Cookie cookie)

public boolean authenticate (HttpServletResponse response)


public AsyncContext getAsyncContext ()

public Object getAttribute (String key)

public Enumeration getAttributeNames ()

public String getAuthType ()

public String getCharacterEncoding ()

public int getContentLength ()

public String getContentType ()

public String getContextPath ()

public Cookie[] getCookies ()

public long getDateHeader (String string)

public DispatcherType getDispatcherType ()

public String getHeader (String key)

public Enumeration getHeaderNames ()

public Enumeration getHeaders (String string)

public ServletInputStream getInputStream ()


public int getIntHeader (String string)

public String getLocalAddr ()

public String getLocalName ()

public int getLocalPort ()

public Locale getLocale ()

public Enumeration<Locale> getLocales ()

public String getMethod ()

public String getParameter (String name)

public Map getParameterMap ()

public Enumeration getParameterNames ()

public String[] getParameterValues (String name)

public Part getPart (String name)


public Collection<Part> getParts ()


public String getPathInfo ()

public String getPathTranslated ()

public String getProtocol ()

public String getQueryString ()

public BufferedReader getReader ()


public String getRealPath (String string)

public String getRemoteAddr ()

public String getRemoteHost ()

public int getRemotePort ()

public String getRemoteUser ()

public RequestDispatcher getRequestDispatcher (String string)

public String getRequestURI ()

public StringBuffer getRequestURL ()

public String getRequestedSessionId ()

public String getScheme ()

public String getServerName ()

public int getServerPort ()

public ServletContext getServletContext ()

public String getServletPath ()

public HttpSession getSession (boolean b)

public HttpSession getSession ()

public Principal getUserPrincipal ()

public boolean isAsyncStarted ()

public boolean isAsyncSupported ()

public boolean isRequestedSessionIdFromCookie ()

public boolean isRequestedSessionIdFromURL ()

public boolean isRequestedSessionIdFromUrl ()

public boolean isRequestedSessionIdValid ()

public boolean isSecure ()

public boolean isUserInRole (String string)

public void login (String username, String password)


public void logout ()


public void removeAttribute (String string)

public void setAttribute (String key, Object value)

public void setCharacterEncoding (String encoding)

public void setContentType (String contentType)

public MockHttpServletRequest setContextPath (String contextPath)

public MockHttpServletRequest setCookies (Map<StringString> cookies)

public MockHttpServletRequest setCookies (Cookie[] cookies)

public void setHeader (String key, String value)

public void setLocale (Locale locale)

public void setMethod (String method)

public void setParameter (String name, String value)

public void setProtocol (String protocol)

public void setRemoteAddr (String remoteAddr)

public void setRequestURL (String requestURL)

public void setServletContext (ServletContext servletContext)

public void setServletPath (String servletPath)

public AsyncContext startAsync (ServletRequest servletRequest, ServletResponse servletResponse)

public AsyncContext startAsync ()

public Cookie[] toCookies (Map<StringString> cookieMap)

Converts the key valeus of a map to an array of cookies

cookieMap a map of cookies
  • an array of cookies or null if its empty or null