1
내가 uploadfiles이 엔트리 포인트를 가지고 있고, 그것을 잘 작동 :봄 테스트 + 서블릿 3.0 + 멀티 - 설정 태그
@RequestMapping(value = "/importarPedidosRepresentante", method = RequestMethod.POST)
@ResponseBody
public List<ImportacaoPVEResultado> importarPedidoRepresentanteZip(@RequestParam MultipartFile pedidosZip) throws JsonParseException, JsonMappingException, IOException {
....
}
을 지금, 나는이 봄 테스트 프레임 워크를 사용하여 JUnit 테스트를 만들려고 해요 :
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration(classes = MvcConfiguration.class, loader = AnnotationConfigWebContextLoader.class)
public class TestRepresentantesServices {
private MockMvc mvc;
....
@Test
public void testZip() throws Exception {
MockMultipartFile file = new MockMultipartFile("pedidosZip", "pedidos.zip", MediaType.APPLICATION_OCTET_STREAM_VALUE, jsonZip);
MockHttpServletRequestBuilder request = MockMvcRequestBuilders.fileUpload("/representantes/importarPedidosRepresentante").file(file).contentType(MediaType.MULTIPART_FORM_DATA);
ResultActions resp = mvc.perform(request); /// <-- java.lang.AssertionError: Status expected:<200> but was:<400>
}
}
나는이 주장에 오류 받고 있어요
: 내가 잘못
java.lang.AssertionError: Status expected:<200> but was:<400>
at org.springframework.test.util.AssertionErrors.fail(AssertionErrors.java:60)
at org.springframework.test.util.AssertionErrors.assertEquals(AssertionErrors.java:89)
at org.springframework.test.web.servlet.result.StatusResultMatchers$5.match(StatusResultMatchers.java:549)
at org.springframework.test.web.servlet.MockMvc.applyDefaultResultActions(MockMvc.java:159)
at org.springframework.test.web.servlet.MockMvc.perform(MockMvc.java:136)
at br.com.jjw.jjwxp.web.test.representantes.controllers.TestRepresentantesServices.testZip(TestRepresentantesServices.java:425)
을하고있어 무엇을? 당신이 당신의 컨트롤러 방법
@RequestPart MultipartFile pedidosZip
를 기대한다 그러나
HTTP 400 means: Bad Request
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.