Req Mock support?

46 views
Skip to first unread message

Derek Chen-Becker

unread,
Jan 17, 2011, 10:30:04 AM1/17/11
to liftweb
I was thinking, it might be nice to have a MockWeb object that performed a lot of the wrapping I discussed in my latest post. Something like

object MockWeb {
  // Init S with a mock request using the given context path and uri
  def apply[T](contextPath : String, uri : String, queryString : String = "")(test : => T)

  // Same, but allow further modification of the backing mock request
  def apply[T](contextPath : String, uri : String, queryString : String = "")(initReq : MockHttpServletRequest => Unit)(test : => T)
}

Thoughts?

David Pollak

unread,
Jan 17, 2011, 10:54:27 AM1/17/11
to lif...@googlegroups.com

It's an expansion of https://www.assembla.com/spaces/liftweb/tickets/793-add-support-for-unit-testing-resthelper-without-full-jetty-lift-environment

Do you want to take over the ticket and do some great things with it?
 

--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.



--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Blog: http://goodstuff.im
Surf the harmonics

Derek Chen-Becker

unread,
Jan 17, 2011, 10:58:17 AM1/17/11
to lif...@googlegroups.com
Sure thing!




Derek Chen-Becker

unread,
Jan 17, 2011, 11:08:27 AM1/17/11
to lif...@googlegroups.com
So, in my example I'm using spring-mock because it's easy, but is that reasonable to add as a dependency? I'm thinking that this code would probably want to live in lift-testkit, or maybe some other module (not lift-webkit), so it would most likely only affect people's test scopes, but I could look into providing our own MockHTTPRequest (based on HTTPRequst) if there's a consensus against involving Spring.

Derek




On Jan 17, 2011 8:54 AM, David Pollak <feeder.of...@gmail.com> wrote:



David Pollak

unread,
Jan 17, 2011, 11:21:39 AM1/17/11
to lif...@googlegroups.com
I have a pretty strong aversion to bringing anything Spring into Lift.  I have a very, very low opinion of the Spring code quality and over-all design.

I thought Steve Jenson wrote some HTTP mocks back in the day.

Derek Chen-Becker

unread,
Jan 17, 2011, 11:27:12 AM1/17/11
to lif...@googlegroups.com
I'll take a look. I don't think it will be hard to write our own MockHTTPRequest.

Derek




Jeppe Nejsum Madsen

unread,
Jan 18, 2011, 4:47:44 AM1/18/11
to lif...@googlegroups.com
"Derek Chen-Becker" <dchen...@gmail.com> writes:

> So, in my example I'm using spring-mock because it's easy, but is that
> reasonable to add as a dependency?

How much functionality is needed in the Mocks? I've done basic mocking
with the Mockito framework supported by specs:

var httpRequest = mock[HTTPRequest]

httpRequest.method returns "GET"
httpRequest.uri returns "/context/"
httpRequest.contextPath returns "/context"
httpRequest.header(anyString()) returns None
httpRequest.sessionId returns None

var httpSession = mock[HTTPSession]

/Jeppe

Reply all
Reply to author
Forward
0 new messages