当前位置: 首页>>代码示例>>Java>>正文


Java MockMultipartHttpServletRequest.addFile方法代码示例

本文整理汇总了Java中org.springframework.mock.web.MockMultipartHttpServletRequest.addFile方法的典型用法代码示例。如果您正苦于以下问题:Java MockMultipartHttpServletRequest.addFile方法的具体用法?Java MockMultipartHttpServletRequest.addFile怎么用?Java MockMultipartHttpServletRequest.addFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.mock.web.MockMultipartHttpServletRequest的用法示例。


在下文中一共展示了MockMultipartHttpServletRequest.addFile方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldReturnHttpErrorCodeWhenChecksumFileSaveFails

import org.springframework.mock.web.MockMultipartHttpServletRequest; //导入方法依赖的package包/类
@Test
public void shouldReturnHttpErrorCodeWhenChecksumFileSaveFails() throws Exception {
    File artifactFile = new File("junk");
    when(artifactService.findArtifact(any(JobIdentifier.class), eq("some-path"))).thenReturn(artifactFile);
    when(artifactService.saveFile(any(File.class), any(InputStream.class), eq(false), eq(1))).thenReturn(true);
    when(artifactService.saveOrAppendFile(any(File.class), any(InputStream.class))).thenReturn(false);

    MockMultipartHttpServletRequest mockMultipartHttpServletRequest = new MockMultipartHttpServletRequest();
    mockMultipartHttpServletRequest.addFile(new MockMultipartFile(REGULAR_MULTIPART_FILENAME, "content".getBytes()));
    mockMultipartHttpServletRequest.addFile(new MockMultipartFile(CHECKSUM_MULTIPART_FILENAME, "checksum-content".getBytes()));

    ModelAndView modelAndView = artifactsController.postArtifact("pipeline-1", "1", "stage-1", "2", "job-1", 122L, "some-path", 1, mockMultipartHttpServletRequest);


    ResponseCodeView view = (ResponseCodeView) modelAndView.getView();
    assertThat(view.getStatusCode(), is(SC_INTERNAL_SERVER_ERROR));
    assertThat(view.getContent(), is("Error saving checksum file for the artifact at path 'some-path'"));
}
 
开发者ID:gocd,项目名称:gocd,代码行数:19,代码来源:ArtifactsControllerTest.java

示例2: createServletRequest

import org.springframework.mock.web.MockMultipartHttpServletRequest; //导入方法依赖的package包/类
/**
 * Create a new {@link MockMultipartHttpServletRequest} based on the
 * supplied {@code ServletContext} and the {@code MockMultipartFiles}
 * added to this builder.
 */
@Override
protected final MockHttpServletRequest createServletRequest(ServletContext servletContext) {
	MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest(servletContext);
	for (MockMultipartFile file : this.files) {
		request.addFile(file);
	}
	return request;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:14,代码来源:MockMultipartHttpServletRequestBuilder.java

示例3: createServletRequest

import org.springframework.mock.web.MockMultipartHttpServletRequest; //导入方法依赖的package包/类
/**
 * Create a new {@link MockMultipartHttpServletRequest} based on the supplied {@code
 * ServletContext} and the {@code MockMultipartFiles} added to this builder.
 */
@Override
protected final MockHttpServletRequest createServletRequest(ServletContext servletContext) {
  MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest(servletContext);
  for (MockMultipartFile file : this.files) {
    request.addFile(file);
  }
  return request;
}
 
开发者ID:reflectoring,项目名称:coderadar,代码行数:13,代码来源:ExtendedMockHttpServletRequestBuilder.java

示例4: testMultipartRequest

import org.springframework.mock.web.MockMultipartHttpServletRequest; //导入方法依赖的package包/类
@Test
public void testMultipartRequest() throws Exception {
    MockMultipartFile mockMultipartFile = new MockMultipartFile("schnobb.txt", "wobb".getBytes(Charset.forName("UTF-8")));

    MockMultipartHttpServletRequest mockRequest = new MockMultipartHttpServletRequest();
    mockRequest.addFile(mockMultipartFile);

    ParameterMap params = new ParameterMap(mockRequest);
    assertThat((MockMultipartFile) params.get("schnobb.txt"), sameInstance(mockMultipartFile));
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:11,代码来源:ParameterMapTests.java

示例5: createServletRequest

import org.springframework.mock.web.MockMultipartHttpServletRequest; //导入方法依赖的package包/类
@Override
protected final MockHttpServletRequest createServletRequest(ServletContext servletContext) {
	MockMultipartHttpServletRequest request =
			(servlet3Present ? createServlet3Request() : new MockMultipartHttpServletRequest());
	for (MockMultipartFile file : this.files) {
		request.addFile(file);
	}
	return request;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:10,代码来源:MockMultipartHttpServletRequestBuilder.java

示例6: mockMultipartHttpServletRequestWithByteArray

import org.springframework.mock.web.MockMultipartHttpServletRequest; //导入方法依赖的package包/类
@Test
public void mockMultipartHttpServletRequestWithByteArray() throws IOException {
	MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
	assertFalse(request.getFileNames().hasNext());
	assertNull(request.getFile("file1"));
	assertNull(request.getFile("file2"));
	assertTrue(request.getFileMap().isEmpty());

	request.addFile(new MockMultipartFile("file1", "myContent1".getBytes()));
	request.addFile(new MockMultipartFile("file2", "myOrigFilename", "text/plain", "myContent2".getBytes()));
	doTestMultipartHttpServletRequest(request);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:13,代码来源:MockMultipartHttpServletRequestTests.java

示例7: mockMultipartHttpServletRequestWithInputStream

import org.springframework.mock.web.MockMultipartHttpServletRequest; //导入方法依赖的package包/类
@Test
public void mockMultipartHttpServletRequestWithInputStream() throws IOException {
	MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
	request.addFile(new MockMultipartFile("file1", new ByteArrayInputStream("myContent1".getBytes())));
	request.addFile(new MockMultipartFile("file2", "myOrigFilename", "text/plain", new ByteArrayInputStream(
		"myContent2".getBytes())));
	doTestMultipartHttpServletRequest(request);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:9,代码来源:MockMultipartHttpServletRequestTests.java

示例8: getMockMultipartHttpServletRequestForMockObsWithComplexConcept

import org.springframework.mock.web.MockMultipartHttpServletRequest; //导入方法依赖的package包/类
/**
 * Convenience method constructing a multipart http servlet request for the tests
 */
public static MockMultipartHttpServletRequest getMockMultipartHttpServletRequestForMockObsWithComplexConcept() {
    MockMultipartHttpServletRequest mockRequest = new MockMultipartHttpServletRequest();
    mockRequest.addFile(getMockMultipartFileForMockObsWithComplexConcept());
    
    return mockRequest;
}
 
开发者ID:openmrs,项目名称:openmrs-module-radiology,代码行数:10,代码来源:RadiologyTestData.java


注:本文中的org.springframework.mock.web.MockMultipartHttpServletRequest.addFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。