public void testCustomRejectedExecutionHandler() { RejectedExecutionHandler handler = new RejectedExecutionHandler() { public void rejectedExecution(Runnable arg0, ThreadPoolExecutor arg1) { // nothing to do here } }; ThreadingProfile profile = new ThreadingProfile(); profile.setRejectedExecutionHandler(handler); ThreadPoolExecutor pool = profile.createPool("testPool"); assertSame(handler, pool.getRejectedExecutionHandler()); }
public void testCustomThreadFactory() { ThreadingProfile profile = new ThreadingProfile(); ThreadFactory configuredFactory = new ThreadFactory() { public Thread newThread(Runnable r) { return null; } }; profile.setThreadFactory(configuredFactory); ThreadPoolExecutor pool = profile.createPool(); ThreadFactory returnedFactory = pool.getThreadFactory(); assertSame(configuredFactory, returnedFactory); }
public void testDefaultNamedThreadFactory() { ThreadingProfile profile = new ThreadingProfile(); ThreadPoolExecutor pool = profile.createPool("myThreadPool"); ThreadFactory returnedFactory = pool.getThreadFactory(); assertTrue(returnedFactory instanceof NamedThreadFactory); }
public void testDefaultThreadFactory() { ThreadingProfile profile = new ThreadingProfile(); ThreadPoolExecutor pool = profile.createPool(); ThreadFactory returnedFactory = pool.getThreadFactory(); assertTrue(returnedFactory.getClass().isInstance(Executors.defaultThreadFactory())); }