net.liftweb.mocks

MockHttpServletRequest

class MockHttpServletRequest extends HttpServletRequest

A Mock ServletRequest. Change its state to create the request you are interested in. At the very least, you will need to change method and path.

There are several things that aren't supported:

Linear Supertypes
HttpServletRequest, ServletRequest, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. MockHttpServletRequest
  2. HttpServletRequest
  3. ServletRequest
  4. AnyRef
  5. Any
Visibility
  1. Public
  2. All

Instance Constructors

  1. new MockHttpServletRequest(url: URL, contextPath: String)

    Construct a new mock request for the given URL.

    Construct a new mock request for the given URL. See processUrl for limitations.

    url

    The URL to extract from

    contextPath

    The servlet context of the request.

  2. new MockHttpServletRequest(url: URL)

    Construct a new mock request for the given URL.

    Construct a new mock request for the given URL. See processUrl for limitations.

    url

    The URL to extract from

  3. new MockHttpServletRequest(url: String = null, contextPath: String = "")

    url

    The URL to extract from

    contextPath

    The context path for this request. Defaults to "" per the Servlet API.

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. def addBasicAuth(user: String, pass: String): Unit

    Adds an "Authorization" header, per RFC1945.

  7. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  8. var attributes: Map[String, AnyRef]

  9. var authType: String

  10. var body: Array[Byte]

    The raw body of the request.

  11. def body_=(jval: JValue, contentType: String): Unit

    Sets the body to the given json value and content type.

  12. def body_=(jval: JValue): Unit

    Sets the body to the given json value.

    Sets the body to the given json value. Also sets the contentType to "application/json"

  13. def body_=(nodes: NodeSeq, contentType: String): Unit

    Sets the body to the given elements and content type.

    Sets the body to the given elements and content type.

    Note that the elements will be converted to bytes based on the current setting of charEncoding.

  14. def body_=(nodes: NodeSeq): Unit

    Sets the body to the given elements.

    Sets the body to the given elements. Also sets the contentType to "text/xml"

    Note that the elements will be converted to bytes based on the current setting of charEncoding.

  15. def body_=(s: String, contentType: String): Unit

    Sets the body to the given string and content type.

    Sets the body to the given string and content type.

    Note that the String will be converted to bytes based on the current setting of charEncoding.

  16. def body_=(s: String): Unit

    Sets the body to the given string.

    Sets the body to the given string. The content type is set to "text/plain".

    Note that the String will be converted to bytes based on the current setting of charEncoding.

  17. var charEncoding: String

    The character encoding of the request.

    The character encoding of the request.

    Defaults to UTF-8. Note that this differs from the default encoding per the HTTP spec (ISO-8859-1), so you will need to change this if you need something other than UTF-8.

  18. def clone(): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  19. def computeRealPath(path: String): String

    Compute the path portion after the contextPath

  20. var contentType: String

  21. var contextPath: String

    The context path for this request.

    The context path for this request. Defaults to "" per the Servlet API.

  22. var cookies: List[Cookie]

  23. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  24. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  25. def finalize(): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  26. def getAttribute(key: String): AnyRef

    Definition Classes
    MockHttpServletRequest → ServletRequest
  27. def getAttributeNames(): Enumeration[AnyRef]

    Definition Classes
    MockHttpServletRequest → ServletRequest
  28. def getAuthType(): String

    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  29. def getCharacterEncoding(): String

    Definition Classes
    MockHttpServletRequest → ServletRequest
  30. final def getClass(): java.lang.Class[_]

    Definition Classes
    AnyRef → Any
  31. def getContentLength(): Int

    Definition Classes
    MockHttpServletRequest → ServletRequest
  32. def getContentType(): String

    Definition Classes
    MockHttpServletRequest → ServletRequest
  33. def getContextPath(): String

    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  34. def getCookies(): Array[Cookie]

    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  35. def getDateHeader(h: String): Long

    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  36. def getHeader(h: String): String

    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  37. def getHeaderNames(): Enumeration[AnyRef]

    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  38. def getHeaders(s: String): Enumeration[AnyRef]

    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  39. def getInputStream(): ServletInputStream

    Definition Classes
    MockHttpServletRequest → ServletRequest
  40. def getIntHeader(h: String): Int

    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  41. def getLocalAddr(): String

    Definition Classes
    MockHttpServletRequest → ServletRequest
  42. def getLocalName(): String

    Definition Classes
    MockHttpServletRequest → ServletRequest
  43. def getLocalPort(): Int

    Definition Classes
    MockHttpServletRequest → ServletRequest
  44. def getLocale(): Locale

    Definition Classes
    MockHttpServletRequest → ServletRequest
  45. def getLocales(): Enumeration[AnyRef]

    Definition Classes
    MockHttpServletRequest → ServletRequest
  46. def getMethod(): String

    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  47. def getParameter(key: String): String

    Definition Classes
    MockHttpServletRequest → ServletRequest
  48. def getParameterMap(): Map[AnyRef, AnyRef]

    Definition Classes
    MockHttpServletRequest → ServletRequest
  49. def getParameterNames(): Enumeration[AnyRef]

    Definition Classes
    MockHttpServletRequest → ServletRequest
  50. def getParameterValues(key: String): Array[String]

    Definition Classes
    MockHttpServletRequest → ServletRequest
  51. def getPathInfo(): String

    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  52. def getPathTranslated(): String

    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  53. def getProtocol(): String

    Definition Classes
    MockHttpServletRequest → ServletRequest
  54. def getQueryString(): String

    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  55. def getReader(): BufferedReader

    Definition Classes
    MockHttpServletRequest → ServletRequest
  56. def getRealPath(s: String): String

    Definition Classes
    MockHttpServletRequest → ServletRequest
  57. def getRemoteAddr(): String

    Definition Classes
    MockHttpServletRequest → ServletRequest
  58. def getRemoteHost(): String

    Definition Classes
    MockHttpServletRequest → ServletRequest
  59. def getRemotePort(): Int

    Definition Classes
    MockHttpServletRequest → ServletRequest
  60. def getRemoteUser(): String

    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  61. def getRequestDispatcher(s: String): RequestDispatcher

    Definition Classes
    MockHttpServletRequest → ServletRequest
  62. def getRequestURI(): String

    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  63. def getRequestURL(): StringBuffer

    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  64. def getRequestedSessionId(): String

    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  65. def getScheme(): String

    Definition Classes
    MockHttpServletRequest → ServletRequest
  66. def getServerName(): String

    Definition Classes
    MockHttpServletRequest → ServletRequest
  67. def getServerPort(): Int

    Definition Classes
    MockHttpServletRequest → ServletRequest
  68. def getServletPath(): String

    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  69. def getSession(create: Boolean): HttpSession

    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  70. def getSession(): HttpSession

    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  71. def getUserPrincipal(): Principal

    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  72. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  73. var headers: Map[String, List[String]]

  74. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  75. def isRequestedSessionIdFromCookie(): Boolean

    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  76. def isRequestedSessionIdFromURL(): Boolean

    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  77. def isRequestedSessionIdFromUrl(): Boolean

    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  78. def isRequestedSessionIdValid(): Boolean

    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  79. def isSecure(): Boolean

    Definition Classes
    MockHttpServletRequest → ServletRequest
  80. def isUserInRole(user: String): Boolean

    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  81. var localAddr: String

    The local address that the request was received on.

    The local address that the request was received on.

    If you change this you should probably change localName and serverName as well.

  82. var localName: String

    The local hostname that the request was received on.

    The local hostname that the request was received on.

    If you change this you should probably change localAddr and serverName as well.

  83. var localPort: Int

    The port that this request was received on.

    The port that this request was received on. You should probably change serverPort as well if you change this.

  84. var locales: List[Locale]

    The preferred locales for the client, in decreasing order of preference.

    The preferred locales for the client, in decreasing order of preference. If not set, the default locale will be used.

  85. var method: String

  86. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  87. final def notify(): Unit

    Definition Classes
    AnyRef
  88. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  89. var parameters: List[(String, String)]

    The query parameters for the request.

    The query parameters for the request. There are two main ways to set this List, either by modifying the parameters var directly, or by assigning to queryString, which will parse the provided string into GET parameters.

  90. var path: String

  91. var pathInfo: String

  92. def processUrl(url: URL): Unit

    Set fields based on the given URL.

    Set fields based on the given URL. There are several limitations:

    • The host portion is used to set localAddr, localHost and serverName. You will need to manually set these if you want different behavior.
    • The userinfo field isn't processed. If you want to mock BASIC authentication, use the addBasicAuth method
    url

    The URL to extract from

  93. def processUrl(url: String): Unit

    Set fields based on the given url string.

    Set fields based on the given url string. If the url begins with "http" it is assumed to be a full URL, and is processed with processUrl(URL). If the url begins with "/" then it's assumed to be only the path and query string.

    url

    The URL to extract from

  94. var protocol: String

  95. def queryString: String

  96. def queryString_=(q: String): Unit

  97. var remoteAddr: String

    The address of the client that sent the request.

    The address of the client that sent the request.

    If you change this you should probably change remoteHost as well.

  98. var remoteHost: String

    The hostname of the client that sent the request.

    The hostname of the client that sent the request.

    If you change this you should probably change remoteAddr as well.

  99. var remotePort: Int

  100. def removeAttribute(key: String): Unit

    Definition Classes
    MockHttpServletRequest → ServletRequest
  101. var requestUri: String

  102. var scheme: String

  103. var secure: Boolean

    Indicates whether the request is being handled by a secure protocol (e.

    Indicates whether the request is being handled by a secure protocol (e.g. HTTPS). If you set the scheme to https you should set this to true.

  104. var serverName: String

  105. var serverPort: Int

    The port that this request was received on.

    The port that this request was received on. You should probably change localPort as well if you change this.

  106. var servletPath: String

  107. var session: HttpSession

  108. def setAttribute(key: String, value: AnyRef): Unit

    Definition Classes
    MockHttpServletRequest → ServletRequest
  109. def setCharacterEncoding(enc: String): Unit

    Definition Classes
    MockHttpServletRequest → ServletRequest
  110. def setDateHeader(s: String, l: Long): Unit

    A utility method to set the given header to an RFC1123 date based on the given long value (epoch seconds).

  111. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  112. def toString(): String

    Definition Classes
    AnyRef → Any
  113. val url: String

    The URL to extract from

  114. var user: String

  115. var userPrincipal: Principal

  116. var userRoles: Set[String]

  117. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  118. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  119. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()

Deprecated Value Members

  1. def attr: Map[String, AnyRef]

    Annotations
    @deprecated
    Deprecated

    (Since version 2.4) Use the "attributes" var instead

  2. def attr_=(attrs: Map[String, AnyRef]): Unit

    Annotations
    @deprecated
    Deprecated

    (Since version 2.4) Use the "attributes" var instead

  3. def parameterMap: Map[String, String]

    Annotations
    @deprecated
    Deprecated

    (Since version 2.4) Use the "parameters" var instead

  4. def parameterMap_=(params: Map[String, List[String]]): Unit

    Annotations
    @deprecated
    Deprecated

    (Since version 2.4) Use the "parameters" var instead

Inherited from HttpServletRequest

Inherited from ServletRequest

Inherited from AnyRef

Inherited from Any