Java Code Examples for org.springframework.web.reactive.result.method.RequestMappingInfo#getMatchingCondition()

The following examples show how to use org.springframework.web.reactive.result.method.RequestMappingInfo#getMatchingCondition() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Test
@Ignore
public void preFlightRequest() throws Exception {
	MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.options("/foo")
			.header("Origin", "https://domain.com")
			.header(HttpHeaders.ACCESS_CONTROL_REQUEST_HEADERS, "POST")
			);

	RequestMappingInfo info = paths("/foo").methods(RequestMethod.POST).build();
	RequestMappingInfo match = info.getMatchingCondition(exchange);
	assertNotNull(match);

	info = paths("/foo").methods(RequestMethod.OPTIONS).build();
	match = info.getMatchingCondition(exchange);
	assertNull("Pre-flight should match the ACCESS_CONTROL_REQUEST_METHOD", match);
}
 
Example 2
@Test
@Ignore
public void preFlightRequest() throws Exception {
	MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.options("/foo")
			.header("Origin", "http://domain.com")
			.header(HttpHeaders.ACCESS_CONTROL_REQUEST_HEADERS, "POST")
			);

	RequestMappingInfo info = paths("/foo").methods(RequestMethod.POST).build();
	RequestMappingInfo match = info.getMatchingCondition(exchange);
	assertNotNull(match);

	info = paths("/foo").methods(RequestMethod.OPTIONS).build();
	match = info.getMatchingCondition(exchange);
	assertNull("Pre-flight should match the ACCESS_CONTROL_REQUEST_METHOD", match);
}
 
Example 3
@Test
public void matchParamsCondition() {
	ServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/foo?foo=bar"));

	RequestMappingInfo info = paths("/foo").params("foo=bar").build();
	RequestMappingInfo match = info.getMatchingCondition(exchange);

	assertNotNull(match);

	info = paths("/foo").params("foo!=bar").build();
	match = info.getMatchingCondition(exchange);

	assertNull(match);
}
 
Example 4
@Test
public void matchHeadersCondition() {
	MockServerHttpRequest request = MockServerHttpRequest.get("/foo").header("foo", "bar").build();
	ServerWebExchange exchange = MockServerWebExchange.from(request);

	RequestMappingInfo info = paths("/foo").headers("foo=bar").build();
	RequestMappingInfo match = info.getMatchingCondition(exchange);

	assertNotNull(match);

	info = paths("/foo").headers("foo!=bar").build();
	match = info.getMatchingCondition(exchange);

	assertNull(match);
}
 
Example 5
@Test
public void matchConsumesCondition() {
	MockServerHttpRequest request = MockServerHttpRequest.post("/foo").contentType(MediaType.TEXT_PLAIN).build();
	ServerWebExchange exchange = MockServerWebExchange.from(request);

	RequestMappingInfo info = paths("/foo").consumes("text/plain").build();
	RequestMappingInfo match = info.getMatchingCondition(exchange);

	assertNotNull(match);

	info = paths("/foo").consumes("application/xml").build();
	match = info.getMatchingCondition(exchange);

	assertNull(match);
}
 
Example 6
@Test
public void matchProducesCondition() {
	MockServerHttpRequest request = MockServerHttpRequest.get("/foo").accept(MediaType.TEXT_PLAIN).build();
	ServerWebExchange exchange = MockServerWebExchange.from(request);

	RequestMappingInfo info = paths("/foo").produces("text/plain").build();
	RequestMappingInfo match = info.getMatchingCondition(exchange);

	assertNotNull(match);

	info = paths("/foo").produces("application/xml").build();
	match = info.getMatchingCondition(exchange);

	assertNull(match);
}
 
Example 7
@Test
public void matchParamsCondition() {
	ServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/foo?foo=bar"));

	RequestMappingInfo info = paths("/foo").params("foo=bar").build();
	RequestMappingInfo match = info.getMatchingCondition(exchange);

	assertNotNull(match);

	info = paths("/foo").params("foo!=bar").build();
	match = info.getMatchingCondition(exchange);

	assertNull(match);
}
 
Example 8
@Test
public void matchHeadersCondition() {
	MockServerHttpRequest request = MockServerHttpRequest.get("/foo").header("foo", "bar").build();
	ServerWebExchange exchange = MockServerWebExchange.from(request);

	RequestMappingInfo info = paths("/foo").headers("foo=bar").build();
	RequestMappingInfo match = info.getMatchingCondition(exchange);

	assertNotNull(match);

	info = paths("/foo").headers("foo!=bar").build();
	match = info.getMatchingCondition(exchange);

	assertNull(match);
}
 
Example 9
@Test
public void matchConsumesCondition() {
	MockServerHttpRequest request = MockServerHttpRequest.post("/foo").contentType(MediaType.TEXT_PLAIN).build();
	ServerWebExchange exchange = MockServerWebExchange.from(request);

	RequestMappingInfo info = paths("/foo").consumes("text/plain").build();
	RequestMappingInfo match = info.getMatchingCondition(exchange);

	assertNotNull(match);

	info = paths("/foo").consumes("application/xml").build();
	match = info.getMatchingCondition(exchange);

	assertNull(match);
}
 
Example 10
@Test
public void matchProducesCondition() {
	MockServerHttpRequest request = MockServerHttpRequest.get("/foo").accept(MediaType.TEXT_PLAIN).build();
	ServerWebExchange exchange = MockServerWebExchange.from(request);

	RequestMappingInfo info = paths("/foo").produces("text/plain").build();
	RequestMappingInfo match = info.getMatchingCondition(exchange);

	assertNotNull(match);

	info = paths("/foo").produces("application/xml").build();
	match = info.getMatchingCondition(exchange);

	assertNull(match);
}
 
Example 11
@Test
public void matchCustomCondition() {
	ServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/foo?foo=bar"));

	RequestMappingInfo info = paths("/foo").params("foo=bar").build();
	RequestMappingInfo match = info.getMatchingCondition(exchange);

	assertNotNull(match);

	info = paths("/foo").params("foo!=bar")
			.customCondition(new ParamsRequestCondition("foo!=bar")).build();

	match = info.getMatchingCondition(exchange);

	assertNull(match);
}
 
Example 12
@Test
public void matchCustomCondition() {
	ServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/foo?foo=bar"));

	RequestMappingInfo info = paths("/foo").params("foo=bar").build();
	RequestMappingInfo match = info.getMatchingCondition(exchange);

	assertNotNull(match);

	info = paths("/foo").params("foo!=bar")
			.customCondition(new ParamsRequestCondition("foo!=bar")).build();

	match = info.getMatchingCondition(exchange);

	assertNull(match);
}