### Question:
CloseableExecutor implements AutoCloseable { public static CloseableExecutor of(ExecutorService executor) { return new CloseableExecutor(executor, Duration.ZERO); } private  CloseableExecutor(ExecutorService executorService, Duration duration); static CloseableExecutor of(ExecutorService executor); static CloseableExecutor of(ExecutorService executor, Duration duration); @Override void close();  }### Answer:
@Test public void testAutoClose() { ExecutorService mockExecutorService = mock(ExecutorService.class); try (CloseableExecutor ignored = CloseableExecutor.of(mockExecutorService)) { } verify(mockExecutorService).shutdown(); }
@Test public void testAutoCloseDuration() throws Exception { ExecutorService mockExecutorService = mock(ExecutorService.class); try (CloseableExecutor ignored = CloseableExecutor.of(mockExecutorService, Duration.ofSeconds(1))) { } verify(mockExecutorService).shutdown(); verify(mockExecutorService).awaitTermination(1000, TimeUnit.MILLISECONDS); }