Skip to content

Testing Java file upload with bodyRaw is resulting in a null body #12518

Answered by mkurz
caitlinshk asked this question in Q&A
Discussion options

You must be logged in to vote

Hi Caitlin,

your test code is wrong, you mix Play Scala code with Play Java code.
I set up a repo with your exact code to reproduce the problem, see the commits here: https://github.com/mkurz/playframework-discussion-12518/commits/main/
The second commit adds your code above.
The third commit makes the test work: If you clone the repo and run sbt test you will see it will succeed.

This is what I changed: mkurz/playframework-discussion-12518@259ffaf

  • You did not provide the adminImportView so I had to work around that.
  • I think the mistake you made is to mix Play Scala code into your Play Java test:
    -        Result result = controller.importProgram(request.build());
    +        Result result =…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by mkurz
Comment options

You must be logged in to vote
1 reply
@mkurz
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants