SingleThreadedClientServiceCache implements ServiceCache<S> { @VisibleForTesting GenericKeyedObjectPool<ServiceEndPoint, S> getPool() { return _pool; } SingleThreadedClientServiceCache(ServiceCachingPolicy policy, ServiceFactory<S> serviceFactory, MetricRegistry metrics); @VisibleForTesting  SingleThreadedClientServiceCache(ServiceCachingPolicy policy, ServiceFactory<S> serviceFactory, ScheduledExecutorService executor,
                                     MetricRegistry metrics); ServiceHandle<S> checkOut(ServiceEndPoint endPoint); @Override void checkIn(ServiceHandle<S> handle); @Override int getNumIdleInstances(ServiceEndPoint endPoint); @Override int getNumActiveInstances(ServiceEndPoint endPoint); @Override void close(); @Override void register(ServiceEndPoint endPoint); @Override void evict(ServiceEndPoint endPoint);  }
@Test public void testKeyedObjectPoolIsCorrectlyConfigured() { when(_cachingPolicy.getCacheExhaustionAction()).thenReturn(ServiceCachingPolicy.ExhaustionAction.GROW); when(_cachingPolicy.getMaxNumServiceInstances()).thenReturn(20); when(_cachingPolicy.getMaxNumServiceInstancesPerEndPoint()).thenReturn(5); when(_cachingPolicy.getMaxServiceInstanceIdleTime(TimeUnit.MILLISECONDS)).thenReturn(10L); GenericKeyedObjectPool<ServiceEndPoint, Service> pool = newCache().getPool(); assertEquals(GenericKeyedObjectPool.WHEN_EXHAUSTED_GROW, pool.getWhenExhaustedAction()); assertEquals(20, pool.getMaxTotal()); assertEquals(5, pool.getMaxActive()); assertEquals(5, pool.getMaxIdle()); assertEquals(10L, pool.getMinEvictableIdleTimeMillis()); assertEquals(20, pool.getNumTestsPerEvictionRun()); }