Java Code Examples for org.springframework.mock.web.test.MockMultipartHttpServletRequest#setParameter()
The following examples show how to use
org.springframework.mock.web.test.MockMultipartHttpServletRequest#setParameter() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RequestPartServletServerHttpRequestTests.java From spring-analysis-note with MIT License | 6 votes |
@Test // SPR-13096 public void getBodyViaRequestParameter() throws Exception { MockMultipartHttpServletRequest mockRequest = new MockMultipartHttpServletRequest() { @Override public HttpHeaders getMultipartHeaders(String paramOrFileName) { HttpHeaders headers = new HttpHeaders(); headers.setContentType(new MediaType("application", "octet-stream", StandardCharsets.ISO_8859_1)); return headers; } }; byte[] bytes = {(byte) 0xC4}; mockRequest.setParameter("part", new String(bytes, StandardCharsets.ISO_8859_1)); ServerHttpRequest request = new RequestPartServletServerHttpRequest(mockRequest, "part"); byte[] result = FileCopyUtils.copyToByteArray(request.getBody()); assertArrayEquals(bytes, result); }
Example 2
Source File: RequestPartServletServerHttpRequestTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void getBodyViaRequestParameterWithRequestEncoding() throws Exception { MockMultipartHttpServletRequest mockRequest = new MockMultipartHttpServletRequest() { @Override public HttpHeaders getMultipartHeaders(String paramOrFileName) { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); return headers; } }; byte[] bytes = {(byte) 0xC4}; mockRequest.setParameter("part", new String(bytes, StandardCharsets.ISO_8859_1)); mockRequest.setCharacterEncoding("iso-8859-1"); ServerHttpRequest request = new RequestPartServletServerHttpRequest(mockRequest, "part"); byte[] result = FileCopyUtils.copyToByteArray(request.getBody()); assertArrayEquals(bytes, result); }
Example 3
Source File: RequestPartServletServerHttpRequestTests.java From java-technology-stack with MIT License | 6 votes |
@Test // SPR-13096 public void getBodyViaRequestParameter() throws Exception { MockMultipartHttpServletRequest mockRequest = new MockMultipartHttpServletRequest() { @Override public HttpHeaders getMultipartHeaders(String paramOrFileName) { HttpHeaders headers = new HttpHeaders(); headers.setContentType(new MediaType("application", "octet-stream", StandardCharsets.ISO_8859_1)); return headers; } }; byte[] bytes = {(byte) 0xC4}; mockRequest.setParameter("part", new String(bytes, StandardCharsets.ISO_8859_1)); ServerHttpRequest request = new RequestPartServletServerHttpRequest(mockRequest, "part"); byte[] result = FileCopyUtils.copyToByteArray(request.getBody()); assertArrayEquals(bytes, result); }
Example 4
Source File: RequestPartServletServerHttpRequestTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void getBodyViaRequestParameterWithRequestEncoding() throws Exception { MockMultipartHttpServletRequest mockRequest = new MockMultipartHttpServletRequest() { @Override public HttpHeaders getMultipartHeaders(String paramOrFileName) { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); return headers; } }; byte[] bytes = {(byte) 0xC4}; mockRequest.setParameter("part", new String(bytes, StandardCharsets.ISO_8859_1)); mockRequest.setCharacterEncoding("iso-8859-1"); ServerHttpRequest request = new RequestPartServletServerHttpRequest(mockRequest, "part"); byte[] result = FileCopyUtils.copyToByteArray(request.getBody()); assertArrayEquals(bytes, result); }
Example 5
Source File: RequestPartServletServerHttpRequestTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void getBodyViaRequestParameter() throws Exception { MockMultipartHttpServletRequest mockRequest = new MockMultipartHttpServletRequest() { @Override public HttpHeaders getMultipartHeaders(String paramOrFileName) { HttpHeaders headers = new HttpHeaders(); headers.setContentType(new MediaType("application", "octet-stream", Charset.forName("iso-8859-1"))); return headers; } }; byte[] bytes = {(byte) 0xC4}; mockRequest.setParameter("part", new String(bytes, Charset.forName("iso-8859-1"))); ServerHttpRequest request = new RequestPartServletServerHttpRequest(mockRequest, "part"); byte[] result = FileCopyUtils.copyToByteArray(request.getBody()); assertArrayEquals(bytes, result); }
Example 6
Source File: RequestPartServletServerHttpRequestTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void getBodyViaRequestParameterWithRequestEncoding() throws Exception { MockMultipartHttpServletRequest mockRequest = new MockMultipartHttpServletRequest() { @Override public HttpHeaders getMultipartHeaders(String paramOrFileName) { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); return headers; } }; byte[] bytes = {(byte) 0xC4}; mockRequest.setParameter("part", new String(bytes, Charset.forName("iso-8859-1"))); mockRequest.setCharacterEncoding("iso-8859-1"); ServerHttpRequest request = new RequestPartServletServerHttpRequest(mockRequest, "part"); byte[] result = FileCopyUtils.copyToByteArray(request.getBody()); assertArrayEquals(bytes, result); }