@Test(timeout = 10000)
 public void shutdownShouldNotLeadToThreadInitialization() throws InterruptedException {
   DaemonThreadFactory factory = new DaemonThreadFactory("42");
   util.setThreadFactory(factory);
   util.shutdownBackgroundExecutor();
   assertEquals(0, factory.getCreatedThreads());
 }
  @Test(timeout = 10000)
  public void shouldApplyThreadFactory() throws InterruptedException {
    ThreadFactory factory = new DaemonThreadFactory("42");
    util.setThreadFactory(factory);
    Executor executor = util.getBackgroundExecutor();

    CountDownLatch latch = new CountDownLatch(1);
    AtomicReference<String> threadName = new AtomicReference<>();
    executor.execute(
        () -> {
          threadName.set(Thread.currentThread().getName());
          latch.countDown();
        });

    latch.await();
    assertEquals("42", threadName.get());
  }
 @Test(expected = IllegalStateException.class)
 public void shouldDisallowReplaceThreadFactoryWhenExecutorAlreadyCreated() {
   util.getBackgroundExecutor();
   util.setThreadFactory(new DaemonThreadFactory(""));
 }