AbstractHttpAuthenticationHandler implements HttpAuthenticationHandler { @Override public void sendChallenge(final HttpServletResponse response) { response.setHeader(AUTHENTICATE_HEADER, getAuthScheme() + " realm=\"" + getRealm() + "\""); response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); }  @Override boolean isLoginAttempt(final HttpServletRequest request); @Override void sendChallenge(final HttpServletResponse response);  }
@Test public void testSendChallenge() throws Exception { final MockHttpServletResponse response = new MockHttpServletResponse(); handler.sendChallenge(response); assertEquals("basic realm=\"realm\"", response.getHeader(AbstractHttpAuthenticationHandler.AUTHENTICATE_HEADER)); assertEquals(HttpServletResponse.SC_UNAUTHORIZED, response.getStatus()); }