Remove deprecated HttpStatus codes
See gh-33809
This commit is contained in:
@@ -255,16 +255,6 @@ public class StatusResultMatchers {
|
||||
return matcher(HttpStatus.FOUND);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert the response status code is {@code HttpStatus.MOVED_TEMPORARILY} (302).
|
||||
* @see #isFound()
|
||||
* @deprecated in favor of {@link #isFound()}
|
||||
*/
|
||||
@Deprecated
|
||||
public ResultMatcher isMovedTemporarily() {
|
||||
return matcher(HttpStatus.MOVED_TEMPORARILY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert the response status code is {@code HttpStatus.SEE_OTHER} (303).
|
||||
*/
|
||||
@@ -279,15 +269,6 @@ public class StatusResultMatchers {
|
||||
return matcher(HttpStatus.NOT_MODIFIED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert the response status code is {@code HttpStatus.USE_PROXY} (305).
|
||||
* @deprecated matching the deprecation of {@code HttpStatus.USE_PROXY}
|
||||
*/
|
||||
@Deprecated
|
||||
public ResultMatcher isUseProxy() {
|
||||
return matcher(HttpStatus.USE_PROXY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert the response status code is {@code HttpStatus.TEMPORARY_REDIRECT} (307).
|
||||
*/
|
||||
@@ -401,16 +382,6 @@ public class StatusResultMatchers {
|
||||
return matcher(HttpStatus.PAYLOAD_TOO_LARGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert the response status code is {@code HttpStatus.REQUEST_ENTITY_TOO_LARGE} (413).
|
||||
* @see #isPayloadTooLarge()
|
||||
* @deprecated matching the deprecation of {@code HttpStatus.REQUEST_ENTITY_TOO_LARGE}
|
||||
*/
|
||||
@Deprecated
|
||||
public ResultMatcher isRequestEntityTooLarge() {
|
||||
return matcher(HttpStatus.REQUEST_ENTITY_TOO_LARGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert the response status code is {@code HttpStatus.REQUEST_URI_TOO_LONG} (414).
|
||||
* @since 4.1
|
||||
@@ -419,16 +390,6 @@ public class StatusResultMatchers {
|
||||
return matcher(HttpStatus.URI_TOO_LONG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert the response status code is {@code HttpStatus.REQUEST_URI_TOO_LONG} (414).
|
||||
* @see #isUriTooLong()
|
||||
* @deprecated matching the deprecation of {@code HttpStatus.REQUEST_URI_TOO_LONG}
|
||||
*/
|
||||
@Deprecated
|
||||
public ResultMatcher isRequestUriTooLong() {
|
||||
return matcher(HttpStatus.REQUEST_URI_TOO_LONG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert the response status code is {@code HttpStatus.UNSUPPORTED_MEDIA_TYPE} (415).
|
||||
*/
|
||||
@@ -457,33 +418,6 @@ public class StatusResultMatchers {
|
||||
return matcher(HttpStatus.valueOf(418));
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert the response status code is {@code HttpStatus.INSUFFICIENT_SPACE_ON_RESOURCE} (419).
|
||||
* @deprecated matching the deprecation of {@code HttpStatus.INSUFFICIENT_SPACE_ON_RESOURCE}
|
||||
*/
|
||||
@Deprecated
|
||||
public ResultMatcher isInsufficientSpaceOnResource() {
|
||||
return matcher(HttpStatus.INSUFFICIENT_SPACE_ON_RESOURCE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert the response status code is {@code HttpStatus.METHOD_FAILURE} (420).
|
||||
* @deprecated matching the deprecation of {@code HttpStatus.METHOD_FAILURE}
|
||||
*/
|
||||
@Deprecated
|
||||
public ResultMatcher isMethodFailure() {
|
||||
return matcher(HttpStatus.METHOD_FAILURE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert the response status code is {@code HttpStatus.DESTINATION_LOCKED} (421).
|
||||
* @deprecated matching the deprecation of {@code HttpStatus.DESTINATION_LOCKED}
|
||||
*/
|
||||
@Deprecated
|
||||
public ResultMatcher isDestinationLocked() {
|
||||
return matcher(HttpStatus.DESTINATION_LOCKED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert the response status code is {@code HttpStatus.UNPROCESSABLE_ENTITY} (422).
|
||||
*/
|
||||
|
||||
@@ -127,13 +127,6 @@ public enum HttpStatus implements HttpStatusCode {
|
||||
* @see <a href="https://tools.ietf.org/html/rfc7231#section-6.4.3">HTTP/1.1: Semantics and Content, section 6.4.3</a>
|
||||
*/
|
||||
FOUND(302, Series.REDIRECTION, "Found"),
|
||||
/**
|
||||
* {@code 302 Moved Temporarily}.
|
||||
* @see <a href="https://tools.ietf.org/html/rfc1945#section-9.3">HTTP/1.0, section 9.3</a>
|
||||
* @deprecated in favor of {@link #FOUND} which will be returned from {@code HttpStatus.valueOf(302)}
|
||||
*/
|
||||
@Deprecated
|
||||
MOVED_TEMPORARILY(302, Series.REDIRECTION, "Moved Temporarily"),
|
||||
/**
|
||||
* {@code 303 See Other}.
|
||||
* @see <a href="https://tools.ietf.org/html/rfc7231#section-6.4.4">HTTP/1.1: Semantics and Content, section 6.4.4</a>
|
||||
@@ -144,13 +137,6 @@ public enum HttpStatus implements HttpStatusCode {
|
||||
* @see <a href="https://tools.ietf.org/html/rfc7232#section-4.1">HTTP/1.1: Conditional Requests, section 4.1</a>
|
||||
*/
|
||||
NOT_MODIFIED(304, Series.REDIRECTION, "Not Modified"),
|
||||
/**
|
||||
* {@code 305 Use Proxy}.
|
||||
* @see <a href="https://tools.ietf.org/html/rfc7231#section-6.4.5">HTTP/1.1: Semantics and Content, section 6.4.5</a>
|
||||
* @deprecated due to security concerns regarding in-band configuration of a proxy
|
||||
*/
|
||||
@Deprecated
|
||||
USE_PROXY(305, Series.REDIRECTION, "Use Proxy"),
|
||||
/**
|
||||
* {@code 307 Temporary Redirect}.
|
||||
* @see <a href="https://tools.ietf.org/html/rfc7231#section-6.4.7">HTTP/1.1: Semantics and Content, section 6.4.7</a>
|
||||
@@ -239,14 +225,6 @@ public enum HttpStatus implements HttpStatusCode {
|
||||
* HTTP/1.1: Semantics and Content, section 6.5.11</a>
|
||||
*/
|
||||
PAYLOAD_TOO_LARGE(413, Series.CLIENT_ERROR, "Payload Too Large"),
|
||||
/**
|
||||
* {@code 413 Request Entity Too Large}.
|
||||
* @see <a href="https://tools.ietf.org/html/rfc2616#section-10.4.14">HTTP/1.1, section 10.4.14</a>
|
||||
* @deprecated in favor of {@link #PAYLOAD_TOO_LARGE} which will be
|
||||
* returned from {@code HttpStatus.valueOf(413)}
|
||||
*/
|
||||
@Deprecated
|
||||
REQUEST_ENTITY_TOO_LARGE(413, Series.CLIENT_ERROR, "Request Entity Too Large"),
|
||||
/**
|
||||
* {@code 414 URI Too Long}.
|
||||
* @since 4.1
|
||||
@@ -254,13 +232,6 @@ public enum HttpStatus implements HttpStatusCode {
|
||||
* HTTP/1.1: Semantics and Content, section 6.5.12</a>
|
||||
*/
|
||||
URI_TOO_LONG(414, Series.CLIENT_ERROR, "URI Too Long"),
|
||||
/**
|
||||
* {@code 414 Request-URI Too Long}.
|
||||
* @see <a href="https://tools.ietf.org/html/rfc2616#section-10.4.15">HTTP/1.1, section 10.4.15</a>
|
||||
* @deprecated in favor of {@link #URI_TOO_LONG} which will be returned from {@code HttpStatus.valueOf(414)}
|
||||
*/
|
||||
@Deprecated
|
||||
REQUEST_URI_TOO_LONG(414, Series.CLIENT_ERROR, "Request-URI Too Long"),
|
||||
/**
|
||||
* {@code 415 Unsupported Media Type}.
|
||||
* @see <a href="https://tools.ietf.org/html/rfc7231#section-6.5.13">
|
||||
@@ -283,27 +254,6 @@ public enum HttpStatus implements HttpStatusCode {
|
||||
* @see <a href="https://tools.ietf.org/html/rfc2324#section-2.3.2">HTCPCP/1.0</a>
|
||||
*/
|
||||
I_AM_A_TEAPOT(418, Series.CLIENT_ERROR, "I'm a teapot"),
|
||||
/**
|
||||
* @deprecated See
|
||||
* <a href="https://tools.ietf.org/rfcdiff?difftype=--hwdiff&url2=draft-ietf-webdav-protocol-06.txt">
|
||||
* WebDAV Draft Changes</a>
|
||||
*/
|
||||
@Deprecated
|
||||
INSUFFICIENT_SPACE_ON_RESOURCE(419, Series.CLIENT_ERROR, "Insufficient Space On Resource"),
|
||||
/**
|
||||
* @deprecated See
|
||||
* <a href="https://tools.ietf.org/rfcdiff?difftype=--hwdiff&url2=draft-ietf-webdav-protocol-06.txt">
|
||||
* WebDAV Draft Changes</a>
|
||||
*/
|
||||
@Deprecated
|
||||
METHOD_FAILURE(420, Series.CLIENT_ERROR, "Method Failure"),
|
||||
/**
|
||||
* @deprecated
|
||||
* See <a href="https://tools.ietf.org/rfcdiff?difftype=--hwdiff&url2=draft-ietf-webdav-protocol-06.txt">
|
||||
* WebDAV Draft Changes</a>
|
||||
*/
|
||||
@Deprecated
|
||||
DESTINATION_LOCKED(421, Series.CLIENT_ERROR, "Destination Locked"),
|
||||
/**
|
||||
* {@code 422 Unprocessable Entity}.
|
||||
* @see <a href="https://tools.ietf.org/html/rfc4918#section-11.2">WebDAV</a>
|
||||
@@ -551,17 +501,6 @@ public enum HttpStatus implements HttpStatusCode {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@code Series} enum constant for the supplied {@code HttpStatus}.
|
||||
* @param status a standard HTTP status enum constant
|
||||
* @return the {@code Series} enum constant for the supplied {@code HttpStatus}
|
||||
* @deprecated as of 5.3, in favor of invoking {@link HttpStatus#series()} directly
|
||||
*/
|
||||
@Deprecated
|
||||
public static Series valueOf(HttpStatus status) {
|
||||
return status.series;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@code Series} enum constant for the supplied status code.
|
||||
* @param statusCode the HTTP status code (potentially non-standard)
|
||||
|
||||
@@ -17,19 +17,12 @@
|
||||
package org.springframework.http;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.params.provider.Arguments.arguments;
|
||||
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
@@ -62,7 +55,6 @@ class HttpStatusTests {
|
||||
statusCodes.put(302, "FOUND");
|
||||
statusCodes.put(303, "SEE_OTHER");
|
||||
statusCodes.put(304, "NOT_MODIFIED");
|
||||
statusCodes.put(305, "USE_PROXY");
|
||||
statusCodes.put(307, "TEMPORARY_REDIRECT");
|
||||
statusCodes.put(308, "PERMANENT_REDIRECT");
|
||||
|
||||
@@ -85,9 +77,6 @@ class HttpStatusTests {
|
||||
statusCodes.put(416, "REQUESTED_RANGE_NOT_SATISFIABLE");
|
||||
statusCodes.put(417, "EXPECTATION_FAILED");
|
||||
statusCodes.put(418, "I_AM_A_TEAPOT");
|
||||
statusCodes.put(419, "INSUFFICIENT_SPACE_ON_RESOURCE");
|
||||
statusCodes.put(420, "METHOD_FAILURE");
|
||||
statusCodes.put(421, "DESTINATION_LOCKED");
|
||||
statusCodes.put(422, "UNPROCESSABLE_ENTITY");
|
||||
statusCodes.put(423, "LOCKED");
|
||||
statusCodes.put(424, "FAILED_DEPENDENCY");
|
||||
@@ -127,9 +116,6 @@ class HttpStatusTests {
|
||||
void fromEnumToMap() {
|
||||
for (HttpStatus status : HttpStatus.values()) {
|
||||
int code = status.value();
|
||||
if (DEPRECATED_CODES.contains(status)) {
|
||||
continue;
|
||||
}
|
||||
assertThat(statusCodes).as("Map has no value for [" + code + "]").containsKey(code);
|
||||
assertThat(status.name()).as("Invalid name for [" + code + "]").isEqualTo(statusCodes.get(code));
|
||||
}
|
||||
@@ -144,34 +130,4 @@ class HttpStatusTests {
|
||||
}
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "[{index}] code {0}")
|
||||
@MethodSource("codesWithAliases")
|
||||
void codeWithDeprecatedAlias(int code, HttpStatus expected, HttpStatus outdated) {
|
||||
HttpStatus resolved = HttpStatus.valueOf(code);
|
||||
assertThat(resolved)
|
||||
.as("HttpStatus.valueOf(" + code + ")")
|
||||
.isSameAs(expected)
|
||||
.isNotEqualTo(outdated);
|
||||
assertThat(outdated.isSameCodeAs(resolved))
|
||||
.as("outdated isSameCodeAs(resolved)")
|
||||
.isTrue();
|
||||
assertThat(outdated.value())
|
||||
.as("outdated value()")
|
||||
.isEqualTo(resolved.value());
|
||||
}
|
||||
|
||||
private static final Set<HttpStatus> DEPRECATED_CODES = codesWithAliases()
|
||||
.stream()
|
||||
.map(args -> (HttpStatus) args.get()[2])
|
||||
.collect(Collectors.toUnmodifiableSet());
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
static List<Arguments> codesWithAliases() {
|
||||
return List.of(
|
||||
arguments(302, HttpStatus.FOUND, HttpStatus.MOVED_TEMPORARILY),
|
||||
arguments(413, HttpStatus.PAYLOAD_TOO_LARGE, HttpStatus.REQUEST_ENTITY_TOO_LARGE),
|
||||
arguments(414, HttpStatus.URI_TOO_LONG, HttpStatus.REQUEST_URI_TOO_LONG)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user