Skip to content

Mocking MockMultipartFile no longer working in 5.3.2 #26324

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

Closed
austinarbor opened this issue Dec 29, 2020 · 6 comments
Closed

Mocking MockMultipartFile no longer working in 5.3.2 #26324

austinarbor opened this issue Dec 29, 2020 · 6 comments
Labels
status: duplicate A duplicate of another issue

Comments

@austinarbor
Copy link

austinarbor commented Dec 29, 2020

Mocking a MockMultipartFile does not work in multipart request in spring-test 5.3.2
Affects: spring-test 5.3.2

See sample project here

If you check out the test, you can see I am spying a MockMultipartFile to force it to throw an IOException on getInputstream() here

This works fine in spring-test 5.3.1 but does not work in 5.3.2. I confirmed this by excluding spring-test from spring-boot-starter-test and directly importing spring-test 5.3.1, which resolves the issue.

Throwing a breakpoint in the controller method you can see that the MockMultipartFile is not a mock when on 5.3.2

Possibly caused by d82cb15 as fix for #26166

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Dec 29, 2020
@snicoll snicoll changed the title (spring-test) Mocking MockMultipartFile not Working in 5.3.2 Mocking MockMultipartFile not longer working in 5.3.2 Dec 29, 2020
@austinarbor austinarbor changed the title Mocking MockMultipartFile not longer working in 5.3.2 Mocking MockMultipartFile no longer working in 5.3.2 Dec 29, 2020
@rstoyanchev
Copy link
Contributor

This is a duplicate of #26261. I tried with the sample and switching to 5.3.3 snapshots makes the test pass.

@rstoyanchev rstoyanchev added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jan 4, 2021
@austinarbor
Copy link
Author

austinarbor commented Jan 4, 2021

@rstoyanchev i tried adding https://repo.spring.io/snapshot/ to the build.gradle but can't seem to get 5.3.3-SNAPSHOT imported. is there anything else i need to do?

@rstoyanchev
Copy link
Contributor

I also added:

ext['spring-framework.version'] = "5.3.3-SNAPSHOT"

@austinarbor
Copy link
Author

austinarbor commented Jan 5, 2021

Looks like using http instead of https in the repo URL was my problem. Confirming bug is fixed in 5.3.3-SNAPSHOT

@izeye
Copy link
Contributor

izeye commented Jan 8, 2021

This seems to be meant to be closed with the "status: duplicate" label.

@snicoll
Copy link
Member

snicoll commented Jan 8, 2021

Thanks for the nudge Johnny.

@snicoll snicoll closed this as completed Jan 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

5 participants