Example usage for org.apache.http.impl.client DefaultHttpClient getRoutePlanner

List of usage examples for org.apache.http.impl.client DefaultHttpClient getRoutePlanner

Introduction

In this page you can find the example usage for org.apache.http.impl.client DefaultHttpClient getRoutePlanner.

Prototype

public synchronized final HttpRoutePlanner getRoutePlanner() 

Source Link

Usage

From source file:org.sonatype.nexus.error.reporting.NexusPRConnectorTest.java

@Test
public void testNonProxyHosts() throws HttpException {
    final String host = "host";
    final int port = 1234;

    when(proxySettings.isEnabled()).thenReturn(true);
    when(proxySettings.getHostname()).thenReturn(host);
    when(proxySettings.getPort()).thenReturn(port);
    when(proxySettings.getNonProxyHosts()).thenReturn(Sets.newHashSet(".*"));

    final DefaultHttpClient client = (DefaultHttpClient) underTest.client();
    assertThat(ConnRouteParams.getDefaultProxy(client.getParams()), notNullValue());

    final HttpRoutePlanner planner = client.getRoutePlanner();
    final HttpRequest request = mock(HttpRequest.class);
    when(request.getParams()).thenReturn(mock(HttpParams.class));

    planner.determineRoute(new HttpHost("host"), request, mock(HttpContext.class));

    ArgumentCaptor<HttpParams> captor = ArgumentCaptor.forClass(HttpParams.class);

    verify(request).setParams(captor.capture());
    assertThat(ConnRouteParams.getDefaultProxy(captor.getValue()), nullValue());
}