@SuppressWarnings("unchecked") @Test public void testSetTimeoutMultipleClients() throws Exception { AsyncSSLClient client2 = mock(AsyncSSLClient.class); when(clientPool.acquire()).thenReturn(Futures.immediateFuture(client), Futures.immediateFuture(client2)); mockCallSuccess(client); mockCallSuccess(client2); ClientProxy<AsyncSSLClient> proxy = new ClientProxyImpl<>(executor, typeLiteral, clientPool); AsyncSSLClient clientProxy = proxy.get(); clientProxy.setTimeout(10); assertThat(performEchoCall(clientProxy, "foo"), is("foo")); assertThat(performEchoCall(clientProxy, "bar"), is("bar")); verify(clientPool, times(2)).acquire(); verify(client).setTimeout(10); verify(client2).setTimeout(10); verify(clientPool).release(client, true); verify(clientPool).release(client2, true); verifyNoMoreInteractions(clientPool); }
@Override @SuppressWarnings("unchecked") public synchronized C get() { return (C) this.enhancer.create( new Class[]{TProtocolFactory.class, TAsyncSSLClientManager.class, TNonblockingSSLTransport.class}, new Object[]{null, null, null}); }
ClientProxyImpl implements ClientProxy<C> { @Override @SuppressWarnings("unchecked") public synchronized C get() { return (C) this.enhancer.create( new Class[]{TProtocolFactory.class, TAsyncSSLClientManager.class, TNonblockingSSLTransport.class}, new Object[]{null, null, null}); } }
ClientProxyImpl implements ClientProxy<C> { @Override @SuppressWarnings("unchecked") public synchronized C get() { return (C) this.enhancer.create( new Class[]{TProtocolFactory.class, TAsyncSSLClientManager.class, TNonblockingSSLTransport.class}, new Object[]{null, null, null}); } @Inject  ClientProxyImpl(@Named("ClientProxyExecutor") ExecutorService executor,
                         TypeLiteral<C> type,
                         @Assisted final ClientPool<C> clientPool); }
ClientProxyImpl implements ClientProxy<C> { @Override @SuppressWarnings("unchecked") public synchronized C get() { return (C) this.enhancer.create( new Class[]{TProtocolFactory.class, TAsyncSSLClientManager.class, TNonblockingSSLTransport.class}, new Object[]{null, null, null}); } @Inject  ClientProxyImpl(@Named("ClientProxyExecutor") ExecutorService executor,
                         TypeLiteral<C> type,
                         @Assisted final ClientPool<C> clientPool); @Override @SuppressWarnings("unchecked") synchronized C get(); }
ClientProxyImpl implements ClientProxy<C> { @Override @SuppressWarnings("unchecked") public synchronized C get() { return (C) this.enhancer.create( new Class[]{TProtocolFactory.class, TAsyncSSLClientManager.class, TNonblockingSSLTransport.class}, new Object[]{null, null, null}); } @Inject  ClientProxyImpl(@Named("ClientProxyExecutor") ExecutorService executor,
                         TypeLiteral<C> type,
                         @Assisted final ClientPool<C> clientPool); @Override @SuppressWarnings("unchecked") synchronized C get();  }