다음과 같이 콘트롤러 테스트를 하려던 도중에 에러가 나옴.


@Test

public void fileViewTest() throws Exception{

mvc.perform(MockMvcRequestBuilders.get("/file/view/9ccf0428-437c-4ef7-bda2-267f8069cc7d_git37.PNG"))

.andExpect(status().isOk());

}


콘트롤러는 이미지를 보내주는데, 클라이언트가 이를 받지 못하기 때문인 것으로 보임. 헤더 문제 때문인 듯. 다음과 같이 헤더에 일부 추가해주니 제대로 됨.


@Test

public void fileViewTest() throws Exception{

mvc.perform(MockMvcRequestBuilders.get("/file/view/9ccf0428-437c-4ef7-bda2-267f8069cc7d_git37.PNG").accept(MediaType.IMAGE_PNG))

.andExpect(status().isOk());

}

Posted by 타다키치
,