c

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:

  • getRequestDispatcher - returns null always
  • getRequestedSessionId - always returns null. The related isRequestedSessionId... methods similarly all return false
  • getRealPath - simply returns the input string
Linear Supertypes
HttpServletRequest, ServletRequest, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. MockHttpServletRequest
  2. HttpServletRequest
  3. ServletRequest
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
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: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def addBasicAuth(user: String, pass: String): Unit

    Adds an "Authorization" header, per RFC1945.

  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. var attributes: Map[String, AnyRef]
  7. var authType: String
  8. def authenticate(resp: HttpServletResponse): Boolean
    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  9. var body: Array[Byte]

    The raw body of the request.

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

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

  11. 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"

  12. 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.

  13. 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.

  14. 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.

  15. 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.

  16. def changeSessionId(): String
    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  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[java.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
  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[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  26. def getAsyncContext(): AsyncContext
    Definition Classes
    MockHttpServletRequest → ServletRequest
  27. def getAttribute(key: String): AnyRef
    Definition Classes
    MockHttpServletRequest → ServletRequest
  28. def getAttributeNames(): Enumeration[String]
    Definition Classes
    MockHttpServletRequest → ServletRequest
  29. def getAuthType(): String
    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  30. def getCharacterEncoding(): String
    Definition Classes
    MockHttpServletRequest → ServletRequest
  31. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
  32. def getContentLength(): Int
    Definition Classes
    MockHttpServletRequest → ServletRequest
  33. def getContentLengthLong(): Long
    Definition Classes
    MockHttpServletRequest → ServletRequest
  34. def getContentType(): String
    Definition Classes
    MockHttpServletRequest → ServletRequest
  35. def getContextPath(): String
    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  36. def getCookies(): Array[Cookie]
    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  37. def getDateHeader(h: String): Long
    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  38. def getDispatcherType(): DispatcherType
    Definition Classes
    MockHttpServletRequest → ServletRequest
  39. def getHeader(h: String): String
    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  40. def getHeaderNames(): Enumeration[String]
    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  41. def getHeaders(s: String): Enumeration[String]
    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  42. def getInputStream(): ServletInputStream
    Definition Classes
    MockHttpServletRequest → ServletRequest
  43. def getIntHeader(h: String): Int
    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  44. def getLocalAddr(): String
    Definition Classes
    MockHttpServletRequest → ServletRequest
  45. def getLocalName(): String
    Definition Classes
    MockHttpServletRequest → ServletRequest
  46. def getLocalPort(): Int
    Definition Classes
    MockHttpServletRequest → ServletRequest
  47. def getLocale(): Locale
    Definition Classes
    MockHttpServletRequest → ServletRequest
  48. def getLocales(): Enumeration[Locale]
    Definition Classes
    MockHttpServletRequest → ServletRequest
  49. def getMethod(): String
    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  50. def getParameter(key: String): String
    Definition Classes
    MockHttpServletRequest → ServletRequest
  51. def getParameterMap(): Map[String, Array[String]]
    Definition Classes
    MockHttpServletRequest → ServletRequest
  52. def getParameterNames(): Enumeration[String]
    Definition Classes
    MockHttpServletRequest → ServletRequest
  53. def getParameterValues(key: String): Array[String]
    Definition Classes
    MockHttpServletRequest → ServletRequest
  54. def getPart(partName: String): Part
    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  55. def getParts(): Collection[Part]
    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  56. def getPathInfo(): String
    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  57. def getPathTranslated(): String
    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  58. def getProtocol(): String
    Definition Classes
    MockHttpServletRequest → ServletRequest
  59. def getQueryString(): String
    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  60. def getReader(): BufferedReader
    Definition Classes
    MockHttpServletRequest → ServletRequest
  61. def getRealPath(s: String): String
    Definition Classes
    MockHttpServletRequest → ServletRequest
  62. def getRemoteAddr(): String
    Definition Classes
    MockHttpServletRequest → ServletRequest
  63. def getRemoteHost(): String
    Definition Classes
    MockHttpServletRequest → ServletRequest
  64. def getRemotePort(): Int
    Definition Classes
    MockHttpServletRequest → ServletRequest
  65. def getRemoteUser(): String
    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  66. def getRequestDispatcher(s: String): RequestDispatcher
    Definition Classes
    MockHttpServletRequest → ServletRequest
  67. def getRequestURI(): String
    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  68. def getRequestURL(): StringBuffer
    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  69. def getRequestedSessionId(): String
    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  70. def getScheme(): String
    Definition Classes
    MockHttpServletRequest → ServletRequest
  71. def getServerName(): String
    Definition Classes
    MockHttpServletRequest → ServletRequest
  72. def getServerPort(): Int
    Definition Classes
    MockHttpServletRequest → ServletRequest
  73. def getServletContext(): ServletContext
    Definition Classes
    MockHttpServletRequest → ServletRequest
  74. def getServletPath(): String
    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  75. def getSession(create: Boolean): HttpSession
    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  76. def getSession(): HttpSession
    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  77. def getUserPrincipal(): Principal
    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  78. def hashCode(): Int
    Definition Classes
    AnyRef → Any
  79. var headers: Map[String, List[String]]
  80. def isAsyncStarted(): Boolean
    Definition Classes
    MockHttpServletRequest → ServletRequest
  81. def isAsyncSupported(): Boolean
    Definition Classes
    MockHttpServletRequest → ServletRequest
  82. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  83. def isRequestedSessionIdFromCookie(): Boolean
    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  84. def isRequestedSessionIdFromURL(): Boolean
    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  85. def isRequestedSessionIdFromUrl(): Boolean
    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  86. def isRequestedSessionIdValid(): Boolean
    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  87. def isSecure(): Boolean
    Definition Classes
    MockHttpServletRequest → ServletRequest
  88. def isUserInRole(user: String): Boolean
    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  89. 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.

  90. 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.

  91. 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.

  92. 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.

  93. def login(username: String, password: String): Unit
    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  94. def logout(): Unit
    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  95. var method: String
  96. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  97. final def notify(): Unit
    Definition Classes
    AnyRef
  98. final def notifyAll(): Unit
    Definition Classes
    AnyRef
  99. 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.

  100. var path: String
  101. var pathInfo: String
  102. 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

  103. 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

  104. var protocol: String
  105. def queryString: String
  106. def queryString_=(q: String): Unit
  107. 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.

  108. 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.

  109. var remotePort: Int
  110. def removeAttribute(key: String): Unit
    Definition Classes
    MockHttpServletRequest → ServletRequest
  111. var requestUri: String
  112. var scheme: String
  113. var secure: Boolean

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

    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.

  114. var serverName: String
  115. 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.

  116. var servletPath: String
  117. var session: HttpSession
  118. def setAttribute(key: String, value: AnyRef): Unit
    Definition Classes
    MockHttpServletRequest → ServletRequest
  119. def setCharacterEncoding(enc: String): Unit
    Definition Classes
    MockHttpServletRequest → ServletRequest
  120. 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).

  121. def startAsync(): AsyncContext
    Definition Classes
    MockHttpServletRequest → ServletRequest
  122. def startAsync(request: ServletRequest, response: ServletResponse): AsyncContext
    Definition Classes
    MockHttpServletRequest → ServletRequest
  123. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  124. def toString(): String
    Definition Classes
    AnyRef → Any
  125. def upgrade[T <: HttpUpgradeHandler](arg0: Class[T]): T
    Definition Classes
    MockHttpServletRequest → HttpServletRequest
  126. val url: String
  127. var user: String
  128. var userPrincipal: Principal
  129. var userRoles: Set[String]
  130. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  131. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  132. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from HttpServletRequest

Inherited from ServletRequest

Inherited from AnyRef

Inherited from Any

Ungrouped