use of org.springframework.web.server.ServerWebExchange in project spring-framework by spring-projects.
the class InitBinderBindingContextTests method createBinder.
@Test
public void createBinder() throws Exception {
ServerWebExchange exchange = MockServerHttpRequest.get("/").toExchange();
BindingContext context = createBindingContext("initBinder", WebDataBinder.class);
WebDataBinder dataBinder = context.createDataBinder(exchange, null, null);
assertNotNull(dataBinder.getDisallowedFields());
assertEquals("id", dataBinder.getDisallowedFields()[0]);
}
use of org.springframework.web.server.ServerWebExchange in project spring-framework by spring-projects.
the class InitBinderBindingContextTests method createBinderWithAttrName.
@Test
public void createBinderWithAttrName() throws Exception {
ServerWebExchange exchange = MockServerHttpRequest.get("/").toExchange();
BindingContext context = createBindingContext("initBinderWithAttributeName", WebDataBinder.class);
WebDataBinder dataBinder = context.createDataBinder(exchange, null, "foo");
assertNotNull(dataBinder.getDisallowedFields());
assertEquals("id", dataBinder.getDisallowedFields()[0]);
}
use of org.springframework.web.server.ServerWebExchange in project spring-framework by spring-projects.
the class RequestBodyArgumentResolverTests method resolveValue.
@SuppressWarnings("unchecked")
private <T> T resolveValue(MethodParameter param, String body) {
ServerWebExchange exchange = MockServerHttpRequest.post("/path").body(body).toExchange();
Mono<Object> result = this.resolver.readBody(param, true, new BindingContext(), exchange);
Object value = result.block(Duration.ofSeconds(5));
assertNotNull(value);
assertTrue("Unexpected return value type: " + value, param.getParameterType().isAssignableFrom(value.getClass()));
//no inspection unchecked
return (T) value;
}
use of org.springframework.web.server.ServerWebExchange in project spring-framework by spring-projects.
the class RequestHeaderMethodArgumentResolverTests method resolveNameFromSystemPropertyThroughPlaceholder.
@Test
public void resolveNameFromSystemPropertyThroughPlaceholder() throws Exception {
String expected = "foo";
ServerWebExchange exchange = MockServerHttpRequest.get("/").header("bar", expected).toExchange();
System.setProperty("systemProperty", "bar");
try {
Mono<Object> mono = this.resolver.resolveArgument(this.paramResolvedNameWithPlaceholder, this.bindingContext, exchange);
Object result = mono.block();
assertTrue(result instanceof String);
assertEquals(expected, result);
} finally {
System.clearProperty("systemProperty");
}
}
use of org.springframework.web.server.ServerWebExchange in project spring-framework by spring-projects.
the class RequestHeaderMethodArgumentResolverTests method resolveStringArgument.
@Test
public void resolveStringArgument() throws Exception {
String expected = "foo";
ServerWebExchange exchange = MockServerHttpRequest.get("/").header("name", expected).toExchange();
Mono<Object> mono = this.resolver.resolveArgument(this.paramNamedDefaultValueStringHeader, this.bindingContext, exchange);
Object result = mono.block();
assertTrue(result instanceof String);
assertEquals(expected, result);
}
Aggregations