From 2748f2b8eba22264408f2a05725810b58e80649d Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 10 Oct 2012 16:10:49 -0400 Subject: [PATCH] Remove deprecated methods in spring-test-mvc --- .../client/match/MockRestRequestMatchers.java | 46 ------------- .../response/MockRestResponseCreators.java | 67 ------------------- 2 files changed, 113 deletions(-) diff --git a/spring-test-mvc/src/main/java/org/springframework/test/web/mock/client/match/MockRestRequestMatchers.java b/spring-test-mvc/src/main/java/org/springframework/test/web/mock/client/match/MockRestRequestMatchers.java index 5cf8e986a6..ae4aea7441 100644 --- a/spring-test-mvc/src/main/java/org/springframework/test/web/mock/client/match/MockRestRequestMatchers.java +++ b/spring-test-mvc/src/main/java/org/springframework/test/web/mock/client/match/MockRestRequestMatchers.java @@ -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 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()); - } - }; - } - } diff --git a/spring-test-mvc/src/main/java/org/springframework/test/web/mock/client/response/MockRestResponseCreators.java b/spring-test-mvc/src/main/java/org/springframework/test/web/mock/client/response/MockRestResponseCreators.java index 8ad41971d2..27af73a079 100644 --- a/spring-test-mvc/src/main/java/org/springframework/test/web/mock/client/response/MockRestResponseCreators.java +++ b/spring-test-mvc/src/main/java/org/springframework/test/web/mock/client/response/MockRestResponseCreators.java @@ -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, ""); - } - }