### Question:
InternalExecRuntime implements ExecRuntime, Cancellable { private void connectEndpoint(final ConnectionEndpoint endpoint, final HttpClientContext context) throws IOException { if (cancellableDependency != null) { if (cancellableDependency.isCancelled()) { throw new RequestFailedException("Request aborted"); } } final RequestConfig requestConfig = context.getRequestConfig(); final Timeout connectTimeout = requestConfig.getConnectTimeout(); if (log.isDebugEnabled()) { log.debug("{}: connecting endpoint ({})", ConnPoolSupport.getId(endpoint), connectTimeout); } manager.connect(endpoint, connectTimeout, context); if (log.isDebugEnabled()) { log.debug("{}: endpoint connected", ConnPoolSupport.getId(endpoint)); } } InternalExecRuntime(
            final Logger log,
            final HttpClientConnectionManager manager,
            final HttpRequestExecutor requestExecutor,
            final CancellableDependency cancellableDependency); @Override boolean isExecutionAborted(); @Override boolean isEndpointAcquired(); @Override void acquireEndpoint(
            final String id, final HttpRoute route, final Object object, final HttpClientContext context); @Override boolean isEndpointConnected(); @Override void connectEndpoint(final HttpClientContext context); @Override void disconnectEndpoint(); @Override void upgradeTls(final HttpClientContext context); @Override ClassicHttpResponse execute(
            final String id,
            final ClassicHttpRequest request,
            final HttpClientContext context); @Override boolean isConnectionReusable(); @Override void markConnectionReusable(final Object state, final TimeValue validDuration); @Override void markConnectionNonReusable(); @Override void releaseEndpoint(); @Override void discardEndpoint(); @Override boolean cancel(); @Override ExecRuntime fork(final CancellableDependency cancellableDependency);  }### Answer:
@Test public void testConnectEndpoint() throws Exception { final HttpClientContext context = HttpClientContext.create(); final RequestConfig config = RequestConfig.custom() .setConnectionRequestTimeout(345, TimeUnit.MILLISECONDS) .setConnectTimeout(123, TimeUnit.MILLISECONDS) .build(); context.setRequestConfig(config); Mockito.when(mgr.lease(Mockito.eq("some-id"), Mockito.eq(route), Mockito.<Timeout>any(), Mockito.any())) .thenReturn(leaseRequest); Mockito.when(leaseRequest.get(Mockito.<Timeout>any())).thenReturn(connectionEndpoint); execRuntime.acquireEndpoint("some-id", route, null, context); Assert.assertTrue(execRuntime.isEndpointAcquired()); Mockito.when(connectionEndpoint.isConnected()).thenReturn(false); Assert.assertFalse(execRuntime.isEndpointConnected()); execRuntime.connectEndpoint(context); Mockito.verify(mgr).connect(connectionEndpoint, Timeout.ofMilliseconds(123), context); }