Closed
Description
Oliver Drotbohm opened SPR-11424 and commented
The status()
method of MockMvcResultMatchers
exposes a method per status code. This works fine if I want to express a particular code expected.
However, if I want to express a certain type of code (e.g. 1xx, 2xx etc.) I have to fall back to something like this:
….andExpect(status().is(both(greaterThanOrEqualTo(200)).and(lessThan(300))));
A short
–.andExpect(status().inRangeSuccess()); // expecting 2xx
would be easier to write and read. The method could also be named isSuccess()
but I think it might make sense to clearly separate the range check methods from the ones checking for an individual status code.
Affects: 4.0.1
Metadata
Metadata
Assignees
Labels
Type
Projects
Relationships
Development
No branches or pull requests
Activity
spring-projects-issues commentedon Feb 13, 2014
Rossen Stoyanchev commented
Sounds good. HttpStatus has the Series enum along those lines. We could add a method for each of them. How about:
spring-projects-issues commentedon Mar 10, 2014
Balakrishnan commented
In the newly added methods, the order of parameters in assert seems to be reversed.
Also, would it be possible to add these helper methods in org.springframework.http.HttpStatus also? That would be quite helpful.
spring-projects-issues commentedon Mar 12, 2014
Rossen Stoyanchev commented
thanks see these two commits.