Remove deprecated methods in spring-test-mvc
This commit is contained in:
parent
e7a7f751b6
commit
2748f2b8eb
|
|
@ -214,50 +214,4 @@ public abstract class MockRestRequestMatchers {
|
|||
return new XpathRequestMatchers(expression, namespaces, args);
|
||||
}
|
||||
|
||||
|
||||
// Deprecated methods ..
|
||||
|
||||
/**
|
||||
* Expect that the specified request header contains a subtring
|
||||
*
|
||||
* @deprecated in favor of {@link #header(String, Matcher...)}
|
||||
*/
|
||||
public static RequestMatcher headerContains(final String header, final String substring) {
|
||||
Assert.notNull(header, "'header' must not be null");
|
||||
Assert.notNull(substring, "'substring' must not be null");
|
||||
return new RequestMatcher() {
|
||||
public void match(ClientHttpRequest request) throws AssertionError {
|
||||
List<String> actualHeaders = request.getHeaders().get(header);
|
||||
AssertionErrors.assertTrue("Expected header <" + header + "> in request", actualHeaders != null);
|
||||
|
||||
boolean foundMatch = false;
|
||||
for (String headerValue : actualHeaders) {
|
||||
if (headerValue.contains(substring)) {
|
||||
foundMatch = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
AssertionErrors.assertTrue("Expected value containing <" + substring + "> in header <" + header + ">",
|
||||
foundMatch);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect the given request body content.
|
||||
*
|
||||
* @deprecated in favor of {@link #content()} as well as {@code jsonPath(..)},
|
||||
* and {@code xpath(..)} methods in this class
|
||||
*/
|
||||
public static RequestMatcher body(final String body) {
|
||||
Assert.notNull(body, "'body' must not be null");
|
||||
return new RequestMatcher() {
|
||||
public void match(ClientHttpRequest request) throws AssertionError, IOException {
|
||||
MockClientHttpRequest mockRequest = (MockClientHttpRequest) request;
|
||||
AssertionErrors.assertEquals("Unexpected body content", body, mockRequest.getBodyAsString());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,71 +119,4 @@ public abstract class MockRestResponseCreators {
|
|||
return new DefaultResponseCreator(status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond with a given body, headers, status code, and status text.
|
||||
*
|
||||
* @param body the body of the response "UTF-8" encoded
|
||||
* @param headers the response headers
|
||||
* @param statusCode the response status code
|
||||
* @param statusText the response status text
|
||||
*
|
||||
* @deprecated in favor of methods returning DefaultResponseCreator
|
||||
*/
|
||||
public static ResponseCreator withResponse(final String body, final HttpHeaders headers,
|
||||
final HttpStatus statusCode, final String statusText) {
|
||||
|
||||
return new ResponseCreator() {
|
||||
public MockClientHttpResponse createResponse(ClientHttpRequest request) throws IOException {
|
||||
MockClientHttpResponse response = new MockClientHttpResponse(body.getBytes("UTF-8"), statusCode);
|
||||
response.getHeaders().putAll(headers);
|
||||
return response;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond with the given body, headers, and a status code of 200 (OK).
|
||||
*
|
||||
* @param body the body of the response "UTF-8" encoded
|
||||
* @param headers the response headers
|
||||
*
|
||||
* @deprecated in favor of methods 'withXyz' in this class returning DefaultResponseCreator
|
||||
*/
|
||||
public static ResponseCreator withResponse(String body, HttpHeaders headers) {
|
||||
return withResponse(body, headers, HttpStatus.OK, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond with a given body, headers, status code, and text.
|
||||
*
|
||||
* @param body a {@link Resource} containing the body of the response
|
||||
* @param headers the response headers
|
||||
* @param statusCode the response status code
|
||||
* @param statusText the response status text
|
||||
*
|
||||
* @deprecated in favor of methods 'withXyz' in this class returning DefaultResponseCreator
|
||||
*/
|
||||
public static ResponseCreator withResponse(final Resource body, final HttpHeaders headers,
|
||||
final HttpStatus statusCode, String statusText) {
|
||||
|
||||
return new ResponseCreator() {
|
||||
public MockClientHttpResponse createResponse(ClientHttpRequest request) throws IOException {
|
||||
MockClientHttpResponse response = new MockClientHttpResponse(body.getInputStream(), statusCode);
|
||||
response.getHeaders().putAll(headers);
|
||||
return response;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond with the given body, headers, and a status code of 200 (OK).
|
||||
* @param body the body of the response
|
||||
* @param headers the response headers
|
||||
*
|
||||
* @deprecated in favor of methods 'withXyz' in this class returning DefaultResponseCreator
|
||||
*/
|
||||
public static ResponseCreator withResponse(final Resource body, final HttpHeaders headers) {
|
||||
return withResponse(body, headers, HttpStatus.OK, "");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue