use of org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest in project spring-framework by spring-projects.
the class RequestMappingInfoHandlerMappingTests method getHandlerTestInvalidContentType.
@Test
public void getHandlerTestInvalidContentType() {
MockServerHttpRequest request = put("/person/1").header("content-type", "bogus").build();
ServerWebExchange exchange = MockServerWebExchange.from(request);
Mono<Object> mono = this.handlerMapping.getHandler(exchange);
assertError(mono, UnsupportedMediaTypeStatusException.class, ex -> assertThat(ex.getMessage()).isEqualTo(("415 UNSUPPORTED_MEDIA_TYPE " + "\"Invalid mime type \"bogus\": does not contain '/'\"")));
}
use of org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest in project spring-framework by spring-projects.
the class RequestMappingInfoHandlerMappingTests method handleMatchMatrixVariablesDecoding.
@Test
public void handleMatchMatrixVariablesDecoding() {
MockServerHttpRequest request = method(HttpMethod.GET, URI.create("/cars;mvar=a%2Fb")).build();
ServerWebExchange exchange = MockServerWebExchange.from(request);
handleMatch(exchange, "/{cars}");
MultiValueMap<String, String> matrixVariables = getMatrixVariables(exchange, "cars");
Map<String, String> uriVariables = getUriTemplateVariables(exchange);
assertThat(matrixVariables).isNotNull();
assertThat(matrixVariables.get("mvar")).isEqualTo(Collections.singletonList("a/b"));
assertThat(uriVariables.get("cars")).isEqualTo("cars");
}
use of org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest in project spring-framework by spring-projects.
the class RequestParamMethodArgumentResolverTests method resolveSimpleTypeParam.
@Test
public void resolveSimpleTypeParam() {
MockServerHttpRequest request = MockServerHttpRequest.get("/path?stringNotAnnot=plainValue").build();
ServerWebExchange exchange = MockServerWebExchange.from(request);
MethodParameter param = this.testMethod.annotNotPresent(RequestParam.class).arg(String.class);
Object result = resolve(param, exchange);
assertThat(result).isEqualTo("plainValue");
}
use of org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest in project spring-framework by spring-projects.
the class RequestParamMethodArgumentResolverTests method resolveEmptyValueWithoutDefault.
@Test
public void resolveEmptyValueWithoutDefault() {
MethodParameter param = this.testMethod.annotNotPresent(RequestParam.class).arg(String.class);
MockServerHttpRequest request = MockServerHttpRequest.get("/path?stringNotAnnot=").build();
assertThat(resolve(param, MockServerWebExchange.from(request))).isEqualTo("");
}
use of org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest in project spring-framework by spring-projects.
the class RequestParamMethodArgumentResolverTests method resolveStringArray.
@Test
public void resolveStringArray() {
MethodParameter param = this.testMethod.annotPresent(RequestParam.class).arg(String[].class);
MockServerHttpRequest request = MockServerHttpRequest.get("/path?name=foo&name=bar").build();
Object result = resolve(param, MockServerWebExchange.from(request));
boolean condition = result instanceof String[];
assertThat(condition).isTrue();
assertThat((String[]) result).isEqualTo(new String[] { "foo", "bar" });
}
Aggregations