use of org.springframework.web.testfixture.server.MockServerWebExchange in project spring-framework by spring-projects.
the class HeadersRequestConditionTests method headerNotPresent.
@Test
public void headerNotPresent() {
MockServerWebExchange exchange = MockServerWebExchange.from(get("/"));
HeadersRequestCondition condition = new HeadersRequestCondition("!accept");
assertThat(condition.getMatchingCondition(exchange)).isNotNull();
}
use of org.springframework.web.testfixture.server.MockServerWebExchange in project spring-framework by spring-projects.
the class HeadersRequestConditionTests method headerValueMatchNegated.
@Test
public void headerValueMatchNegated() {
MockServerWebExchange exchange = MockServerWebExchange.from(get("/").header("foo", "baz"));
HeadersRequestCondition condition = new HeadersRequestCondition("foo!=bar");
assertThat(condition.getMatchingCondition(exchange)).isNotNull();
}
use of org.springframework.web.testfixture.server.MockServerWebExchange in project spring-framework by spring-projects.
the class PatternsRequestConditionTests method matchPatternContainsExtension.
@Test
public void matchPatternContainsExtension() {
PatternsRequestCondition condition = createPatternsCondition("/foo.jpg");
MockServerWebExchange exchange = MockServerWebExchange.from(get("/foo.html"));
PatternsRequestCondition match = condition.getMatchingCondition(exchange);
assertThat(match).isNull();
}
use of org.springframework.web.testfixture.server.MockServerWebExchange in project spring-framework by spring-projects.
the class PatternsRequestConditionTests method matchTrailingSlash.
@Test
public void matchTrailingSlash() {
MockServerWebExchange exchange = MockServerWebExchange.from(get("/foo/"));
PatternsRequestCondition condition = createPatternsCondition("/foo");
PatternsRequestCondition match = condition.getMatchingCondition(exchange);
assertThat(match).isNotNull();
assertThat(match.getPatterns().iterator().next().getPatternString()).as("Should match by default").isEqualTo("/foo");
condition = createPatternsCondition("/foo");
match = condition.getMatchingCondition(exchange);
assertThat(match).isNotNull();
assertThat(match.getPatterns().iterator().next().getPatternString()).as("Trailing slash should be insensitive to useSuffixPatternMatch settings (SPR-6164, SPR-5636)").isEqualTo("/foo");
PathPatternParser parser = new PathPatternParser();
parser.setMatchOptionalTrailingSeparator(false);
condition = new PatternsRequestCondition(parser.parse("/foo"));
match = condition.getMatchingCondition(MockServerWebExchange.from(get("/foo/")));
assertThat(match).isNull();
}
use of org.springframework.web.testfixture.server.MockServerWebExchange in project spring-framework by spring-projects.
the class PatternsRequestConditionTests method matchSortPatterns.
@Test
public void matchSortPatterns() {
PatternsRequestCondition condition = createPatternsCondition("/*/*", "/foo/bar", "/foo/*");
MockServerWebExchange exchange = MockServerWebExchange.from(get("/foo/bar"));
PatternsRequestCondition match = condition.getMatchingCondition(exchange);
PatternsRequestCondition expected = createPatternsCondition("/foo/bar", "/foo/*", "/*/*");
assertThat(match).isEqualTo(expected);
}
Aggregations