Thread t = factory.newThread(mock(Runnable.class));
assertTrue(t.getName().startsWith("test "));
}
public void testNewThreadDelegation() throws Exception {
ThreadFactory delegate = mock(ThreadFactory.class);
when(delegate.newThread(any(Runnable.class))).thenReturn(new Thread("thread"));
PrefixedThreadFactory factory = new PrefixedThreadFactory(delegate, "test ");
Thread t = factory.newThread(mock(Runnable.class));
verify(delegate).newThread(any(Runnable.class));
assertEquals(t.getName(), "test thread");
}