mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-25 08:19:01 +00:00
Polishing
See gh-35861
This commit is contained in:
@@ -17,9 +17,7 @@
|
||||
package org.springframework.test.http;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@@ -43,9 +41,6 @@ import org.springframework.http.HttpHeaders;
|
||||
*/
|
||||
public class HttpHeadersAssert extends AbstractObjectAssert<HttpHeadersAssert, HttpHeaders> {
|
||||
|
||||
private static final ZoneId GMT = ZoneOffset.UTC;
|
||||
|
||||
|
||||
private final AbstractCollectionAssert<?, Collection<? extends String>, String, ObjectAssert<String>> namesAssert;
|
||||
|
||||
|
||||
@@ -174,7 +169,7 @@ public class HttpHeadersAssert extends AbstractObjectAssert<HttpHeadersAssert, H
|
||||
containsHeader(name);
|
||||
Assertions.assertThat(this.actual.getFirstZonedDateTime(name))
|
||||
.as("check primary date value for HTTP header '%s'", name)
|
||||
.isCloseTo(value.atZone(GMT), Assertions.within(999, ChronoUnit.MILLIS));
|
||||
.isCloseTo(value.atZone(ZoneOffset.UTC), Assertions.within(999, ChronoUnit.MILLIS));
|
||||
return this.myself;
|
||||
}
|
||||
|
||||
|
||||
+5
-9
@@ -22,7 +22,6 @@ import java.io.InputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Arrays;
|
||||
@@ -98,9 +97,6 @@ import static org.springframework.web.servlet.HandlerMapping.PRODUCIBLE_MEDIA_TY
|
||||
*/
|
||||
class HttpEntityMethodProcessorMockTests {
|
||||
|
||||
private static final ZoneId GMT = ZoneOffset.UTC;
|
||||
|
||||
|
||||
private HttpEntityMethodProcessor processor;
|
||||
|
||||
private HttpMessageConverter<String> stringHttpMessageConverter = mock();
|
||||
@@ -477,7 +473,7 @@ class HttpEntityMethodProcessorMockTests {
|
||||
void shouldHandleLastModifiedWithHttp304() throws Exception {
|
||||
long currentTime = new Date().getTime();
|
||||
long oneMinuteAgo = currentTime - (1000 * 60);
|
||||
ZonedDateTime dateTime = ofEpochMilli(currentTime).atZone(GMT);
|
||||
ZonedDateTime dateTime = ofEpochMilli(currentTime).atZone(ZoneOffset.UTC);
|
||||
servletRequest.addHeader(HttpHeaders.IF_MODIFIED_SINCE, RFC_1123_DATE_TIME.format(dateTime));
|
||||
ResponseEntity<String> returnValue = ResponseEntity.ok().lastModified(oneMinuteAgo).body("body");
|
||||
|
||||
@@ -537,7 +533,7 @@ class HttpEntityMethodProcessorMockTests {
|
||||
long currentTime = new Date().getTime();
|
||||
long oneMinuteAgo = currentTime - (1000 * 60);
|
||||
String etagValue = "\"deadb33f8badf00d\"";
|
||||
ZonedDateTime dateTime = ofEpochMilli(currentTime).atZone(GMT);
|
||||
ZonedDateTime dateTime = ofEpochMilli(currentTime).atZone(ZoneOffset.UTC);
|
||||
servletRequest.addHeader(HttpHeaders.IF_MODIFIED_SINCE, RFC_1123_DATE_TIME.format(dateTime));
|
||||
servletRequest.addHeader(HttpHeaders.IF_NONE_MATCH, etagValue);
|
||||
ResponseEntity<String> returnValue = ResponseEntity.ok()
|
||||
@@ -569,7 +565,7 @@ class HttpEntityMethodProcessorMockTests {
|
||||
long oneMinuteAgo = currentTime - (1000 * 60);
|
||||
String etagValue = "\"deadb33f8badf00d\"";
|
||||
String changedEtagValue = "\"changed-etag-value\"";
|
||||
ZonedDateTime dateTime = ofEpochMilli(currentTime).atZone(GMT);
|
||||
ZonedDateTime dateTime = ofEpochMilli(currentTime).atZone(ZoneOffset.UTC);
|
||||
servletRequest.addHeader(HttpHeaders.IF_MODIFIED_SINCE, RFC_1123_DATE_TIME.format(dateTime));
|
||||
servletRequest.addHeader(HttpHeaders.IF_NONE_MATCH, etagValue);
|
||||
ResponseEntity<String> returnValue = ResponseEntity.ok()
|
||||
@@ -625,7 +621,7 @@ class HttpEntityMethodProcessorMockTests {
|
||||
void shouldHandleIfNoneMatchIfUnmodifiedSince() throws Exception {
|
||||
String etagValue = "\"some-etag\"";
|
||||
servletRequest.addHeader(HttpHeaders.IF_NONE_MATCH, etagValue);
|
||||
ZonedDateTime dateTime = ofEpochMilli(new Date().getTime()).atZone(GMT);
|
||||
ZonedDateTime dateTime = ofEpochMilli(new Date().getTime()).atZone(ZoneOffset.UTC);
|
||||
servletRequest.addHeader(HttpHeaders.IF_UNMODIFIED_SINCE, RFC_1123_DATE_TIME.format(dateTime));
|
||||
ResponseEntity<String> returnValue = ResponseEntity.ok().eTag(etagValue).body("body");
|
||||
|
||||
@@ -732,7 +728,7 @@ class HttpEntityMethodProcessorMockTests {
|
||||
@Test
|
||||
void shouldNotFailPreconditionForPutRequests() throws Exception {
|
||||
servletRequest.setMethod("PUT");
|
||||
ZonedDateTime dateTime = ofEpochMilli(new Date().getTime()).atZone(GMT);
|
||||
ZonedDateTime dateTime = ofEpochMilli(new Date().getTime()).atZone(ZoneOffset.UTC);
|
||||
servletRequest.addHeader(HttpHeaders.IF_UNMODIFIED_SINCE, RFC_1123_DATE_TIME.format(dateTime));
|
||||
|
||||
long justModified = dateTime.plusSeconds(1).toEpochSecond() * 1000;
|
||||
|
||||
Reference in New Issue
Block a user