Skip to content

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

@spring-projects-issues

Description

@spring-projects-issues

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

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions