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:
Arjen Poutsma
2021-11-25 13:45:34 +01:00
parent 6e335e3a9f
commit 7a4207cd7b
74 changed files with 337 additions and 274 deletions

View File

@@ -20,7 +20,6 @@ import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
@@ -100,7 +99,7 @@ public class DefaultEntityResponseBuilderTests {
public void allow() {
String body = "foo";
Mono<EntityResponse<String>> result = EntityResponse.fromObject(body).allow(HttpMethod.GET).build();
Set<HttpMethod> expected = EnumSet.of(HttpMethod.GET);
Set<HttpMethod> expected = Set.of(HttpMethod.GET);
StepVerifier.create(result)
.expectNextMatches(response -> expected.equals(response.headers().getAllow()))
.expectComplete()

View File

@@ -21,7 +21,6 @@ import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
@@ -198,7 +197,7 @@ public class DefaultServerResponseBuilderTests {
@Test
public void allow() {
Mono<ServerResponse> result = ServerResponse.ok().allow(HttpMethod.GET).build();
Set<HttpMethod> expected = EnumSet.of(HttpMethod.GET);
Set<HttpMethod> expected = Set.of(HttpMethod.GET);
StepVerifier.create(result)
.expectNextMatches(response -> expected.equals(response.headers().getAllow()))
.expectComplete()

View File

@@ -18,8 +18,8 @@ package org.springframework.web.reactive.function.server;
import java.io.IOException;
import java.nio.file.Files;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -141,7 +141,7 @@ public class ResourceHandlerFunctionTests {
Mono<ServerResponse> responseMono = this.handlerFunction.handle(request);
Mono<Void> result = responseMono.flatMap(response -> {
assertThat(response.statusCode()).isEqualTo(HttpStatus.OK);
assertThat(response.headers().getAllow()).isEqualTo(EnumSet.of(HttpMethod.GET, HttpMethod.HEAD, HttpMethod.OPTIONS));
assertThat(response.headers().getAllow()).isEqualTo(Set.of(HttpMethod.GET, HttpMethod.HEAD, HttpMethod.OPTIONS));
return response.writeTo(exchange, context);
});
@@ -150,7 +150,7 @@ public class ResourceHandlerFunctionTests {
.expectComplete()
.verify();
assertThat(mockResponse.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(mockResponse.getHeaders().getAllow()).isEqualTo(EnumSet.of(HttpMethod.GET, HttpMethod.HEAD, HttpMethod.OPTIONS));
assertThat(mockResponse.getHeaders().getAllow()).isEqualTo(Set.of(HttpMethod.GET, HttpMethod.HEAD, HttpMethod.OPTIONS));
StepVerifier.create(mockResponse.getBody()).expectComplete().verify();
}

View File

@@ -21,7 +21,6 @@ import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -141,7 +140,7 @@ public class RequestMappingInfoHandlerMappingTests {
Mono<Object> mono = this.handlerMapping.getHandler(exchange);
assertError(mono, MethodNotAllowedException.class,
ex -> assertThat(ex.getSupportedMethods()).isEqualTo(EnumSet.of(HttpMethod.GET, HttpMethod.HEAD)));
ex -> assertThat(ex.getSupportedMethods()).isEqualTo(Set.of(HttpMethod.GET, HttpMethod.HEAD)));
}
@Test // SPR-9603
@@ -194,11 +193,11 @@ public class RequestMappingInfoHandlerMappingTests {
List<HttpMethod> allMethodExceptTrace = new ArrayList<>(Arrays.asList(HttpMethod.values()));
allMethodExceptTrace.remove(HttpMethod.TRACE);
testHttpOptions("/foo", EnumSet.of(HttpMethod.GET, HttpMethod.HEAD, HttpMethod.OPTIONS), null);
testHttpOptions("/person/1", EnumSet.of(HttpMethod.PUT, HttpMethod.OPTIONS), null);
testHttpOptions("/persons", EnumSet.copyOf(allMethodExceptTrace), null);
testHttpOptions("/something", EnumSet.of(HttpMethod.PUT, HttpMethod.POST), null);
testHttpOptions("/qux", EnumSet.of(HttpMethod.PATCH,HttpMethod.GET,HttpMethod.HEAD,HttpMethod.OPTIONS),
testHttpOptions("/foo", Set.of(HttpMethod.GET, HttpMethod.HEAD, HttpMethod.OPTIONS), null);
testHttpOptions("/person/1", Set.of(HttpMethod.PUT, HttpMethod.OPTIONS), null);
testHttpOptions("/persons", Set.copyOf(allMethodExceptTrace), null);
testHttpOptions("/something", Set.of(HttpMethod.PUT, HttpMethod.POST), null);
testHttpOptions("/qux", Set.of(HttpMethod.PATCH,HttpMethod.GET,HttpMethod.HEAD,HttpMethod.OPTIONS),
new MediaType("foo", "bar"));
}