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:
@@ -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;
|
||||
|
||||
@@ -89,7 +88,7 @@ public class DefaultEntityResponseBuilderTests {
|
||||
String body = "foo";
|
||||
EntityResponse<String> result =
|
||||
EntityResponse.fromObject(body).allow(HttpMethod.GET).build();
|
||||
Set<HttpMethod> expected = EnumSet.of(HttpMethod.GET);
|
||||
Set<HttpMethod> expected = Set.of(HttpMethod.GET);
|
||||
assertThat(result.headers().getAllow()).isEqualTo(expected);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionStage;
|
||||
|
||||
@@ -156,7 +156,7 @@ public class DefaultServerResponseBuilderTests {
|
||||
@Test
|
||||
public void allow() {
|
||||
ServerResponse response = ServerResponse.ok().allow(HttpMethod.GET).build();
|
||||
assertThat(response.headers().getAllow()).isEqualTo(EnumSet.of(HttpMethod.GET));
|
||||
assertThat(response.headers().getAllow()).isEqualTo(Set.of(HttpMethod.GET));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
import jakarta.servlet.ServletException;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -35,6 +35,7 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.ResourceHttpMessageConverter;
|
||||
import org.springframework.http.converter.ResourceRegionHttpMessageConverter;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.handler.PathPatternsTestUtils;
|
||||
import org.springframework.web.testfixture.servlet.MockHttpServletRequest;
|
||||
@@ -173,14 +174,16 @@ public class ResourceHandlerFunctionTests {
|
||||
|
||||
ServerResponse response = this.handlerFunction.handle(request);
|
||||
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));
|
||||
|
||||
MockHttpServletResponse servletResponse = new MockHttpServletResponse();
|
||||
ModelAndView mav = response.writeTo(servletRequest, servletResponse, this.context);
|
||||
assertThat(mav).isNull();
|
||||
|
||||
assertThat(servletResponse.getStatus()).isEqualTo(200);
|
||||
assertThat(servletResponse.getHeader("Allow")).isEqualTo("GET,HEAD,OPTIONS");
|
||||
String allowHeader = servletResponse.getHeader("Allow");
|
||||
String[] methods = StringUtils.tokenizeToStringArray(allowHeader, ",");
|
||||
assertThat(methods).containsExactlyInAnyOrder("GET","HEAD","OPTIONS");
|
||||
byte[] actualBytes = servletResponse.getContentAsByteArray();
|
||||
assertThat(actualBytes.length).isEqualTo(0);
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ package org.springframework.web.servlet.mvc.method.annotation;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import jakarta.servlet.ServletException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -102,7 +102,7 @@ public class ResponseEntityExceptionHandlerTests {
|
||||
Exception ex = new HttpRequestMethodNotSupportedException("GET", supported);
|
||||
|
||||
ResponseEntity<Object> responseEntity = testException(ex);
|
||||
assertThat(responseEntity.getHeaders().getAllow()).isEqualTo(EnumSet.of(HttpMethod.POST, HttpMethod.DELETE));
|
||||
assertThat(responseEntity.getHeaders().getAllow()).isEqualTo(Set.of(HttpMethod.POST, HttpMethod.DELETE));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user