/** Verify that the name of the thread created by LeaderSelector is set correctly. */ @Test public void testThreadName() throws Exception { final String expectedThreadName = "TestLeaderService"; final SettableFuture<String> actualThreadName = SettableFuture.create(); register(new LeaderService(_curator, PATH, "id", expectedThreadName, 1, TimeUnit.HOURS, new Supplier<Service>() { @Override public Service get() { return new AbstractService() { @Override protected void doStart() { actualThreadName.set(Thread.currentThread().getName()); notifyStarted(); } @Override protected void doStop() { notifyStopped(); } }; } })).startAsync(); assertEquals(expectedThreadName, actualThreadName.get(1, TimeUnit.MINUTES)); }