2017-01-05 3 views
0

SpringMvc app 용 테스트를 작성 중이며 문제가 발생했습니다.SpringMVC testing with params

여기
@RequestMapping(value = "submit", method = RequestMethod.POST, params = "delete") 
public String delete(@ModelAttribute("inputBean") InputBean inputBean) { 
    Book book = (Book) itemServiceController.getItemFindByIdService().findById(inputBean.getId()); 
    Author author = getAuthorOfBook(book); 
    author.getBookList().remove(book); 
    authorServiceController.getAuthorCreateService().create(authorServiceController.getAuthorUpdateService().update(author)); 
    itemServiceController.getItemDeleteService().delete(inputBean.getId()); 
    return "redirect:index.html"; 
} 

내 mockMvc입니다 : 여기

테스트에 대한 내 컨트롤러 방법입니다

mockMvc.perform(post("/submit?delete") 
      .contentType(MediaType.APPLICATION_FORM_URLENCODED) 
      .param("id", "1") 
      .sessionAttr("inputBean", new InputBean()) 
      ) 
    .andExpect(status().isOk()) 
    .andExpect(view().name("indexLib")) 
    .andExpect(model().attribute("inputBean", hasProperty("id", is(1)))); 

이 반환 (400)

컨트롤러 방법은 1 ~ 4의 위해 만든 상태 HTTP 상태 양식 제출 단추. 이 문제를 해결하는 방법?

+0

해야 하는가? – hakamairi

답변

0
내가 답을 발견했습니다

, 적절한 URL은 당신이 얻을 실제 예외는 무엇입니까

"/submit?id=102&delete="