@Test
public void testWithPoolSize() throws IOException {

  ScheduledExecutorService executor = new ScheduledThreadPoolExecutor(1);
  executor.shutdown();
  TransportChannelProvider provider =
      InstantiatingGrpcChannelProvider.newBuilder()
          .build()
          .withExecutor((Executor) executor)
          .withHeaders(Collections.<String, String>emptyMap())
          .withEndpoint("localhost:8080");
  assertThat(provider.acceptsPoolSize()).isTrue();
  // Make sure we can create channels OK.
  provider.getTransportChannel().shutdownNow();
  provider = provider.withPoolSize(2);
  assertThat(provider.acceptsPoolSize()).isFalse();
  provider.getTransportChannel().shutdownNow();
  try {
    provider.withPoolSize(3);
    fail("acceptsPoolSize() returned false; we shouldn't be able to set it again");
  } catch (IllegalStateException e) {
  }
}