### Question:
Server implements AutoCloseable { public static Builder builder() { return new Builder(); } Server(
      AddressResolver addressResolver,
      EventLoopGroup eventLoopGroup,
      boolean customEventLoop,
      Timer timer,
      boolean customTimer,
      long bindTimeoutInNanos,
      StubStore stubStore,
      boolean activityLogging,
      ServerBootstrap serverBootstrap); private  Server(
      AddressResolver addressResolver,
      EventLoopGroup eventLoopGroup,
      Class<? extends ServerChannel> channelClass,
      boolean customEventLoop,
      Timer timer,
      boolean customTimer,
      long bindTimeoutInNanos,
      StubStore stubStore,
      boolean activityLogging); boolean isClosed(); BoundCluster register(ClusterSpec.Builder builder); CompletionStage<BoundCluster> registerAsync(ClusterSpec.Builder builder); BoundCluster register(ClusterSpec cluster); CompletionStage<BoundCluster> registerAsync(ClusterSpec cluster); BoundCluster register(ClusterSpec cluster, ServerOptions serverOptions); @SuppressWarnings("unchecked") CompletionStage<BoundCluster> registerAsync(
      ClusterSpec cluster, ServerOptions serverOptions); BoundCluster unregister(BoundNode node); CompletionStage<BoundCluster> unregisterAsync(BoundNode node); BoundCluster unregister(BoundCluster cluster); CompletionStage<BoundCluster> unregisterAsync(BoundCluster cluster); BoundCluster unregister(Long clusterId); CompletionStage<BoundCluster> unregisterAsync(Long clusterId); Integer unregisterAll(); CompletionStage<Integer> unregisterAllAsync(); BoundNode register(NodeSpec.Builder builder); CompletionStage<BoundNode> registerAsync(NodeSpec.Builder builder); BoundNode register(NodeSpec node); CompletionStage<BoundNode> registerAsync(NodeSpec node); BoundNode register(NodeSpec node, ServerOptions serverOptions); CompletionStage<BoundNode> registerAsync(NodeSpec node, ServerOptions serverOptions); BoundCluster getCluster(long id); Collection<BoundCluster> getClusters(); static Builder builder(); CompletionStage<Void> closeAsync(); @Override void close();  }### Answer:
@Test public void testTryWithResourcesShouldCloseAllResources() throws Exception { EventLoopGroup eventLoop; Timer timer; try (Server server = Server.builder().build()) { eventLoop = server.eventLoopGroup; timer = server.timer; } assertThat(eventLoop.isShutdown()).isTrue(); try { timer.newTimeout( timeout -> { }, 1, TimeUnit.SECONDS); fail("Expected IllegalStateException"); } catch (IllegalStateException ise) { } }
@Test public void testTryWithResourcesShouldCloseAllClustersButNotTimerIfProvided() throws Exception { EventLoopGroup eventLoop; Timer timer = new HashedWheelTimer(); try (Server server = Server.builder().withTimer(timer).build()) { eventLoop = server.eventLoopGroup; } assertThat(eventLoop.isShutdown()).isTrue(); timer.newTimeout( timeout -> { }, 1, TimeUnit.SECONDS); timer.stop(); }