@Test
 public void ensureHealthy_happyDay_whenWithinLimit() throws Exception {
   final int limit = 10;
   when(pool.getEvictAfterNumberOfUse()).thenReturn(limit);
   ensureHealthy_happyDay(limit);
   // no exception should have thrown
 }
 @Test
 public void ensureHealthy_chokes_whenOutOfLimit() throws Exception {
   final int limit = 10;
   when(pool.getEvictAfterNumberOfUse()).thenReturn(limit);
   exception.expect(GMServiceException.class);
   ensureHealthy_happyDay(limit + 1);
 }
  @Test
  public void constructor_chokes_whenCreateReaderWriterFails() throws Exception {
    when(pool.createProcess()).thenThrow(new GMServiceException(READER_WRITER_PROCESS_FAILURE));

    exception.expect(GMServiceException.class);
    exception.expectMessage(READER_WRITER_PROCESS_FAILURE);

    new PooledGMConnection(pool);
  }
 @Override
 @Before
 public void setup() throws Exception {
   super.setup();
   final ArgumentCaptor<String> gmPathCaptor = ArgumentCaptor.forClass(String.class);
   when(builder.buildFactory(gmPathCaptor.capture())).thenReturn(factory);
   when(factory.getProcess()).thenReturn(process);
   when(factory.getGMPath())
       .then(
           new Answer<String>() {
             @Override
             public String answer(InvocationOnMock invocation) throws Throwable {
               return gmPathCaptor.getValue();
             }
           });
   pool.setProcessFactoryBuilder(builder);
   when(pool.createProcess()).thenReturn(process);
   sut = new PooledGMConnection(pool);
 }
 @Test
 public void ensureHealthy_happyDay_onNoLimit() throws Exception {
   when(pool.getEvictAfterNumberOfUse()).thenReturn(0);
   ensureHealthy_happyDay(10);
   // no exception should have thrown
 }