use of org.springframework.web.reactive.BindingContext in project spring-framework by spring-projects.
the class HttpEntityArgumentResolverTests method resolveValue.
@SuppressWarnings("unchecked")
private <T> T resolveValue(ServerWebExchange exchange, ResolvableType type) {
MethodParameter param = this.testMethod.arg(type);
Mono<Object> result = this.resolver.resolveArgument(param, new BindingContext(), exchange);
Object value = result.block(Duration.ofSeconds(5));
assertNotNull(value);
assertTrue("Unexpected return value type: " + value.getClass(), param.getParameterType().isAssignableFrom(value.getClass()));
return (T) value;
}
use of org.springframework.web.reactive.BindingContext in project spring-framework by spring-projects.
the class InitBinderBindingContextTests method createBinderWithGlobalInitialization.
@Test
public void createBinderWithGlobalInitialization() throws Exception {
ConversionService conversionService = new DefaultFormattingConversionService();
bindingInitializer.setConversionService(conversionService);
ServerWebExchange exchange = MockServerHttpRequest.get("/").toExchange();
BindingContext context = createBindingContext("initBinder", WebDataBinder.class);
WebDataBinder dataBinder = context.createDataBinder(exchange, null, null);
assertSame(conversionService, dataBinder.getConversionService());
}
use of org.springframework.web.reactive.BindingContext in project spring-framework by spring-projects.
the class InitBinderBindingContextTests method createBinderTypeConversion.
@Test
public void createBinderTypeConversion() throws Exception {
ServerWebExchange exchange = MockServerHttpRequest.get("/path?requestParam=22").toExchange();
ReactiveAdapterRegistry adapterRegistry = new ReactiveAdapterRegistry();
this.argumentResolvers.add(new RequestParamMethodArgumentResolver(null, adapterRegistry, false));
BindingContext context = createBindingContext("initBinderTypeConversion", WebDataBinder.class, int.class);
WebDataBinder dataBinder = context.createDataBinder(exchange, null, "foo");
assertNotNull(dataBinder.getDisallowedFields());
assertEquals("requestParam-22", dataBinder.getDisallowedFields()[0]);
}
use of org.springframework.web.reactive.BindingContext in project spring-framework by spring-projects.
the class InitBinderBindingContextTests method createBinderNullAttrName.
@Test
public void createBinderNullAttrName() throws Exception {
ServerWebExchange exchange = MockServerHttpRequest.get("/").toExchange();
BindingContext context = createBindingContext("initBinderWithAttributeName", WebDataBinder.class);
WebDataBinder dataBinder = context.createDataBinder(exchange, null, null);
assertNull(dataBinder.getDisallowedFields());
}
use of org.springframework.web.reactive.BindingContext in project spring-framework by spring-projects.
the class InitBinderBindingContextTests method createBinderWithAttrNameNoMatch.
@Test
public void createBinderWithAttrNameNoMatch() throws Exception {
ServerWebExchange exchange = MockServerHttpRequest.get("/").toExchange();
BindingContext context = createBindingContext("initBinderWithAttributeName", WebDataBinder.class);
WebDataBinder dataBinder = context.createDataBinder(exchange, null, "invalidName");
assertNull(dataBinder.getDisallowedFields());
}
Aggregations