I am trying to test Spring MVC controller error response with the following
this.mockMvc
.perform(get("/healthChecks/9999"))
.andExpect(status().isNotFound())
.andExpect(jsonPath('error', is("Not Found")))
.andExpect(jsonPath('timestamp', is(notNullValue())))
.andExpect(jsonPath('status', is(404)))
.andExpect(jsonPath('path', is(notNullValue())))
but the test fails with the exception:
java.lang.IllegalArgumentException: json can not be null or empty
on the first jsonPath statement.
When I twist this url, I get the following:
{
"timestamp": 1470242437578,
"status": 200,
"error": "OK",
"exception": "gov.noaa.ncei.gis.web.HealthCheckNotFoundException",
"message": "could not find HealthCheck 9999.",
"path": "/healthChecks/9999"
}
Can anyone help me understand what I'm doing wrong?
source
share