Skip to content
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

Improve support for custom HTTP verbs in Spring MVC Test [SPR-13719] #18292

Closed
spring-projects-issues opened this issue Nov 24, 2015 · 5 comments
Assignees
Labels
in: test Issues in the test module in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Nov 24, 2015

Kamill Sokol opened SPR-13719 and commented

In Spring MVC we can build web applications using custom http verbs.
Unfortunately, Spring MVC Test only supports GET, POST, HEAD, OPTIONS, PUT, PATCH, DELETE, TRACE and file upload.

If we want to test custom http verbs we have to duplicate most of the code due to the strict design.

In my opinion, custom http verbs won't be needed very often and hence it shouldn't be backed into Spring MVC Test. Rather it should be partly open for extension.

Proposal

Add constructor to MockHttpServletRequestBuilder that supports http method as a string parameter. With this addition in place we can build http requests with arbitrary verbs.
One can think of extending MockMvcRequestBuilders, too. API might look like this:

MockMvcRequestBuilders.request(String httpMethod, String urlTemplate, Object... urlVariables)

I leave it open for discussion whether MockMvcRequestBuilders has to be changed, too.

If requested, I can contribute code to the Spring Github repository.

-This Jira issues relates to SPR-10426-
This Jira issues relates to #9476.


Affects: 4.2.3

Issue Links:

@spring-projects-issues
Copy link
Collaborator Author

Rossen Stoyanchev commented

Sure feel free to submit a pull request. Having a starting place with an initial proposal would be helpful.

@spring-projects-issues
Copy link
Collaborator Author

Kamill Sokol commented

Sure. I created a Pull Request for review.

@spring-projects-issues
Copy link
Collaborator Author

Rossen Stoyanchev commented

Thanks.

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Dec 28, 2015

Kamill Sokol commented

Due to resolved issue #9476 I switched to Spring 4.3.0.SNAPSHOT and run my test suite again. Actually, there is no need for a custom TestDispatcherServlet anymore. From my initial proposal only the third point remains open. At the moment we can not use custom HTTP verbs in a Spring MVC Test. I removed point 1. and 2. from my initial proposal and updated my PR accordingly.

@spring-projects-issues
Copy link
Collaborator Author

Rossen Stoyanchev commented

Okay thanks for updating the issue and the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test Issues in the test module in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants