@Test
public void testAwaitTermination() throws IOException, InterruptedException {

  MockChannelFactory factory = new MockChannelFactory();
  ChannelPool pool = new ChannelPool(factory, 1);
  for (ManagedChannel managedChannel : factory.channels) {
    when(managedChannel.isTerminated()).thenReturn(false);
  }
  pool.awaitTermination(500, TimeUnit.MILLISECONDS);
  for (ManagedChannel managedChannel : factory.channels) {
    verify(managedChannel, times(1)).awaitTermination(anyLong(), eq(TimeUnit.NANOSECONDS));
  }
}