ContainerThreadFactory implements ThreadFactory { @Override public Thread newThread(Runnable target) { return delegate.newThread(target); } ContainerThreadFactory(MetricConsumerProvider metricConsumerProvider); @Override Thread newThread(Runnable target);  }
@Test public void requireThatThreadsCreatedAreJDiscContainerThreads() { assertEquals(ContainerThread.class, new ContainerThreadFactory(Mockito.mock(MetricConsumerProvider.class)) .newThread(Mockito.mock(Runnable.class)) .getClass()); }
@Test public void requireThatThreadFactoryCallsProvider() { MetricConsumerProvider provider = Mockito.mock(MetricConsumerProvider.class); ThreadFactory factory = new ContainerThreadFactory(provider); factory.newThread(Mockito.mock(Runnable.class)); Mockito.verify(provider, Mockito.times(1)).newInstance(); factory.newThread(Mockito.mock(Runnable.class)); Mockito.verify(provider, Mockito.times(2)).newInstance(); }