use of org.springframework.web.reactive.BindingContext in project spring-framework by spring-projects.
the class InitBinderBindingContextTests method returnValueNotExpected.
@Test(expected = IllegalStateException.class)
public void returnValueNotExpected() throws Exception {
ServerWebExchange exchange = MockServerHttpRequest.get("/").toExchange();
BindingContext context = createBindingContext("initBinderReturnValue", WebDataBinder.class);
context.createDataBinder(exchange, null, "invalidName");
}
use of org.springframework.web.reactive.BindingContext 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.reactive.BindingContext 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.reactive.BindingContext 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.reactive.BindingContext in project spring-framework by spring-projects.
the class RequestHeaderMethodArgumentResolverTests method setup.
@Before
public void setup() throws Exception {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
context.refresh();
ReactiveAdapterRegistry adapterRegistry = new ReactiveAdapterRegistry();
this.resolver = new RequestHeaderMethodArgumentResolver(context.getBeanFactory(), adapterRegistry);
ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer();
initializer.setConversionService(new DefaultFormattingConversionService());
this.bindingContext = new BindingContext(initializer);
Method method = ReflectionUtils.findMethod(getClass(), "params", (Class<?>[]) null);
this.paramNamedDefaultValueStringHeader = new SynthesizingMethodParameter(method, 0);
this.paramNamedValueStringArray = new SynthesizingMethodParameter(method, 1);
this.paramSystemProperty = new SynthesizingMethodParameter(method, 2);
this.paramResolvedNameWithExpression = new SynthesizingMethodParameter(method, 3);
this.paramResolvedNameWithPlaceholder = new SynthesizingMethodParameter(method, 4);
this.paramNamedValueMap = new SynthesizingMethodParameter(method, 5);
this.paramDate = new SynthesizingMethodParameter(method, 6);
this.paramInstant = new SynthesizingMethodParameter(method, 7);
this.paramMono = new SynthesizingMethodParameter(method, 8);
}
Aggregations