Hi,

I don't know how this could help because I've been away from lift code
for a long time. But I remember that I tried to use mocks with JMock
and specs in order to specify the "example" site (\liftweb\sites
\example\src\test\scala\net\liftweb\example\snippet).

The idea was to simulate a session:

inSession {
 // do your test here
}

This works with the following code (see the WikiSpec.scala file):

========================
class MockRequest extends Specification with JMocker with ClassMocker
{
  var request: Req = mock[Req]
  var httpRequest: HttpServletRequest = mock[HttpServletRequest]
  var session: LiftSession = mock[LiftSession]
  def createMocks = {
    request = mock[Req]
    httpRequest = mock[HttpServletRequest]
    session = mock[LiftSession]
    expect {
      0.atLeastOf(httpRequest).getCookies
      0.atLeastOf(request).request.willReturn(httpRequest)
    }
  }
  def inSession(f: => Any) {
    S.init(request, session) {
      f
    }
  }
  def unsetParameter(name: String) {
    expect {
      0.atLeastOf(request).param(equal(name)).willReturn(None)
    }
  }
  def setParameter(name: String, value: String) {
    expect {
      0.atLeastOf(request).param(equal(name)).willReturn(Some(value))
    }
  }
}

========================

Unfortunately, I remember that we had compilation issues when
upgrading to scala-2.7.2 and as a result, most of the code is
commented out.

I've recently started to integrate Mockito and Powermock to specs and
that may prove a decent way to support unit testing using "S" methods.

Eric.



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

Reply via email to