use of org.springframework.web.testfixture.server.MockServerWebExchange in project spring-framework by spring-projects.
the class RequestHeaderMethodArgumentResolverTests method resolveDefaultValue.
@Test
public void resolveDefaultValue() {
MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/"));
Mono<Object> mono = this.resolver.resolveArgument(this.paramNamedDefaultValueStringHeader, this.bindingContext, exchange);
Object result = mono.block();
boolean condition = result instanceof String;
assertThat(condition).isTrue();
assertThat(result).isEqualTo("bar");
}
use of org.springframework.web.testfixture.server.MockServerWebExchange in project spring-framework by spring-projects.
the class CookieValueMethodArgumentResolverTests method resolveCookieStringArgument.
@Test
public void resolveCookieStringArgument() {
HttpCookie cookie = new HttpCookie("name", "foo");
MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/").cookie(cookie));
Mono<Object> mono = this.resolver.resolveArgument(this.cookieStringParameter, this.bindingContext, exchange);
assertThat(mono.block()).as("Invalid result").isEqualTo(cookie.getValue());
}
use of org.springframework.web.testfixture.server.MockServerWebExchange in project spring-framework by spring-projects.
the class InitBinderBindingContextTests method createBinderWithAttrName.
@Test
public void createBinderWithAttrName() throws Exception {
MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/"));
BindingContext context = createBindingContext("initBinderWithAttributeName", WebDataBinder.class);
WebDataBinder dataBinder = context.createDataBinder(exchange, null, "foo");
assertThat(dataBinder.getDisallowedFields()).isNotNull();
assertThat(dataBinder.getDisallowedFields()[0]).isEqualTo("id");
}
use of org.springframework.web.testfixture.server.MockServerWebExchange in project spring-framework by spring-projects.
the class InitBinderBindingContextTests method returnValueNotExpected.
@Test
public void returnValueNotExpected() throws Exception {
MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/"));
BindingContext context = createBindingContext("initBinderReturnValue", WebDataBinder.class);
assertThatIllegalStateException().isThrownBy(() -> context.createDataBinder(exchange, null, "invalidName"));
}
use of org.springframework.web.testfixture.server.MockServerWebExchange in project spring-framework by spring-projects.
the class InitBinderBindingContextTests method createBinder.
@Test
public void createBinder() throws Exception {
MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/"));
BindingContext context = createBindingContext("initBinder", WebDataBinder.class);
WebDataBinder dataBinder = context.createDataBinder(exchange, null, null);
assertThat(dataBinder.getDisallowedFields()).isNotNull();
assertThat(dataBinder.getDisallowedFields()[0]).isEqualTo("id");
}
Aggregations