object MockWeb
The MockWeb object contains various methods to simplify unit testing in Lift outside of the full-blown testkit stack.
There is partial support for configuration defined in the LiftRules object. This includes:
- early
- statelessRewrite
- statelessTest
- statefulRewrite
- Alphabetic
- By Inheritance
- MockWeb
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
testReq[T](request: HttpServletRequest)(f: (Req) ⇒ T): T
Executes a given function against a new Req constructed from the given HttpServletRequest.
Executes a given function against a new Req constructed from the given HttpServletRequest. If useLiftRules is set to true, then LiftRules.early, LiftRules.statelessRewrite, and LiftRules.statelessTest rules are applied.
-
def
testReq[T](url: String, contextPath: String = "")(f: (Req) ⇒ T): T
Executes a given function against a new Req constructed from the given url/path String and contextPath.
Executes a given function against a new Req constructed from the given url/path String and contextPath. See MockHttpServletRequest.processUrl for details on the url String format, and see testReq(HttpServletRequest) for more details on how the Req is processed.
-
def
testS[T](request: HttpServletRequest)(testFunc: ⇒ T): T
Sets up S based on the provided request and a new session.
-
def
testS[T](request: HttpServletRequest, session: Box[LiftSession])(testFunc: ⇒ T): T
Sets up S based on the provided request and session.
Sets up S based on the provided request and session. You can use this method if you want to do special setup on the request outside of what is handled by the MockHttpServletRequest constructor, or if you want to use a different mock impl.
You can provide your own session if you want to simulate sharing a session across multiple requests. See testS(String,String,Box[LiftSession]) for an example of this use.
Note that if useLiftRules is set to true, then rules like LiftRules.early, LiftRules.statelessTest, etc, will be applied.
- request
The request to be used for this test
- session
The LiftSession to use for this request. Passing Empty will force creation of a new session
- testFunc
The function to be executed in the scope of a new S
-
def
testS[T](url: String, session: Box[LiftSession] = Empty, contextPath: String = "")(testFunc: ⇒ T): T
Sets up S based on the provided url, contextPath and session.
Sets up S based on the provided url, contextPath and session. You can provide your own session if you want to simulate sharing a session across multiple requests. For example:
object testVar extends SessionVar[String]("Empty") val testSession = testS("http://foo.com/test") { testVar("Foo!") S.session // returns the current session } // A second test testS("http://foo.com/test2", session = testSession) { testVar.is must_== "Foo!" }
- url
The url to use for this request. Can either be a full URL, or just the path and queryString. See MockHttpServletRequest.processUrl for more details
- session
The LiftSession to use for this request. If you don't provide one a new one will be created for you
- contextPath
The servlet context path for this request
- testFunc
The function to be executed in the scope of a new S
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
var
useLiftRulesGlobally: Boolean
Setting this var to
true
will force all tests to use LiftRules.Setting this var to
true
will force all tests to use LiftRules. See useLiftRules for more granular control. -
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
withSnippet[T](name: String, attrs: MetaData = Null)(f: ⇒ T): T
This is a utility method to allow you to set the S.currentSnippet method for testing.
This is a utility method to allow you to set the S.currentSnippet method for testing.
- name
The snippet name to be tested. For example, <lift:MyWidget.foo/> has a name of MyWidget.foo. You can retrieve this via
S.currentSnippet
orS.invokedAs
- attrs
The list of snippet tag attributes. Defaults to Null. See
S.attrs
for more details- f
The function to execute in the context of the emulated snippet
- object useLiftRules extends ThreadGlobal[Boolean]