ChallengeHandler { protected static <T extends ChallengeHandler> T create(Class<T> clazz) { return load0(clazz, ServiceLoader.load(clazz)); }  abstract boolean canHandle(ChallengeRequest challengeRequest); abstract ChallengeResponse handle(ChallengeRequest challengeRequest);  }
@Test public void shouldCorrectlyRetrieveAnEstablishedDefaultChallengeHandler() throws Exception { WebSocketFactory wsFactory = WebSocketFactory.createWebSocketFactory(); BasicChallengeHandler basicChallengeHandler = BasicChallengeHandler.create(); basicChallengeHandler.setLoginHandler(new LoginHandler() { @Override public PasswordAuthentication getCredentials() { return new PasswordAuthentication("global", "credentials".toCharArray()); } }); wsFactory.setDefaultChallengeHandler(basicChallengeHandler); Assert.assertSame(basicChallengeHandler, wsFactory.getDefaultChallengeHandler()); }