use of org.springframework.web.context.request.ServletWebRequest in project spring-framework by spring-projects.
the class RequestPartMethodArgumentResolverTests method resolveOptionalPartListWithoutMultipartRequest.
@Test
public void resolveOptionalPartListWithoutMultipartRequest() throws Exception {
webRequest = new ServletWebRequest(new MockHttpServletRequest());
Object actualValue = resolver.resolveArgument(optionalPartList, null, webRequest, null);
assertEquals("Invalid argument value", Optional.empty(), actualValue);
actualValue = resolver.resolveArgument(optionalPartList, null, webRequest, null);
assertEquals("Invalid argument value", Optional.empty(), actualValue);
}
use of org.springframework.web.context.request.ServletWebRequest in project spring-framework by spring-projects.
the class RequestPartMethodArgumentResolverTests method resolveMultipartFileNotAnnotArgument.
@Test
public void resolveMultipartFileNotAnnotArgument() throws Exception {
MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
MultipartFile expected = new MockMultipartFile("multipartFileNotAnnot", "Hello World".getBytes());
request.addFile(expected);
request.addFile(new MockMultipartFile("otherPart", "", "text/plain", "Hello World".getBytes()));
webRequest = new ServletWebRequest(request);
Object result = resolver.resolveArgument(paramMultipartFileNotAnnot, null, webRequest, null);
assertTrue(result instanceof MultipartFile);
assertEquals("Invalid result", expected, result);
}
use of org.springframework.web.context.request.ServletWebRequest in project spring-framework by spring-projects.
the class PathExtensionContentNegotiationStrategyTests method setup.
@Before
public void setup() {
this.servletRequest = new MockHttpServletRequest();
this.webRequest = new ServletWebRequest(servletRequest);
}
use of org.springframework.web.context.request.ServletWebRequest in project spring-framework by spring-projects.
the class InvocableHandlerMethodTests method setUp.
@Before
public void setUp() throws Exception {
Method method = Handler.class.getDeclaredMethod("handle", Integer.class, String.class);
this.handlerMethod = new InvocableHandlerMethod(new Handler(), method);
this.webRequest = new ServletWebRequest(new MockHttpServletRequest(), new MockHttpServletResponse());
}
use of org.springframework.web.context.request.ServletWebRequest in project spring-framework by spring-projects.
the class RequestParamMethodArgumentResolverTests method resolveOptionalMultipartFile.
@Test
public void resolveOptionalMultipartFile() throws Exception {
ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer();
initializer.setConversionService(new DefaultConversionService());
WebDataBinderFactory binderFactory = new DefaultDataBinderFactory(initializer);
MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
MultipartFile expected = new MockMultipartFile("mfile", "Hello World".getBytes());
request.addFile(expected);
webRequest = new ServletWebRequest(request);
MethodParameter param = this.testMethod.annotPresent(RequestParam.class).arg(Optional.class, MultipartFile.class);
Object result = resolver.resolveArgument(param, null, webRequest, binderFactory);
assertTrue(result instanceof Optional);
assertEquals("Invalid result", expected, ((Optional<?>) result).get());
}
Aggregations