use of org.springframework.web.testfixture.server.MockServerWebExchange in project spring-framework by spring-projects.
the class ConsumesRequestConditionTests method negatedConsumesMatch.
@Test
public void negatedConsumesMatch() throws Exception {
MockServerWebExchange exchange = postExchange("text/plain");
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 consumesMatch.
@Test
public void consumesMatch() throws Exception {
MockServerWebExchange exchange = postExchange("text/plain");
ConsumesRequestCondition condition = new ConsumesRequestCondition("text/plain");
assertThat(condition.getMatchingCondition(exchange)).isNotNull();
}
use of org.springframework.web.testfixture.server.MockServerWebExchange in project spring-framework by spring-projects.
the class ParamsRequestConditionTests method paramNotPresent.
@Test
public void paramNotPresent() throws Exception {
MockServerWebExchange exchange = MockServerWebExchange.from(get("/"));
assertThat(new ParamsRequestCondition("!foo").getMatchingCondition(exchange)).isNotNull();
}
use of org.springframework.web.testfixture.server.MockServerWebExchange in project spring-framework by spring-projects.
the class ProducesRequestConditionTests method matchAndCompare.
// gh-22853
@Test
public void matchAndCompare() {
RequestedContentTypeResolverBuilder builder = new RequestedContentTypeResolverBuilder();
builder.headerResolver();
builder.fixedResolver(MediaType.TEXT_HTML);
RequestedContentTypeResolver resolver = builder.build();
ProducesRequestCondition none = new ProducesRequestCondition(new String[0], null, resolver);
ProducesRequestCondition html = new ProducesRequestCondition(new String[] { "text/html" }, null, resolver);
MockServerWebExchange exchange = MockServerWebExchange.from(get("/").header("Accept", "*/*"));
ProducesRequestCondition noneMatch = none.getMatchingCondition(exchange);
ProducesRequestCondition htmlMatch = html.getMatchingCondition(exchange);
assertThat(noneMatch.compareTo(htmlMatch, exchange)).isEqualTo(1);
}
use of org.springframework.web.testfixture.server.MockServerWebExchange in project spring-framework by spring-projects.
the class ProducesRequestConditionTests method matchWithNegationAndMediaTypeAllWithQualityParameter.
// SPR-17550
@Test
public void matchWithNegationAndMediaTypeAllWithQualityParameter() {
ProducesRequestCondition condition = new ProducesRequestCondition("!application/json");
MockServerWebExchange exchange = MockServerWebExchange.from(get("/").header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"));
assertThat(condition.getMatchingCondition(exchange)).isNotNull();
}
Aggregations