I'm using org.springiframework.web.client.RestTemplate For some Java tests to write unit tests for some new code. I expect these calls to fail (I'm testing authentication.)
Instead of returning a 401 code which is expected, or even a 500 code, the call throws an exception org.springiframework.web.client.HttpServerErrorException$InternalServerError.
Here's the call:
try {
e = restTemplate.exchange("https://myserver.local:8090/findByThread/100000", HttpMethod.GET, new HttpEntity(headers), Map.class, 100000L);
assertNotEquals(200, e.getStatusCode().value());
} catch(Exception ex) {
logger.info("Error");
ex.printStackTrace();
}
I suspect I'm missing something completely obvious, but I don't know what it is. Shouldn't this simply return a EntityResponse with a statusCode=401?