2

In Play 1.2.4, I've been trying to work out why my functional test doesn't appear to POST the file data correctly (it's null). The controller action I'm testing is:

doUploadProfileImage(@Required File file, User user) 

And the functional test code calls it like this:

File file = VirtualFile.fromRelativePath("/test/imagetest.jpg").getRealFile(); Map<String,String> params = new HashMap<String,String>(); params.put("user.id", user.id.toString()); Map<String,File> files = new HashMap<String,File>(); files.put("file", file); Response response = POST(Router.reverse("ImageController.doUploadProfileImage").url, params, files); 

When I step through in debug, everything seems ok before the POST, but when I reach "doUploadProfileImage()", the "file" parameter is NULL.

Any tips on what's going on here? What's an easy way to inspect/log received/raw POST data by the play server?

thanks in advance, SM

1
  • I wonder if this has anything to do with how play uploads tmp files, perhaps they're being deleted before the controller code runs. Will investigate soon and report back. Commented Jan 18, 2012 at 0:43

1 Answer 1

1

I found this problem also, after a few hours debug, just because this line is in my conf/application.conf for play-cobertura-module:

%test.play.tmp=none 

changed to:

%test.play.tmp=/tmp 

It works!

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.