use of org.springframework.mock.http.server.reactive.test.MockServerWebExchange in project spring-framework by spring-projects.
the class ResourceWebHandlerTests method missingResourcePath.
@Test
public void missingResourcePath() throws Exception {
MockServerWebExchange exchange = MockServerHttpRequest.get("").toExchange();
setPathWithinHandlerMapping(exchange, "");
this.handler.handle(exchange).block(TIMEOUT);
assertEquals(HttpStatus.NOT_FOUND, exchange.getResponse().getStatusCode());
}
use of org.springframework.mock.http.server.reactive.test.MockServerWebExchange in project spring-framework by spring-projects.
the class ResourceWebHandlerTests method directory.
@Test
public void directory() throws Exception {
MockServerWebExchange exchange = MockServerHttpRequest.get("").toExchange();
setPathWithinHandlerMapping(exchange, "js/");
this.handler.handle(exchange).block(TIMEOUT);
assertEquals(HttpStatus.NOT_FOUND, exchange.getResponse().getStatusCode());
}
use of org.springframework.mock.http.server.reactive.test.MockServerWebExchange in project spring-framework by spring-projects.
the class ResourceWebHandlerTests method partialContentByteRangeNoEnd.
@Test
public void partialContentByteRangeNoEnd() throws Exception {
MockServerWebExchange exchange = MockServerHttpRequest.get("").header("range", "bytes=9-").toExchange();
setPathWithinHandlerMapping(exchange, "foo.txt");
this.handler.handle(exchange).block(TIMEOUT);
assertEquals(HttpStatus.PARTIAL_CONTENT, exchange.getResponse().getStatusCode());
assertEquals(MediaType.TEXT_PLAIN, exchange.getResponse().getHeaders().getContentType());
assertEquals(1, exchange.getResponse().getHeaders().getContentLength());
assertEquals("bytes 9-9/10", exchange.getResponse().getHeaders().getFirst("Content-Range"));
assertEquals("bytes", exchange.getResponse().getHeaders().getFirst("Accept-Ranges"));
assertEquals(1, exchange.getResponse().getHeaders().get("Accept-Ranges").size());
assertResponseBody(exchange, ".");
}
use of org.springframework.mock.http.server.reactive.test.MockServerWebExchange in project spring-framework by spring-projects.
the class ResourceWebHandlerTests method partialContentSuffixRangeLargeSuffix.
@Test
public void partialContentSuffixRangeLargeSuffix() throws Exception {
MockServerWebExchange exchange = MockServerHttpRequest.get("").header("range", "bytes=-11").toExchange();
setPathWithinHandlerMapping(exchange, "foo.txt");
this.handler.handle(exchange).block(TIMEOUT);
assertEquals(HttpStatus.PARTIAL_CONTENT, exchange.getResponse().getStatusCode());
assertEquals(MediaType.TEXT_PLAIN, exchange.getResponse().getHeaders().getContentType());
assertEquals(10, exchange.getResponse().getHeaders().getContentLength());
assertEquals("bytes 0-9/10", exchange.getResponse().getHeaders().getFirst("Content-Range"));
assertEquals("bytes", exchange.getResponse().getHeaders().getFirst("Accept-Ranges"));
assertEquals(1, exchange.getResponse().getHeaders().get("Accept-Ranges").size());
assertResponseBody(exchange, "Some text.");
}
use of org.springframework.mock.http.server.reactive.test.MockServerWebExchange in project spring-framework by spring-projects.
the class ResourceWebHandlerTests method noPathWithinHandlerMappingAttribute.
@Test(expected = IllegalStateException.class)
public void noPathWithinHandlerMappingAttribute() throws Exception {
MockServerWebExchange exchange = MockServerHttpRequest.get("").toExchange();
this.handler.handle(exchange).block(TIMEOUT);
}
Aggregations