I want to create a fake session on my junit test but i can't...
I have some methods protect by @With to protect each method, the value to acces to the methods protected by @With is on the session,
on the the session if the value of "member_running=1" and "project_running=1" the function addBacklog work and the http status is 200, ifelse the http status is 401 ( Unauthorized )
on this exemple i want to create a session test
@Test
public void testSession() {
running(fakeApplication(), new Runnable() {
public void run() {
session.put("member_running","1");
session.put("project_running","1");
Result res = route(fakeRequest("GET", "/")
.method("POST")
//.session("member_running","1")
//.session("project_running","1")
.session(session)
.uri(routes.ProductBacklogController.addBacklog("MyName","MyPriority","MyFirstEstimate","MyDescription").url()));
assertEquals("This is not the page addBacklog","/projectus/backlog/add/MyName/MyPriority/MyFirstEstimate/MyDescription", request.uri());
assertEquals("The page should be work", 200, res.status());
}
});
}
On my reserach i found the method .withSession("key","value") and he doesn't work, i've try to replace this with just .session("key,"value) ( like the exemple above)
Now i have try to use se session of res with :
res.session();
but it return : {}
And
res.status();
return : 401 because the session is not used.
the session contains :
{connected=true, lastName=Crenn, firstName=Thomas, nav=open, member_running=1, project=[{"project":"ProjectUS","project_id":1,"members":[{"member":"DEVELOPER","member_id":2},{"member":"ADMINISTRATOR","member_id":3},{"member":"PRODUCT_OWNER","member_id":4},{"member":"SCRUM_MASTER","member_id":5}]},{"project":"ScrumBadass","project_id":2,"members":[{"member":"SCRUM_MASTER","member_id":9},{"member":"DEVELOPER","member_id":10}]}], cip=2, project_running=1}
And for information the version of play framework is 2.5
Aucun commentaire:
Enregistrer un commentaire