### Question:
WorkerLauncher { public boolean startSomeWorkers(int numberOfWorkers) throws EngineException { final int numberToStart = Math.min(numberOfWorkers, m_workers.length - m_nextWorkerIndex); for (int i = 0; i < numberToStart; ++i) { final int workerIndex = m_nextWorkerIndex; final Worker worker = m_workerFactory.create(System.out, System.err); synchronized (m_workers) { m_workers[workerIndex] = worker; } try { m_executor.execute( new InterruptibleRunnableAdapter(new WaitForWorkerTask(workerIndex))); } catch (RejectedExecutionException e) { m_logger.error("Failed to wait for " + worker.getIdentity().getName(), e); worker.destroy(); return false; } m_logger.info("worker " + worker.getIdentity().getName() + " started"); ++m_nextWorkerIndex; } return m_workers.length > m_nextWorkerIndex; } WorkerLauncher(int numberOfWorkers,
                        WorkerFactory workerFactory,
                        Condition notifyOnFinish,
                        Logger logger);   WorkerLauncher(ExecutorService executor,
                 int numberOfWorkers,
                 WorkerFactory workerFactory,
                 Condition notifyOnFinish,
                 Logger logger); void startAllWorkers(); boolean startSomeWorkers(int numberOfWorkers); boolean allFinished(); void shutdown(); void dontStartAnyMore(); void destroyAllWorkers();  }### Answer:
@Test public void testRejectedExecution() throws Exception { final WorkerIdentity workerIdentity = new AgentIdentityImplementation("test").createWorkerIdentity(); final WorkerFactory workerFactory = mock(WorkerFactory.class); final Worker worker = mock(Worker.class); when(worker.getIdentity()).thenReturn(workerIdentity); when(workerFactory.create(isA(OutputStream.class), isA(OutputStream.class))).thenReturn(worker); final ExecutorService executor = mock(ExecutorService.class); final WorkerLauncher workerLauncher = new WorkerLauncher(executor, 1, workerFactory, m_condition, m_logger); doThrow(new RejectedExecutionException()) .when(executor).execute(isA(Runnable.class)); final boolean result = workerLauncher.startSomeWorkers(1); assertFalse(result); verify(m_logger).error(eq("Failed to wait for test-0"), isA(Exception.class)); }