@Test
public void invalidJson() {

    DelegatingAuthenticator authenticator = new DelegatingAuthenticator("jolokia", url + "/invalid","json:metadata/name", false);
    HttpExchange exchange = createHttpExchange(new Headers(), "Authorization", "Bearer blub");
    Authenticator.Result result = authenticator.authenticate(exchange);
    Authenticator.Failure failure = (Authenticator.Failure) result;
    assertEquals(failure.getResponseCode(), 422);
    String error = exchange.getResponseHeaders().getFirst("X-Error-Details");
    assertTrue(error.contains("Invalid JSON"));
}