AsyncServicePool implements com.bazaarvoice.ostrich.AsyncServicePool<S> { @Override public void close() throws IOException { if (_shutdownExecutorOnClose) { _executor.shutdown(); } if (_shutdownPoolOnClose) { _pool.close(); } _metrics.close(); } AsyncServicePool(Ticker ticker, ServicePool<S> pool, boolean shutdownPoolOnClose,
                            ExecutorService executor, boolean shutdownExecutorOnClose, MetricRegistry metrics); @Override void close(); @Override Future<R> execute(final RetryPolicy retryPolicy, final ServiceCallback<S, R> callback); @Override Future<R> execute(final PartitionContext partitionContext, final RetryPolicy retryPolicy,
                                 final ServiceCallback<S, R> callback); @Override Collection<Future<R>> executeOnAll(RetryPolicy retry, ServiceCallback<S, R> callback); @Override Collection<Future<R>> executeOn(ServiceEndPointPredicate predicate, final RetryPolicy retry,
                                               final ServiceCallback<S, R> callback); @Override int getNumValidEndPoints(); @Override int getNumBadEndPoints();  }
@Test public void testCloseDoesShutdownExecutor() throws IOException { AsyncServicePool<Service> pool = newAsyncPool(_mockExecutor, true); pool.close(); verify(_mockExecutor).shutdown(); }
@Test public void testCloseDoesNotShutdownExecutor() throws IOException { AsyncServicePool<Service> pool = newAsyncPool(_mockExecutor, false); pool.close(); verify(_mockExecutor, never()).shutdown(); }
@Test public void testCloseDoesShutdownPool() throws IOException { AsyncServicePool<Service> pool = newAsyncPool(_mockPool, true); pool.close(); verify(_mockPool).close(); }
@Test public void testCloseDoesNotShutdownPool() throws IOException { AsyncServicePool<Service> pool = newAsyncPool(_mockPool, false); pool.close(); verify(_mockPool, never()).close(); }