Changes because HttpMethod changed to class
This commit contains changes made because HttpMethod changed from enum to class. See gh-27697
This commit is contained in:
@@ -28,8 +28,8 @@ import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map.Entry;
|
||||
@@ -129,7 +129,7 @@ public class HttpHeadersTests {
|
||||
|
||||
@Test
|
||||
void allow() {
|
||||
EnumSet<HttpMethod> methods = EnumSet.of(HttpMethod.GET, HttpMethod.POST);
|
||||
Set<HttpMethod> methods = new LinkedHashSet<>(Arrays.asList(HttpMethod.GET, HttpMethod.POST));
|
||||
headers.setAllow(methods);
|
||||
assertThat(headers.getAllow()).as("Invalid Allow header").isEqualTo(methods);
|
||||
assertThat(headers.getFirst("Allow")).as("Invalid Allow header").isEqualTo("GET,POST");
|
||||
|
||||
@@ -268,6 +268,7 @@ public class InterceptingClientHttpRequestFactoryTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getMethodValue() {
|
||||
return method.name();
|
||||
}
|
||||
|
||||
@@ -25,9 +25,9 @@ import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -62,8 +62,8 @@ public class ClientHttpConnectorTests {
|
||||
|
||||
private static final int BUF_SIZE = 1024;
|
||||
|
||||
private static final EnumSet<HttpMethod> METHODS_WITH_BODY =
|
||||
EnumSet.of(HttpMethod.PUT, HttpMethod.POST, HttpMethod.PATCH);
|
||||
private static final Set<HttpMethod> METHODS_WITH_BODY =
|
||||
Set.of(HttpMethod.PUT, HttpMethod.POST, HttpMethod.PATCH);
|
||||
|
||||
private final MockWebServer server = new MockWebServer();
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import java.lang.annotation.Target;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
@@ -275,7 +274,7 @@ class RestTemplateIntegrationTests extends AbstractMockWebServerTests {
|
||||
setUpClient(clientHttpRequestFactory);
|
||||
|
||||
Set<HttpMethod> allowed = template.optionsForAllow(new URI(baseUrl + "/get"));
|
||||
assertThat(allowed).as("Invalid response").isEqualTo(EnumSet.of(HttpMethod.GET, HttpMethod.OPTIONS, HttpMethod.HEAD, HttpMethod.TRACE));
|
||||
assertThat(allowed).as("Invalid response").isEqualTo(Set.of(HttpMethod.GET, HttpMethod.OPTIONS, HttpMethod.HEAD, HttpMethod.TRACE));
|
||||
}
|
||||
|
||||
@ParameterizedRestTemplateTest
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -580,7 +579,7 @@ class RestTemplateTests {
|
||||
mockSentRequest(OPTIONS, "https://example.com");
|
||||
mockResponseStatus(HttpStatus.OK);
|
||||
HttpHeaders responseHeaders = new HttpHeaders();
|
||||
EnumSet<HttpMethod> expected = EnumSet.of(GET, POST);
|
||||
Set<HttpMethod> expected = Set.of(GET, POST);
|
||||
responseHeaders.setAllow(expected);
|
||||
given(response.getHeaders()).willReturn(responseHeaders);
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.time.Duration;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
@@ -75,16 +74,6 @@ public class HiddenHttpMethodFilterTests {
|
||||
assertThat(this.filterChain.getHttpMethod()).isEqualTo(HttpMethod.DELETE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filterWithInvalidMethodValue() {
|
||||
StepVerifier.create(postForm("_method=INVALID"))
|
||||
.consumeErrorWith(error -> {
|
||||
assertThat(error).isInstanceOf(IllegalArgumentException.class);
|
||||
assertThat(error.getMessage()).isEqualTo("HttpMethod 'INVALID' not supported");
|
||||
})
|
||||
.verify();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filterWithHttpPut() {
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpRequest;
|
||||
import org.springframework.http.server.ServletServerHttpRequest;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
@@ -680,6 +681,12 @@ class UriComponentsBuilderTests {
|
||||
void fromHttpRequestWithEmptyScheme() {
|
||||
HttpRequest request = new HttpRequest() {
|
||||
@Override
|
||||
public HttpMethod getMethod() {
|
||||
return HttpMethod.GET;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getMethodValue() {
|
||||
return "GET";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user