use of org.springframework.web.method.support.ModelAndViewContainer in project spring-framework by spring-projects.
the class ModelAttributeMethodProcessorTests method setUp.
@Before
public void setUp() throws Exception {
this.request = new ServletWebRequest(new MockHttpServletRequest());
this.container = new ModelAndViewContainer();
this.processor = new ModelAttributeMethodProcessor(false);
Method method = ModelAttributeHandler.class.getDeclaredMethod("modelAttribute", TestBean.class, Errors.class, int.class, TestBean.class, TestBean.class, TestBean.class);
this.paramNamedValidModelAttr = new SynthesizingMethodParameter(method, 0);
this.paramErrors = new SynthesizingMethodParameter(method, 1);
this.paramInt = new SynthesizingMethodParameter(method, 2);
this.paramModelAttr = new SynthesizingMethodParameter(method, 3);
this.paramBindingDisabledAttr = new SynthesizingMethodParameter(method, 4);
this.paramNonSimpleType = new SynthesizingMethodParameter(method, 5);
method = getClass().getDeclaredMethod("annotatedReturnValue");
this.returnParamNamedModelAttr = new MethodParameter(method, -1);
method = getClass().getDeclaredMethod("notAnnotatedReturnValue");
this.returnParamNonSimpleType = new MethodParameter(method, -1);
}
use of org.springframework.web.method.support.ModelAndViewContainer in project spring-framework by spring-projects.
the class ErrorsMethodHandlerArgumentResolverTests method bindingResult.
@Test
public void bindingResult() throws Exception {
ModelAndViewContainer mavContainer = new ModelAndViewContainer();
mavContainer.addAttribute("ignore1", "value1");
mavContainer.addAttribute("ignore2", "value2");
mavContainer.addAttribute("ignore3", "value3");
mavContainer.addAttribute("ignore4", "value4");
mavContainer.addAttribute("ignore5", "value5");
mavContainer.addAllAttributes(bindingResult.getModel());
Object actual = resolver.resolveArgument(paramErrors, mavContainer, webRequest, null);
assertSame(actual, bindingResult);
}
use of org.springframework.web.method.support.ModelAndViewContainer in project spring-framework by spring-projects.
the class ResponseBodyEmitterReturnValueHandlerTests method handleReturnValue.
private void handleReturnValue(Object returnValue, MethodParameter returnType) throws Exception {
ModelAndViewContainer mavContainer = new ModelAndViewContainer();
this.handler.handleReturnValue(returnValue, returnType, mavContainer, this.webRequest);
}
use of org.springframework.web.method.support.ModelAndViewContainer in project crnk-framework by crnk-project.
the class SpringParameterProvider method provide.
@Override
@SuppressWarnings("unchecked")
public <T> T provide(Method method, int parameterIndex) {
MethodParameter methodParameter = new MethodParameter(method, parameterIndex);
ModelAndViewContainer modelAndViewContainer = new ModelAndViewContainer();
NativeWebRequest webRequest = new ServletWebRequest(request);
DefaultDataBinderFactory binderFactory = new DefaultDataBinderFactory(new ConfigurableWebBindingInitializer());
try {
return (T) argumentResolvers.resolveArgument(methodParameter, modelAndViewContainer, webRequest, binderFactory);
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
use of org.springframework.web.method.support.ModelAndViewContainer in project spring-framework by spring-projects.
the class DeferredResultReturnValueHandlerTests method testHandle.
private void testHandle(Object returnValue, Class<?> asyncType, Runnable setResultTask, Object expectedValue) throws Exception {
ModelAndViewContainer mavContainer = new ModelAndViewContainer();
MethodParameter returnType = on(TestController.class).resolveReturnType(asyncType, String.class);
this.handler.handleReturnValue(returnValue, returnType, mavContainer, this.webRequest);
assertThat(this.request.isAsyncStarted()).isTrue();
assertThat(WebAsyncUtils.getAsyncManager(this.webRequest).hasConcurrentResult()).isFalse();
setResultTask.run();
assertThat(WebAsyncUtils.getAsyncManager(this.webRequest).hasConcurrentResult()).isTrue();
assertThat(WebAsyncUtils.getAsyncManager(this.webRequest).getConcurrentResult()).isEqualTo(expectedValue);
}
Aggregations