Пример #1
0
 @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
 }
Пример #2
0
 @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);
 }
Пример #3
0
  @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);
  }
Пример #4
0
 @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);
 }
Пример #5
0
 @Test
 public void ensureHealthy_happyDay_onNoLimit() throws Exception {
   when(pool.getEvictAfterNumberOfUse()).thenReturn(0);
   ensureHealthy_happyDay(10);
   // no exception should have thrown
 }