}
public void testIndirectClient() throws RequiresHttpAction {
final MockBaseClient<Credentials> client = new MockBaseClient<Credentials>(TYPE, false);
client.setCallbackUrl(CALLBACK_URL);
final MockWebContext context = MockWebContext.create();
client.redirect(context, false, false);
final String redirectionUrl = context.getResponseLocation();
assertEquals(CommonHelper.addParameter(CALLBACK_URL, BaseClient.NEEDS_CLIENT_REDIRECTION_PARAMETER, "true"),
redirectionUrl);
context.addRequestParameter(BaseClient.NEEDS_CLIENT_REDIRECTION_PARAMETER, "true");
try {
client.getCredentials(context);
fail("should throw RequiresHttpAction");
} catch (final RequiresHttpAction e) {
assertEquals(302, context.getResponseStatus());
assertEquals(LOGIN_URL, context.getResponseHeaders().get("Location"));
assertEquals("Needs client redirection", e.getMessage());
}
}