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

add support for MockRestServiceServer to verify that a header does not exist [SPR-10771] #15397

Closed
spring-projects-issues opened this issue Jul 23, 2013 · 3 comments
Assignees
Labels
in: test Issues in the test module type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

John Mark opened SPR-10771 and commented

The current API for MockRestServiceServer and MockRestRequestMatchers does not allow a test to validate that a certain header value does not exist. Trying to do

.andExpect(header("Custom-Header", Matchers.nullValue()))

does not work because it requires the header to first exist, and then checks the Matcher. I would like to be able to so something like this:

.andExpect(header("Custom-Header").doesNotExist())

or something to that effect.

Unfortunately, I don't see any workaround for this until spring-test supports it. I was forced to use Mockito ArgumentCaptors in order to verify this requirement, but that meant that I couldn't use MockRestServiceServer.


Affects: 3.2.3

Referenced from: commits 4bf5a02

@spring-projects-issues
Copy link
Collaborator Author

Rossen Stoyanchev commented

Good point. If you've time to do so, send a pull request through. Thanks!

@yalmuhaidib
Copy link

using Spring Boot release version 1.5.22 (spring framework 4.3.25) and could not find how to validate if a request header does not exist in MockRestRequestMatchers.

@sbrannen
Copy link
Member

@bclozel, oops... you implemented that feature for MockMvc instead of MockRestServiceServer. 😉

I'll open a new issue to add similar support for MockRestServiceServer.

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 type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants