use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.
the class HandlerMethodReturnValueHandlerCompositeTests method handleReturnValueWithAsyncHandler.
// SPR-13083
@Test
public void handleReturnValueWithAsyncHandler() throws Exception {
Promise<Integer> promise = new Promise<>();
MethodParameter promiseType = new MethodParameter(getClass().getDeclaredMethod("handlePromise"), -1);
HandlerMethodReturnValueHandler responseBodyHandler = mock(HandlerMethodReturnValueHandler.class);
when(responseBodyHandler.supportsReturnType(promiseType)).thenReturn(true);
this.handlers.addHandler(responseBodyHandler);
AsyncHandlerMethodReturnValueHandler promiseHandler = mock(AsyncHandlerMethodReturnValueHandler.class);
when(promiseHandler.supportsReturnType(promiseType)).thenReturn(true);
when(promiseHandler.isAsyncReturnValue(promise, promiseType)).thenReturn(true);
this.handlers.addHandler(promiseHandler);
this.handlers.handleReturnValue(promise, promiseType, this.mavContainer, null);
verify(promiseHandler).isAsyncReturnValue(promise, promiseType);
verify(promiseHandler).supportsReturnType(promiseType);
verify(promiseHandler).handleReturnValue(promise, promiseType, this.mavContainer, null);
verifyNoMoreInteractions(promiseHandler);
verifyNoMoreInteractions(responseBodyHandler);
}
use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.
the class HandlerMethodReturnValueHandlerCompositeTests method setUp.
@Before
public void setUp() throws Exception {
this.integerType = new MethodParameter(getClass().getDeclaredMethod("handleInteger"), -1);
this.stringType = new MethodParameter(getClass().getDeclaredMethod("handleString"), -1);
this.integerHandler = mock(HandlerMethodReturnValueHandler.class);
when(this.integerHandler.supportsReturnType(this.integerType)).thenReturn(true);
this.handlers = new HandlerMethodReturnValueHandlerComposite();
this.handlers.addHandler(this.integerHandler);
mavContainer = new ModelAndViewContainer();
}
use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.
the class RequestParamMethodArgumentResolverTests method resolveSimpleTypeParamToNull.
// SPR-8561
@Test
public void resolveSimpleTypeParamToNull() throws Exception {
MethodParameter param = this.testMethod.annotNotPresent(RequestParam.class).arg(String.class);
Object result = resolver.resolveArgument(param, null, webRequest, null);
assertNull(result);
}
use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.
the class RequestParamMethodArgumentResolverTests method resolvePartNotAnnot.
@Test
public void resolvePartNotAnnot() throws Exception {
MockPart expected = new MockPart("part", "Hello World".getBytes());
MockHttpServletRequest request = new MockHttpServletRequest();
request.setMethod("POST");
request.setContentType("multipart/form-data");
request.addPart(expected);
webRequest = new ServletWebRequest(request);
MethodParameter param = this.testMethod.annotNotPresent(RequestParam.class).arg(Part.class);
Object result = resolver.resolveArgument(param, null, webRequest, null);
assertTrue(result instanceof Part);
assertEquals("Invalid result", expected, result);
}
use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.
the class RequestParamMethodArgumentResolverTests method resolveMultipartFileNotAnnot.
@Test
public void resolveMultipartFileNotAnnot() throws Exception {
MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
MultipartFile expected = new MockMultipartFile("multipartFileNotAnnot", "Hello World".getBytes());
request.addFile(expected);
webRequest = new ServletWebRequest(request);
MethodParameter param = this.testMethod.annotNotPresent().arg(MultipartFile.class);
Object result = resolver.resolveArgument(param, null, webRequest, null);
assertTrue(result instanceof MultipartFile);
assertEquals("Invalid result", expected, result);
}
Aggregations