java - Session does not get saved while doing Junit test in JavaPlay -


i implementing login authentication in app using this tutorial.

here authentication function :

public result authenticate() {     form<login> loginform = formfactory.form(login.class).bindfromrequest();     if(loginform.haserrors()){         return badrequest(login.render(loginform));     }else{         session().clear();         session(str_email, loginform.get().email);         return redirect(                 routes.application.index()         );     } } 

i storing e-mail of user in session.

while doing tests not able session in result. here code test :

@test public void authenticatesuccess() throws ioexception {     //setup     map<string,string> objectnode = new hashmap<>();     objectnode.put("email",configuration.getstring(config_login_email));     objectnode.put("password",configuration.getstring(config_login_pd));      //test     result result = invokewithcontext(fakerequest("post","login").bodyform(objectnode), () ->                     application.authenticate()     );      //verify     assert.assertequals(303, result.status());     logger.info(string.valueof(result.session())); *--> session empty } 

it redirected index page status of result matches session not saved. can problem here ?


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -