PUT method in playframework FunctionalTest

I wrote a small application using GAE and playframework.

I try to test the PUT method (used for updates) and when it is called from FunctionalTest it always returns with an account even though I log in at the beginning of the test, which can be confirmed all other methods work fine.

It seems that when using the PUT method, the session is lost

Has anyone had similar problems?

I am using play 1.1.1

+3
source share
1 answer

There seems to be a bug in FunctionalTest. In all methods (POST, GET, DELETE), the following line exists, which transfers cookies

if (savedCookies != null) request.cookies = savedCookies;

PUT. , savedCookies , .

, cookie , cookie , POST , cookie.

private static Map<String, Http.Cookie> lastCookies;

public void login(){
    String postUrl = Router.reverse("GAEActions.doLogin").url;
    Map<String, String> map = Maps.newHashMap();
    map.put("email", "as@gmail.com");
    map.put("url", "/");
    map.put("isAdmin", "true");
    Map<String, File> fileMap = Maps.newHashMap();
    Response post = POST(postUrl, map, fileMap);
    lastCookies = post.cookies;
}
public void test(){
....
    Request request = newRequest();
    request.cookies = lastCookies;
    Response post = PUT(request, url,"application/json",json);
+3

All Articles