Java Play Framework 1.2.x unit testing send cookie -


I am working with Java on Play Framework 1.2.x In one of my unit tests, I want to send cookie information as part of my functional testing case. I have tried the code below but it is not working. Once in the controller, I read the cookie, it is getting empty.

Any thoughts that I remember here?

  cookie cookie = new cookie (); cookie.name = "testTimeZone"; Cookie.value = "-330"; Cookie.maxAge = 30000; Request.cookies.put (cookie name, cookie); Feedback = ApplicationTest.POST (Request, URL, empty, empty);    

OK, here's how it has been solved. I found that this is a bug in Play 1.2.x. Therefore, I have implemented the functional test class provided by the overriding framework on spreading it and post method.

Added this code to the override POST method

  if (savedCookies! = Empty) {// savedCookies is in the FunalTest class (if request.cookies! = Null) {Request.cookies.putAll (savedCookies); } Other {request.cookies = saved cookies; }}   

and then use this extended class in my testcases.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -