use of org.springframework.test.web.client.RequestMatcher in project spring-framework by spring-projects.
the class ContentRequestMatchers method contentType.
/**
* Assert the request content type as a {@link MediaType}.
*/
public RequestMatcher contentType(final MediaType expectedContentType) {
return new RequestMatcher() {
@Override
public void match(ClientHttpRequest request) throws IOException, AssertionError {
MediaType actualContentType = request.getHeaders().getContentType();
assertTrue("Content type not set", actualContentType != null);
assertEquals("Content type", expectedContentType, actualContentType);
}
};
}
use of org.springframework.test.web.client.RequestMatcher in project spring-framework by spring-projects.
the class ContentRequestMatchers method bytes.
/**
* Compare the body of the request to the given byte array.
*/
public RequestMatcher bytes(final byte[] expectedContent) {
return new RequestMatcher() {
@Override
public void match(ClientHttpRequest request) throws IOException, AssertionError {
MockClientHttpRequest mockRequest = (MockClientHttpRequest) request;
assertEquals("Request content", expectedContent, mockRequest.getBodyAsBytes());
}
};
}
Aggregations