Use long for expires and lastModified in HeaderAssertions
This commit changes the type of parameters so that HeaderAssertions can assert expires and lastModified properly. Issue: SPR-17194
This commit is contained in:
committed by
Rossen Stoyanchev
parent
f87a37fd0d
commit
d570f82456
@@ -17,6 +17,8 @@
|
||||
package org.springframework.test.web.reactive.server;
|
||||
|
||||
import java.net.URI;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -217,6 +219,37 @@ public class HeaderAssertionTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void expires() {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
ZonedDateTime expires = ZonedDateTime.of(2018, 1, 1, 0, 0, 0, 0, ZoneId.of("UTC"));
|
||||
headers.setExpires(expires);
|
||||
HeaderAssertions assertions = headerAssertions(headers);
|
||||
assertions.expires(expires.toInstant().toEpochMilli());
|
||||
try {
|
||||
assertions.expires(expires.toInstant().toEpochMilli() + 1);
|
||||
fail("Wrong value expected");
|
||||
}
|
||||
catch (AssertionError error) {
|
||||
// Expected
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lastModified() {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
ZonedDateTime lastModified = ZonedDateTime.of(2018, 1, 1, 0, 0, 0, 0, ZoneId.of("UTC"));
|
||||
headers.setLastModified(lastModified.toInstant().toEpochMilli());
|
||||
HeaderAssertions assertions = headerAssertions(headers);
|
||||
assertions.lastModified(lastModified.toInstant().toEpochMilli());
|
||||
try {
|
||||
assertions.lastModified(lastModified.toInstant().toEpochMilli() + 1);
|
||||
fail("Wrong value expected");
|
||||
}
|
||||
catch (AssertionError error) {
|
||||
// Expected
|
||||
}
|
||||
}
|
||||
|
||||
private HeaderAssertions headerAssertions(HttpHeaders responseHeaders) {
|
||||
MockClientHttpRequest request = new MockClientHttpRequest(HttpMethod.GET, URI.create("/"));
|
||||
|
||||
Reference in New Issue
Block a user