use of org.springframework.web.server.ServerWebExchange in project spring-framework by spring-projects.
the class RequestParamMapMethodArgumentResolverTests method resolveMultiValueMapArgument.
@Test
public void resolveMultiValueMapArgument() throws Exception {
MethodParameter param = this.testMethod.annotPresent(RequestParam.class).arg(MultiValueMap.class);
ServerWebExchange exchange = MockServerHttpRequest.get("/path?foo=bar&foo=baz").toExchange();
Object result = resolve(param, exchange);
assertTrue(result instanceof MultiValueMap);
assertEquals(Collections.singletonMap("foo", Arrays.asList("bar", "baz")), result);
}
use of org.springframework.web.server.ServerWebExchange in project spring-framework by spring-projects.
the class RequestParamMethodArgumentResolverTests method resolveSimpleTypeParam.
@Test
public void resolveSimpleTypeParam() throws Exception {
ServerWebExchange exchange = MockServerHttpRequest.get("/path?stringNotAnnot=plainValue").toExchange();
MethodParameter param = this.testMethod.annotNotPresent(RequestParam.class).arg(String.class);
Object result = resolve(param, exchange);
assertEquals("plainValue", result);
}
use of org.springframework.web.server.ServerWebExchange in project spring-framework by spring-projects.
the class RequestParamMethodArgumentResolverTests method resolveWithFormData.
@Test
public void resolveWithFormData() throws Exception {
ServerWebExchange exchange = MockServerHttpRequest.post("/path").contentType(MediaType.APPLICATION_FORM_URLENCODED).body("name=foo").toExchange();
MethodParameter param = this.testMethod.annot(requestParam().notRequired("bar")).arg(String.class);
assertEquals("foo", resolve(param, exchange));
}
use of org.springframework.web.server.ServerWebExchange in project spring-framework by spring-projects.
the class HiddenHttpMethodFilter method mapExchange.
private ServerWebExchange mapExchange(ServerWebExchange exchange, String methodParamValue) {
HttpMethod httpMethod = HttpMethod.resolve(methodParamValue.toUpperCase(Locale.ENGLISH));
Assert.notNull(httpMethod, () -> "HttpMethod '" + methodParamValue + "' not supported");
return exchange.mutate().request(builder -> builder.method(httpMethod)).build();
}
use of org.springframework.web.server.ServerWebExchange in project spring-framework by spring-projects.
the class DefaultCorsProcessorTests method preflightRequestWithoutRequestMethod.
@Test
public void preflightRequestWithoutRequestMethod() throws Exception {
ServerWebExchange exchange = preFlightRequest().header(ACCESS_CONTROL_REQUEST_HEADERS, "Header1").toExchange();
this.processor.processRequest(this.conf, exchange);
ServerHttpResponse response = exchange.getResponse();
assertFalse(response.getHeaders().containsKey(ACCESS_CONTROL_ALLOW_ORIGIN));
assertEquals(HttpStatus.FORBIDDEN, response.getStatusCode());
}
Aggregations