-
Notifications
You must be signed in to change notification settings - Fork 38.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot test @RequestPart multipart controllers with Servlet MockPart #25829
Comments
|
Wouldn't this be ideal for a first contribution? I would be absolutely willing to fix this. |
I created a PR for this. This is one idea to solve the problem. Existing tests work and the mentioned problem is fixed (validated via test). I would love to get feedback for further PRs. |
I wonder if this isn't a duplicate of #25602? |
I confirm the example project works against master but fails with 5.2.x. |
It seems that it is. Sorry didn't find that issue. |
No worries, it's not very obvious and at the time I fixed it for the upcoming 5.3 only but this does show it would be beneficial to have a fix in 5.2.x as well. |
Tested with spring boot 2.3.4.
Example project
We have controller that receives some arguments that are parts of multipart request.
For running application request works as intended:
Now we want to test it:
But test is failing with NPE exception:
The reason behind that is
org.springframework.web.multipart.support.RequestPartServletServerHttpRequest:84
; it's expectingStandardMultipartHttpServletRequest
inmultipartRequest
field but gotMockMultipartHttpServletRequest
:The text was updated successfully, but these errors were encountered: