0
mockmvc 테스트 junit 중에 302 오류가 발생했습니다. insertBoard 클래스의 리디렉션 문제입니다. 어떻게해야합니까? < 200>하지만했다 : 상태 예상 < 302>MockMvc - 예상 상태 : <200>하지만 : <302>
@RequestMapping(value="/sample/insertBoard.do")
public ModelAndView insertBoard(CommandMap commandMap,HttpServletRequest request) throws Exception{
ModelAndView mv = ModelAndView("redirect:/sample/openBoardList.do");
sampleService.insertBoard(commandMap.getMap(),request);
return mv;
}
@Test
public void testInsertBoard() throws Exception{
File fis = new File("c:\\users\\aaa.jpg");
FileInputStream fi1 = new FileInputStream(fis);
MockMultipartFile file = new MockMultipartFile("file",fis.getName(),"multipart/form-data",fi1);
this.mockMvc.perform(MockMvcRequestBuilders.fileupload("/sample/insertBoard.do"))
.file(file)
.param("title","title_test")
.param("contents","contents_test")
.contentType(MediaType.MULTIPART_FORM_DATA)
.andExpect(status().isOk());
}
미안 해요. 나는 이해할 수 없다. 그냥 testInsertBoard 테스트를 성공하고 싶습니다. – kim