I try to set the context path for spring rest mocks using the following code snippet:
private MockMvc mockMvc;
@Before
public void setUp() {
this.mockMvc
What many people do is simply not use the context path in mockMvc tests. You only specify the @RequestMapping
URI:
@Test
public void index() throws Exception {
this.mockMvc.perform(get("/business-case/1234").accept(MediaTypes.HAL_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("_links.business-cases", is(notNullValue())));
}