How would you fake a session value in functional test in Play Framework 1.2.3?
I'm doing a simple test like:
Before running the test, I set up a blank session, hoping it will make part of the test:
@Before public void setupHTTP() { Session.current.set(new Session()); }
@Test public void testRedirectToUserHomeForAuthenticatedUserWhenBlankAction() { authenticateUser("test@user.com"); Response response = GET("/user/blank"); assertRedirected(response, "/user/home"); }
The method
authenticate(String userEmail)just put the key "username" in the session map:
protected void authenticateUser(String userEmail) { // Put in session the email Session.current.get().put(USERNAME, userEmail); }
But the test runs in a different thread, as long as I could understand, and don't see the session I've set up...
How to fake session values in functional tests?