use of org.springframework.mock.http.server.reactive.test.MockServerWebExchange in project spring-framework by spring-projects.
the class DefaultServerWebExchangeCheckNotModifiedTests method checkModifiedTimestampWithLengthPart.
@Test
public void checkModifiedTimestampWithLengthPart() throws Exception {
long epochTime = dateFormat.parse(CURRENT_TIME).getTime();
String header = "Tue, 08 Apr 2014 09:57:42 GMT; length=13774";
MockServerWebExchange exchange = get("/").header("If-Modified-Since", header).toExchange();
assertFalse(exchange.checkNotModified(Instant.ofEpochMilli(epochTime)));
assertNull(exchange.getResponse().getStatusCode());
assertEquals(epochTime, exchange.getResponse().getHeaders().getLastModified());
}
use of org.springframework.mock.http.server.reactive.test.MockServerWebExchange in project spring-framework by spring-projects.
the class DefaultServerWebExchangeCheckNotModifiedTests method checkNotModifiedETagWithSeparatorChars.
@Test
public void checkNotModifiedETagWithSeparatorChars() {
String eTag = "\"Foo, Bar\"";
MockServerWebExchange exchange = get("/").ifNoneMatch(eTag).toExchange();
assertTrue(exchange.checkNotModified(eTag));
assertEquals(304, exchange.getResponse().getStatusCode().value());
assertEquals(eTag, exchange.getResponse().getHeaders().getETag());
}
use of org.springframework.mock.http.server.reactive.test.MockServerWebExchange in project spring-framework by spring-projects.
the class DefaultServerWebExchangeCheckNotModifiedTests method checkNotModifiedMultipleETags.
@Test
public void checkNotModifiedMultipleETags() {
String eTag = "\"Bar\"";
String multipleETags = String.format("\"Foo\", %s", eTag);
MockServerWebExchange exchange = get("/").ifNoneMatch(multipleETags).toExchange();
assertTrue(exchange.checkNotModified(eTag));
assertEquals(304, exchange.getResponse().getStatusCode().value());
assertEquals(eTag, exchange.getResponse().getHeaders().getETag());
}
use of org.springframework.mock.http.server.reactive.test.MockServerWebExchange in project spring-framework by spring-projects.
the class DefaultServerWebExchangeCheckNotModifiedTests method checkNotModifiedInvalidIfNoneMatchHeader.
// SPR-14559
@Test
public void checkNotModifiedInvalidIfNoneMatchHeader() {
String eTag = "\"etagvalue\"";
MockServerWebExchange exchange = get("/").ifNoneMatch("missingquotes").toExchange();
assertFalse(exchange.checkNotModified(eTag));
assertNull(exchange.getResponse().getStatusCode());
assertEquals(eTag, exchange.getResponse().getHeaders().getETag());
}
use of org.springframework.mock.http.server.reactive.test.MockServerWebExchange in project spring-framework by spring-projects.
the class DefaultServerWebExchangeCheckNotModifiedTests method checkNotModifiedETagAndModifiedTimestamp.
// SPR-14224
@Test
public void checkNotModifiedETagAndModifiedTimestamp() {
String eTag = "\"Foo\"";
Instant oneMinuteAgo = currentDate.minusSeconds(60);
MockServerWebExchange exchange = get("/").ifNoneMatch(eTag).ifModifiedSince(oneMinuteAgo.toEpochMilli()).toExchange();
assertTrue(exchange.checkNotModified(eTag, currentDate));
assertEquals(304, exchange.getResponse().getStatusCode().value());
assertEquals(eTag, exchange.getResponse().getHeaders().getETag());
assertEquals(currentDate.toEpochMilli(), exchange.getResponse().getHeaders().getLastModified());
}
Aggregations