use of org.springframework.web.testfixture.server.MockServerWebExchange in project spring-framework by spring-projects.
the class ResourceWebHandlerTests method partialContentSuffixRangeLargeSuffix.
@Test
public void partialContentSuffixRangeLargeSuffix() {
MockServerHttpRequest request = MockServerHttpRequest.get("").header("range", "bytes=-11").build();
MockServerWebExchange exchange = MockServerWebExchange.from(request);
setPathWithinHandlerMapping(exchange, "foo.txt");
this.handler.handle(exchange).block(TIMEOUT);
assertThat(exchange.getResponse().getStatusCode()).isEqualTo(HttpStatus.PARTIAL_CONTENT);
assertThat(exchange.getResponse().getHeaders().getContentType()).isEqualTo(MediaType.TEXT_PLAIN);
assertThat(exchange.getResponse().getHeaders().getContentLength()).isEqualTo(10);
assertThat(exchange.getResponse().getHeaders().getFirst("Content-Range")).isEqualTo("bytes 0-9/10");
assertThat(exchange.getResponse().getHeaders().getFirst("Accept-Ranges")).isEqualTo("bytes");
assertThat(exchange.getResponse().getHeaders().get("Accept-Ranges").size()).isEqualTo(1);
assertResponseBody(exchange, "Some text.");
}
use of org.springframework.web.testfixture.server.MockServerWebExchange in project spring-framework by spring-projects.
the class ConsumesRequestConditionTests method consumesParseError.
@Test
public void consumesParseError() throws Exception {
MockServerWebExchange exchange = postExchange("01");
ConsumesRequestCondition condition = new ConsumesRequestCondition("text/plain");
assertThat(condition.getMatchingCondition(exchange)).isNull();
}
use of org.springframework.web.testfixture.server.MockServerWebExchange in project spring-framework by spring-projects.
the class ConsumesRequestConditionTests method getMatchingCondition.
@Test
public void getMatchingCondition() throws Exception {
MockServerWebExchange exchange = postExchange("text/plain");
ConsumesRequestCondition condition = new ConsumesRequestCondition("text/plain", "application/xml");
ConsumesRequestCondition result = condition.getMatchingCondition(exchange);
assertConditions(result, "text/plain");
condition = new ConsumesRequestCondition("application/xml");
result = condition.getMatchingCondition(exchange);
assertThat(result).isNull();
}
use of org.springframework.web.testfixture.server.MockServerWebExchange in project spring-framework by spring-projects.
the class ConsumesRequestConditionTests method consumesSingleNoMatch.
@Test
public void consumesSingleNoMatch() throws Exception {
MockServerWebExchange exchange = postExchange("application/xml");
ConsumesRequestCondition condition = new ConsumesRequestCondition("text/plain");
assertThat(condition.getMatchingCondition(exchange)).isNull();
}
use of org.springframework.web.testfixture.server.MockServerWebExchange in project spring-framework by spring-projects.
the class ConsumesRequestConditionTests method compareToSingle.
@Test
public void compareToSingle() throws Exception {
MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/"));
ConsumesRequestCondition condition1 = new ConsumesRequestCondition("text/plain");
ConsumesRequestCondition condition2 = new ConsumesRequestCondition("text/*");
int result = condition1.compareTo(condition2, exchange);
assertThat(result < 0).as("Invalid comparison result: " + result).isTrue();
result = condition2.compareTo(condition1, exchange);
assertThat(result > 0).as("Invalid comparison result: " + result).isTrue();
}
Aggregations