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:

go to: companion
linear super types: 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
Impl.
  1. Concrete
  2. Abstract

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 =, contextPath: String =)

    url

    The URL to extract from

    contextPath

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

Value Members

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

    attributes: final
    definition classes: AnyRef
  2. def != (arg0: Any) : Boolean

    o != arg0 is the same as !(o == (arg0)).

    o != arg0 is the same as !(o == (arg0)).

    arg0

    the object to compare against this object for dis-equality.

    returns

    false if the receiver object is equivalent to the argument; true otherwise.

    attributes: final
    definition classes: Any
  3. def ## () : Int

    attributes: final
    definition classes: AnyRef → Any
  4. def $asInstanceOf [T0] () : T0

    attributes: final
    definition classes: AnyRef
  5. def $isInstanceOf [T0] () : Boolean

    attributes: final
    definition classes: AnyRef
  6. def == (arg0: AnyRef) : Boolean

    o == arg0 is the same as if (o eq null) arg0 eq null else o.equals(arg0).

    o == arg0 is the same as if (o eq null) arg0 eq null else o.equals(arg0).

    arg0

    the object to compare against this object for equality.

    returns

    true if the receiver object is equivalent to the argument; false otherwise.

    attributes: final
    definition classes: AnyRef
  7. def == (arg0: Any) : Boolean

    o == arg0 is the same as o.equals(arg0).

    o == arg0 is the same as o.equals(arg0).

    arg0

    the object to compare against this object for equality.

    returns

    true if the receiver object is equivalent to the argument; false otherwise.

    attributes: final
    definition classes: Any
  8. def addBasicAuth (user: String, pass: String) : Unit

    Adds an "Authorization" header, per RFC1945.

    Adds an "Authorization" header, per RFC1945.

  9. def asInstanceOf [T0] : T0

    This method is used to cast the receiver object to be of type T0.

    This method is used to cast the receiver object to be of type T0.

    Note that the success of a cast at runtime is modulo Scala's erasure semantics. Therefore the expression1.asInstanceOf[String] will throw a ClassCastException at runtime, while the expressionList(1).asInstanceOf[List[String]] will not. In the latter example, because the type argument is erased as part of compilation it is not possible to check whether the contents of the list are of the requested typed.

    returns

    the receiver object.

    attributes: final
    definition classes: Any
  10. def attr : Map[String, AnyRef]

      deprecated:
    1. Use the "attributes" var instead

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

      deprecated:
    1. Use the "attributes" var instead

  12. var attributes : Map[String, AnyRef]

  13. var authType : String

  14. var body : Array[Byte]

    The raw body of the request.

    The raw body of the request.

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

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

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

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

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

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

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

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

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

  22. def clone () : AnyRef

    This method creates and returns a copy of the receiver object.

    This method creates and returns a copy of the receiver object.

    The default implementation of the clone method is platform dependent.

    returns

    a copy of the receiver object.

    attributes: protected
    definition classes: AnyRef
  23. def computeRealPath (path: String) : String

    Compute the path portion after the contextPath

    Compute the path portion after the contextPath

  24. var contentType : String

  25. var contextPath : String

    The context path for this request.

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

  26. var cookies : List[Cookie]

  27. def eq (arg0: AnyRef) : Boolean

    This method is used to test whether the argument (arg0) is a reference to the receiver object (this).

    This method is used to test whether the argument (arg0) is a reference to the receiver object (this).

    The eq method implements an [http://en.wikipedia.org/wiki/Equivalence_relation equivalence relation] on non-null instances of AnyRef: * It is reflexive: for any non-null instance x of type AnyRef, x.eq(x) returns true. * It is symmetric: for any non-null instances x and y of type AnyRef, x.eq(y) returns true if and only if y.eq(x) returns true. * It is transitive: for any non-null instances x, y, and z of type AnyRef if x.eq(y) returns true and y.eq(z) returns true, then x.eq(z) returns true.

    Additionally, the eq method has three other properties. * It is consistent: for any non-null instances x and y of type AnyRef, multiple invocations of x.eq(y) consistently returns true or consistently returns false. * For any non-null instance x of type AnyRef, x.eq(null) and null.eq(x) returns false. * null.eq(null) returns true.

    When overriding the equals or hashCode methods, it is important to ensure that their behavior is consistent with reference equality. Therefore, if two objects are references to each other (o1 eq o2), they should be equal to each other (o1 == o2) and they should hash to the same value (o1.hashCode == o2.hashCode).

    arg0

    the object to compare against this object for reference equality.

    returns

    true if the argument is a reference to the receiver object; false otherwise.

    attributes: final
    definition classes: AnyRef
  28. def equals (arg0: Any) : Boolean

    This method is used to compare the receiver object (this) with the argument object (arg0) for equivalence.

    This method is used to compare the receiver object (this) with the argument object (arg0) for equivalence.

    The default implementations of this method is an [http://en.wikipedia.org/wiki/Equivalence_relation equivalence relation]: * It is reflexive: for any instance x of type Any, x.equals(x) should return true. * It is symmetric: for any instances x and y of type Any, x.equals(y) should return true if and only if y.equals(x) returns true. * It is transitive: for any instances x, y, and z of type AnyRef if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.

    If you override this method, you should verify that your implementation remains an equivalence relation. Additionally, when overriding this method it is often necessary to override hashCode to ensure that objects that are "equal" (o1.equals(o2) returns true) hash to the same scala.Int (o1.hashCode.equals(o2.hashCode)).

    arg0

    the object to compare against this object for equality.

    returns

    true if the receiver object is equivalent to the argument; false otherwise.

    definition classes: AnyRef → Any
  29. def finalize () : Unit

    This method is called by the garbage collector on the receiver object when garbage collection determines that there are no more references to the object.

    This method is called by the garbage collector on the receiver object when garbage collection determines that there are no more references to the object.

    The details of when and if the finalize method are invoked, as well as the interaction between finalizeand non-local returns and exceptions, are all platform dependent.

    attributes: protected
    definition classes: AnyRef
  30. def getAttribute (key: String) : AnyRef

    definition classes: MockHttpServletRequest → ServletRequest
  31. def getAttributeNames () : Enumeration[AnyRef]

    definition classes: MockHttpServletRequest → ServletRequest
  32. def getAuthType () : String

    definition classes: MockHttpServletRequest → HttpServletRequest
  33. def getCharacterEncoding () : String

    definition classes: MockHttpServletRequest → ServletRequest
  34. def getClass () : java.lang.Class[_]

    Returns a representation that corresponds to the dynamic class of the receiver object.

    Returns a representation that corresponds to the dynamic class of the receiver object.

    The nature of the representation is platform dependent.

    returns

    a representation that corresponds to the dynamic class of the receiver object.

    attributes: final
    definition classes: AnyRef
  35. def getContentLength () : Int

    definition classes: MockHttpServletRequest → ServletRequest
  36. def getContentType () : String

    definition classes: MockHttpServletRequest → ServletRequest
  37. def getContextPath () : String

    definition classes: MockHttpServletRequest → HttpServletRequest
  38. def getCookies () : Array[Cookie]

    definition classes: MockHttpServletRequest → HttpServletRequest
  39. def getDateHeader (h: String) : Long

    definition classes: MockHttpServletRequest → HttpServletRequest
  40. def getHeader (h: String) : String

    definition classes: MockHttpServletRequest → HttpServletRequest
  41. def getHeaderNames () : Enumeration[AnyRef]

    definition classes: MockHttpServletRequest → HttpServletRequest
  42. def getHeaders (s: String) : Enumeration[AnyRef]

    definition classes: MockHttpServletRequest → HttpServletRequest
  43. def getInputStream () : ServletInputStream

    definition classes: MockHttpServletRequest → ServletRequest
  44. def getIntHeader (h: String) : Int

    definition classes: MockHttpServletRequest → HttpServletRequest
  45. def getLocalAddr () : String

    definition classes: MockHttpServletRequest → ServletRequest
  46. def getLocalName () : String

    definition classes: MockHttpServletRequest → ServletRequest
  47. def getLocalPort () : Int

    definition classes: MockHttpServletRequest → ServletRequest
  48. def getLocale () : Locale

    definition classes: MockHttpServletRequest → ServletRequest
  49. def getLocales () : Enumeration[AnyRef]

    definition classes: MockHttpServletRequest → ServletRequest
  50. def getMethod () : String

    definition classes: MockHttpServletRequest → HttpServletRequest
  51. def getParameter (key: String) : String

    definition classes: MockHttpServletRequest → ServletRequest
  52. def getParameterMap () : Map[AnyRef, AnyRef]

    definition classes: MockHttpServletRequest → ServletRequest
  53. def getParameterNames () : Enumeration[AnyRef]

    definition classes: MockHttpServletRequest → ServletRequest
  54. def getParameterValues (key: String) : Array[String]

    definition classes: MockHttpServletRequest → ServletRequest
  55. def getPathInfo () : String

    definition classes: MockHttpServletRequest → HttpServletRequest
  56. def getPathTranslated () : String

    definition classes: MockHttpServletRequest → HttpServletRequest
  57. def getProtocol () : String

    definition classes: MockHttpServletRequest → ServletRequest
  58. def getQueryString () : String

    definition classes: MockHttpServletRequest → HttpServletRequest
  59. def getReader () : BufferedReader

    definition classes: MockHttpServletRequest → ServletRequest
  60. def getRealPath (s: String) : String

    definition classes: MockHttpServletRequest → ServletRequest
  61. def getRemoteAddr () : String

    definition classes: MockHttpServletRequest → ServletRequest
  62. def getRemoteHost () : String

    definition classes: MockHttpServletRequest → ServletRequest
  63. def getRemotePort () : Int

    definition classes: MockHttpServletRequest → ServletRequest
  64. def getRemoteUser () : String

    definition classes: MockHttpServletRequest → HttpServletRequest
  65. def getRequestDispatcher (s: String) : RequestDispatcher

    definition classes: MockHttpServletRequest → ServletRequest
  66. def getRequestURI () : String

    definition classes: MockHttpServletRequest → HttpServletRequest
  67. def getRequestURL () : StringBuffer

    definition classes: MockHttpServletRequest → HttpServletRequest
  68. def getRequestedSessionId () : String

    definition classes: MockHttpServletRequest → HttpServletRequest
  69. def getScheme () : String

    definition classes: MockHttpServletRequest → ServletRequest
  70. def getServerName () : String

    definition classes: MockHttpServletRequest → ServletRequest
  71. def getServerPort () : Int

    definition classes: MockHttpServletRequest → ServletRequest
  72. def getServletPath () : String

    definition classes: MockHttpServletRequest → HttpServletRequest
  73. def getSession (create: Boolean) : HttpSession

    definition classes: MockHttpServletRequest → HttpServletRequest
  74. def getSession () : HttpSession

    definition classes: MockHttpServletRequest → HttpServletRequest
  75. def getUserPrincipal () : Principal

    definition classes: MockHttpServletRequest → HttpServletRequest
  76. def hashCode () : Int

    Returns a hash code value for the object.

    Returns a hash code value for the object.

    The default hashing algorithm is platform dependent.

    Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)) yet not be equal (o1.equals(o2) returns false). A degenerate implementation could always return 0. However, it is required that if two objects are equal (o1.equals(o2) returns true) that they have identical hash codes (o1.hashCode.equals(o2.hashCode)). Therefore, when overriding this method, be sure to verify that the behavior is consistent with the equals method.

    returns

    the hash code value for the object.

    definition classes: AnyRef → Any
  77. var headers : Map[String, List[String]]

  78. def isInstanceOf [T0] : Boolean

    This method is used to test whether the dynamic type of the receiver object is T0.

    This method is used to test whether the dynamic type of the receiver object is T0.

    Note that the test result of the test is modulo Scala's erasure semantics. Therefore the expression1.isInstanceOf[String] will return false, while the expression List(1).isInstanceOf[List[String]] will return true. In the latter example, because the type argument is erased as part of compilation it is not possible to check whether the contents of the list are of the requested typed.

    returns

    true if the receiver object is an instance of erasure of type T0; false otherwise.

    attributes: final
    definition classes: Any
  79. def isRequestedSessionIdFromCookie () : Boolean

    definition classes: MockHttpServletRequest → HttpServletRequest
  80. def isRequestedSessionIdFromURL () : Boolean

    definition classes: MockHttpServletRequest → HttpServletRequest
  81. def isRequestedSessionIdFromUrl () : Boolean

    definition classes: MockHttpServletRequest → HttpServletRequest
  82. def isRequestedSessionIdValid () : Boolean

    definition classes: MockHttpServletRequest → HttpServletRequest
  83. def isSecure () : Boolean

    definition classes: MockHttpServletRequest → ServletRequest
  84. def isUserInRole (user: String) : Boolean

    definition classes: MockHttpServletRequest → HttpServletRequest
  85. 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.

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

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

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

  89. var method : String

  90. def ne (arg0: AnyRef) : Boolean

    o.ne(arg0) is the same as !(o.eq(arg0)).

    o.ne(arg0) is the same as !(o.eq(arg0)).

    arg0

    the object to compare against this object for reference dis-equality.

    returns

    false if the argument is not a reference to the receiver object; true otherwise.

    attributes: final
    definition classes: AnyRef
  91. def notify () : Unit

    Wakes up a single thread that is waiting on the receiver object's monitor.

    Wakes up a single thread that is waiting on the receiver object's monitor.

    attributes: final
    definition classes: AnyRef
  92. def notifyAll () : Unit

    Wakes up all threads that are waiting on the receiver object's monitor.

    Wakes up all threads that are waiting on the receiver object's monitor.

    attributes: final
    definition classes: AnyRef
  93. def parameterMap : Map[String, String]

      deprecated:
    1. Use the "parameters" var instead

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

      deprecated:
    1. Use the "parameters" var instead

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

  96. var path : String

  97. var pathInfo : String

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

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

  100. var protocol : String

  101. def queryString : String

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

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

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

  105. var remotePort : Int

  106. def removeAttribute (key: String) : Unit

    definition classes: MockHttpServletRequest → ServletRequest
  107. var requestUri : String

  108. var scheme : String

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

  110. var serverName : String

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

  112. var servletPath : String

  113. var session : HttpSession

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

    definition classes: MockHttpServletRequest → ServletRequest
  115. def setCharacterEncoding (enc: String) : Unit

    definition classes: MockHttpServletRequest → ServletRequest
  116. 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).

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

  117. def synchronized [T0] (arg0: T0) : T0

    attributes: final
    definition classes: AnyRef
  118. def toString () : String

    Returns a string representation of the object.

    Returns a string representation of the object.

    The default representation is platform dependent.

    returns

    a string representation of the object.

    definition classes: AnyRef → Any
  119. val url : String

    The URL to extract from

    The URL to extract from

  120. var user : String

  121. var userPrincipal : Principal

  122. var userRoles : Set[String]

  123. def wait () : Unit

    attributes: final
    definition classes: AnyRef
  124. def wait (arg0: Long, arg1: Int) : Unit

    attributes: final
    definition classes: AnyRef
  125. def wait (arg0: Long) : Unit

    attributes: final
    definition classes: AnyRef

Inherited from HttpServletRequest

Inherited from ServletRequest

Inherited from AnyRef

Inherited from Any