}
@Test
public void testExecRequestNonPersistentConnection() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpClientContext context = new HttpClientContext();
final RequestConfig config = RequestConfig.custom()
.setConnectTimeout(123)
.setSocketTimeout(234)
.setConnectionRequestTimeout(345)
.build();
context.setRequestConfig(config);
final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
Mockito.when(requestExecutor.execute(
Mockito.same(request),
Mockito.<HttpClientConnection>any(),
Mockito.<HttpClientContext>any())).thenReturn(response);
final CloseableHttpResponse finalResponse = mainClientExec.execute(
route, request, context, execAware);
Mockito.verify(connManager).requestConnection(route, null);
Mockito.verify(connRequest).get(345, TimeUnit.MILLISECONDS);
Mockito.verify(execAware, Mockito.times(1)).setCancellable(connRequest);
Mockito.verify(execAware, Mockito.times(2)).setCancellable(Mockito.<Cancellable>any());
Mockito.verify(connManager).connect(managedConn, route, 123, context);
Mockito.verify(connManager).routeComplete(managedConn, route, context);
Mockito.verify(managedConn).setSocketTimeout(234);
Mockito.verify(requestExecutor, Mockito.times(1)).execute(request, managedConn, context);
Mockito.verify(managedConn, Mockito.times(1)).close();
Mockito.verify(connManager).releaseConnection(managedConn, null, 0, TimeUnit.MILLISECONDS);
Assert.assertNotNull(context.getTargetAuthState());
Assert.assertNotNull(context.getProxyAuthState());
Assert.assertSame(managedConn, context.getConnection());
Assert.assertNull(context.getUserToken());
Assert.assertNotNull(finalResponse);
Assert.assertTrue(finalResponse instanceof HttpResponseProxy);
}