use of org.apache.http.client.RedirectStrategy in project dropwizard by dropwizard.
the class HttpClientBuilderTest method usesACustomRedirectStrategy.
@Test
public void usesACustomRedirectStrategy() throws Exception {
RedirectStrategy neverFollowRedirectStrategy = new RedirectStrategy() {
@Override
public boolean isRedirected(HttpRequest httpRequest, HttpResponse httpResponse, HttpContext httpContext) throws ProtocolException {
return false;
}
@Override
public HttpUriRequest getRedirect(HttpRequest httpRequest, HttpResponse httpResponse, HttpContext httpContext) throws ProtocolException {
return null;
}
};
ConfiguredCloseableHttpClient client = builder.using(neverFollowRedirectStrategy).createClient(apacheBuilder, connectionManager, "test");
assertThat(client).isNotNull();
assertThat(spyHttpClientBuilderField("redirectStrategy", apacheBuilder)).isSameAs(neverFollowRedirectStrategy);
}
Aggregations