Skip to content

Commit 2641b5d

Browse files
committed
1 parent dc0c463 commit 2641b5d

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

spring-test/src/main/java/org/springframework/test/http/HttpHeadersAssert.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
package org.springframework.test.http;
1818

1919
import java.time.Instant;
20-
import java.time.ZoneId;
2120
import java.time.ZoneOffset;
22-
import java.time.ZonedDateTime;
2321
import java.time.temporal.ChronoUnit;
2422
import java.util.Arrays;
2523
import java.util.Collection;
@@ -43,9 +41,6 @@
4341
*/
4442
public class HttpHeadersAssert extends AbstractObjectAssert<HttpHeadersAssert, HttpHeaders> {
4543

46-
private static final ZoneId GMT = ZoneOffset.UTC;
47-
48-
4944
private final AbstractCollectionAssert<?, Collection<? extends String>, String, ObjectAssert<String>> namesAssert;
5045

5146

@@ -174,7 +169,7 @@ public HttpHeadersAssert hasValue(String name, Instant value) {
174169
containsHeader(name);
175170
Assertions.assertThat(this.actual.getFirstZonedDateTime(name))
176171
.as("check primary date value for HTTP header '%s'", name)
177-
.isCloseTo(value.atZone(GMT), Assertions.within(999, ChronoUnit.MILLIS));
172+
.isCloseTo(value.atZone(ZoneOffset.UTC), Assertions.within(999, ChronoUnit.MILLIS));
178173
return this.myself;
179174
}
180175

spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessorMockTests.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.lang.reflect.Method;
2323
import java.net.URI;
2424
import java.nio.charset.StandardCharsets;
25-
import java.time.ZoneId;
2625
import java.time.ZoneOffset;
2726
import java.time.ZonedDateTime;
2827
import java.util.Arrays;
@@ -98,9 +97,6 @@
9897
*/
9998
class HttpEntityMethodProcessorMockTests {
10099

101-
private static final ZoneId GMT = ZoneOffset.UTC;
102-
103-
104100
private HttpEntityMethodProcessor processor;
105101

106102
private HttpMessageConverter<String> stringHttpMessageConverter = mock();
@@ -477,7 +473,7 @@ void shouldHandleResponseHeaderAndBody() throws Exception {
477473
void shouldHandleLastModifiedWithHttp304() throws Exception {
478474
long currentTime = new Date().getTime();
479475
long oneMinuteAgo = currentTime - (1000 * 60);
480-
ZonedDateTime dateTime = ofEpochMilli(currentTime).atZone(GMT);
476+
ZonedDateTime dateTime = ofEpochMilli(currentTime).atZone(ZoneOffset.UTC);
481477
servletRequest.addHeader(HttpHeaders.IF_MODIFIED_SINCE, RFC_1123_DATE_TIME.format(dateTime));
482478
ResponseEntity<String> returnValue = ResponseEntity.ok().lastModified(oneMinuteAgo).body("body");
483479

@@ -537,7 +533,7 @@ void shouldHandleETagAndLastModifiedWithHttp304() throws Exception {
537533
long currentTime = new Date().getTime();
538534
long oneMinuteAgo = currentTime - (1000 * 60);
539535
String etagValue = "\"deadb33f8badf00d\"";
540-
ZonedDateTime dateTime = ofEpochMilli(currentTime).atZone(GMT);
536+
ZonedDateTime dateTime = ofEpochMilli(currentTime).atZone(ZoneOffset.UTC);
541537
servletRequest.addHeader(HttpHeaders.IF_MODIFIED_SINCE, RFC_1123_DATE_TIME.format(dateTime));
542538
servletRequest.addHeader(HttpHeaders.IF_NONE_MATCH, etagValue);
543539
ResponseEntity<String> returnValue = ResponseEntity.ok()
@@ -569,7 +565,7 @@ void shouldHandleChangedETagAndLastModified() throws Exception {
569565
long oneMinuteAgo = currentTime - (1000 * 60);
570566
String etagValue = "\"deadb33f8badf00d\"";
571567
String changedEtagValue = "\"changed-etag-value\"";
572-
ZonedDateTime dateTime = ofEpochMilli(currentTime).atZone(GMT);
568+
ZonedDateTime dateTime = ofEpochMilli(currentTime).atZone(ZoneOffset.UTC);
573569
servletRequest.addHeader(HttpHeaders.IF_MODIFIED_SINCE, RFC_1123_DATE_TIME.format(dateTime));
574570
servletRequest.addHeader(HttpHeaders.IF_NONE_MATCH, etagValue);
575571
ResponseEntity<String> returnValue = ResponseEntity.ok()
@@ -625,7 +621,7 @@ void shouldHandleIfNoneMatchIfMatch() throws Exception {
625621
void shouldHandleIfNoneMatchIfUnmodifiedSince() throws Exception {
626622
String etagValue = "\"some-etag\"";
627623
servletRequest.addHeader(HttpHeaders.IF_NONE_MATCH, etagValue);
628-
ZonedDateTime dateTime = ofEpochMilli(new Date().getTime()).atZone(GMT);
624+
ZonedDateTime dateTime = ofEpochMilli(new Date().getTime()).atZone(ZoneOffset.UTC);
629625
servletRequest.addHeader(HttpHeaders.IF_UNMODIFIED_SINCE, RFC_1123_DATE_TIME.format(dateTime));
630626
ResponseEntity<String> returnValue = ResponseEntity.ok().eTag(etagValue).body("body");
631627

@@ -732,7 +728,7 @@ void shouldHandleValidatorHeadersInputResponses() throws Exception {
732728
@Test
733729
void shouldNotFailPreconditionForPutRequests() throws Exception {
734730
servletRequest.setMethod("PUT");
735-
ZonedDateTime dateTime = ofEpochMilli(new Date().getTime()).atZone(GMT);
731+
ZonedDateTime dateTime = ofEpochMilli(new Date().getTime()).atZone(ZoneOffset.UTC);
736732
servletRequest.addHeader(HttpHeaders.IF_UNMODIFIED_SINCE, RFC_1123_DATE_TIME.format(dateTime));
737733

738734
long justModified = dateTime.plusSeconds(1).toEpochSecond() * 1000;

0 commit comments

Comments
 (0)