Search in sources :

Example 1 with MockMultipartHttpServletRequest

use of org.springframework.mock.web.test.MockMultipartHttpServletRequest in project spring-framework by spring-projects.

the class ServletAnnotationControllerHandlerMethodTests method multipartFilesAsStringArray.

@Test
public void multipartFilesAsStringArray() throws Exception {
    initServletWithControllers(MultipartController.class);
    MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
    request.setRequestURI("/stringArray");
    request.addFile(new MockMultipartFile("content", "Juergen".getBytes()));
    request.addFile(new MockMultipartFile("content", "Eva".getBytes()));
    MockHttpServletResponse response = new MockHttpServletResponse();
    getServlet().service(request, response);
    assertEquals("Juergen-Eva", response.getContentAsString());
}
Also used : MockMultipartFile(org.springframework.mock.web.test.MockMultipartFile) MockMultipartHttpServletRequest(org.springframework.mock.web.test.MockMultipartHttpServletRequest) MockHttpServletResponse(org.springframework.mock.web.test.MockHttpServletResponse) Test(org.junit.Test)

Example 2 with MockMultipartHttpServletRequest

use of org.springframework.mock.web.test.MockMultipartHttpServletRequest in project spring-framework by spring-projects.

the class ServletAnnotationControllerHandlerMethodTests method multipartFileAsSingleString.

@Test
public void multipartFileAsSingleString() throws Exception {
    initServletWithControllers(MultipartController.class);
    MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
    request.setRequestURI("/singleString");
    request.addFile(new MockMultipartFile("content", "Juergen".getBytes()));
    MockHttpServletResponse response = new MockHttpServletResponse();
    getServlet().service(request, response);
    assertEquals("Juergen", response.getContentAsString());
}
Also used : MockMultipartFile(org.springframework.mock.web.test.MockMultipartFile) MockMultipartHttpServletRequest(org.springframework.mock.web.test.MockMultipartHttpServletRequest) MockHttpServletResponse(org.springframework.mock.web.test.MockHttpServletResponse) Test(org.junit.Test)

Example 3 with MockMultipartHttpServletRequest

use of org.springframework.mock.web.test.MockMultipartHttpServletRequest in project spring-framework by spring-projects.

the class ServletAnnotationControllerHandlerMethodTests method multipartFileAsStringArray.

@Test
public void multipartFileAsStringArray() throws Exception {
    initServletWithControllers(MultipartController.class);
    MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
    request.setRequestURI("/stringArray");
    request.addFile(new MockMultipartFile("content", "Juergen".getBytes()));
    MockHttpServletResponse response = new MockHttpServletResponse();
    getServlet().service(request, response);
    assertEquals("Juergen", response.getContentAsString());
}
Also used : MockMultipartFile(org.springframework.mock.web.test.MockMultipartFile) MockMultipartHttpServletRequest(org.springframework.mock.web.test.MockMultipartHttpServletRequest) MockHttpServletResponse(org.springframework.mock.web.test.MockHttpServletResponse) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 MockHttpServletResponse (org.springframework.mock.web.test.MockHttpServletResponse)3 MockMultipartFile (org.springframework.mock.web.test.MockMultipartFile)3 MockMultipartHttpServletRequest (org.springframework.mock.web.test.MockMultipartHttpServletRequest)3