-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
HtmlUnitRequestBuilder
ignores file uploaded via HtmlFileInput.setData()
#27199
Comments
I think that use case will still exist, resulting in 3 use cases.
|
HtmlUnitRequestBuilder
ignores file uploaded via HtmlFileInput.setData()
Well, after diving into the implementation, it turns out you were right about that. 👍 I was able to support both of those use cases in a single I would be grateful if you could try out the fix in one of the upcoming 5.3.10 snapshots and let us know if everything works as expected. Cheers! |
I'd love to, but I'm not sure how. Where and when will these snapshots be available? |
Yes, seems to work! Great! |
Awesome! Thanks for letting us know. |
Prior to this commit, if the user tested file upload support with HtmlUnit and MockMvc by invoking HtmlFileInput.setData() instead of HtmlFileInput.setFiles(), the in-memory file data was simply ignored. This commit addresses this issue by creating a MockPart from the in-memory data in HtmlUnitRequestBuilder. Closes spring-projectsgh-27199
When testing an application using HtmlUnit, its often useful to use
HtmlFileInput.setData(...)
instead ofHtmlFileInput.setFiles(...)
in order to not have to generate temporary files. However, when usingMockMvcWebClientBuilder
, this doesn't work. The problem is thatHtmlUnitRequestBuilder
ignores the data part.#24926 added support for file uploads in
HtmlUnitRequestBuilder
, but missed this use case.Test case:
filesubmit.html:
FileSubmitController.java:
FileSubmitTest.java:
When starting the application normally and changing
WebClient
from a mocked version to a normal version using http://localhost:8080/ both tests succeed.I'm guessing in
HtmlUnitRequestBuilder.params(...)
, theelse
part should be something like this:I'm not sure if there is a specific edge case to use the old "mimic empty file upload" else case.
Tested using Spring Boot 2.5.2 using Spring WebMVC 5.3.8.
The text was updated successfully, but these errors were encountered: