use of org.springframework.mock.http.server.reactive.test.MockServerWebExchange in project spring-framework by spring-projects.
the class DefaultServerWebExchangeCheckNotModifiedTests method checkNotModifiedTimestampConditionalPutConflict.
@Test
public void checkNotModifiedTimestampConditionalPutConflict() throws Exception {
Instant oneMinuteAgo = currentDate.minusSeconds(60);
long millis = oneMinuteAgo.toEpochMilli();
MockServerWebExchange exchange = MockServerHttpRequest.put("/").ifUnmodifiedSince(millis).toExchange();
assertTrue(exchange.checkNotModified(currentDate));
assertEquals(412, exchange.getResponse().getStatusCode().value());
assertEquals(-1, 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 checkNotModifiedETagWeakStrong.
@Test
public void checkNotModifiedETagWeakStrong() {
String eTag = "\"Foo\"";
String weakEtag = String.format("W/%s", eTag);
MockServerWebExchange exchange = get("/").ifNoneMatch(eTag).toExchange();
assertTrue(exchange.checkNotModified(weakEtag));
assertEquals(304, exchange.getResponse().getStatusCode().value());
assertEquals(weakEtag, 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 checkNotModifiedTimestampWithLengthPart.
@Test
public void checkNotModifiedTimestampWithLengthPart() throws Exception {
long epochTime = dateFormat.parse(CURRENT_TIME).getTime();
String header = "Wed, 09 Apr 2014 09:57:42 GMT; length=13774";
MockServerWebExchange exchange = get("/").header("If-Modified-Since", header).toExchange();
assertTrue(exchange.checkNotModified(Instant.ofEpochMilli(epochTime)));
assertEquals(304, exchange.getResponse().getStatusCode().value());
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 checkNotModifiedHeaderAlreadySet.
@Test
public void checkNotModifiedHeaderAlreadySet() {
MockServerWebExchange exchange = get("/").ifModifiedSince(currentDate.toEpochMilli()).toExchange();
exchange.getResponse().getHeaders().add("Last-Modified", CURRENT_TIME);
assertTrue(exchange.checkNotModified(currentDate));
assertEquals(304, exchange.getResponse().getStatusCode().value());
assertEquals(1, exchange.getResponse().getHeaders().get("Last-Modified").size());
assertEquals(CURRENT_TIME, exchange.getResponse().getHeaders().getFirst("Last-Modified"));
}
use of org.springframework.mock.http.server.reactive.test.MockServerWebExchange in project spring-framework by spring-projects.
the class DefaultServerWebExchangeCheckNotModifiedTests method checkNotModifiedTimestamp.
@Test
public void checkNotModifiedTimestamp() throws Exception {
MockServerWebExchange exchange = get("/").ifModifiedSince(currentDate.toEpochMilli()).toExchange();
assertTrue(exchange.checkNotModified(currentDate));
assertEquals(304, exchange.getResponse().getStatusCode().value());
assertEquals(currentDate.toEpochMilli(), exchange.getResponse().getHeaders().getLastModified());
}
Aggregations