### Question:
GrinderProcess { public void shutdown(final boolean inputStreamIsStdin) { if (!inputStreamIsStdin) { m_messagePump.shutdown(); } if (m_logbackLoggerContext != null) { m_logbackLoggerContext.stop(); } } GrinderProcess(final Receiver agentReceiver); void run(); void shutdown(final boolean inputStreamIsStdin);  }### Answer:
@Test public void testThreadContextsThreadCreated() throws Exception { final ThreadContexts threadContexts = new ThreadContexts(); final ThreadContext threadContext = mock(ThreadContext.class); when(threadContext.getThreadNumber()).thenReturn(99); threadContexts.threadCreated(threadContext); final ArgumentCaptor<ThreadLifeCycleListener> listenerCaptor= ArgumentCaptor.forClass(ThreadLifeCycleListener.class); verify(threadContext) .registerThreadLifeCycleListener(listenerCaptor.capture()); listenerCaptor.getValue().endThread(); assertFalse(threadContexts.shutdown(99)); }
@Test public void testThreadContextsShutdown() throws Exception { final ThreadContexts threadContexts = new ThreadContexts(); assertFalse(threadContexts.shutdown(2)); final ThreadContext threadContext = mock(ThreadContext.class); when(threadContext.getThreadNumber()).thenReturn(2); threadContexts.threadCreated(threadContext); assertTrue(threadContexts.shutdown(2)); assertTrue(threadContexts.shutdown(2)); verify(threadContext, times(2)).shutdown(); }
@Test public void testThreadContextsShutdownAll() throws Exception { final ThreadContexts threadContexts = new ThreadContexts(); final ThreadContext threadContext1 = mock(ThreadContext.class); when(threadContext1.getThreadNumber()).thenReturn(1); threadContexts.threadCreated(threadContext1); final ThreadContext threadContext2 = mock(ThreadContext.class); when(threadContext2.getThreadNumber()).thenReturn(2); threadContexts.threadCreated(threadContext2); threadContexts.shutdownAll(); verify(threadContext1).shutdown(); verify(threadContext2).shutdown(); final ThreadContext threadContext3 = mock(ThreadContext.class); when(threadContext3.getThreadNumber()).thenReturn(2); threadContexts.threadCreated(threadContext3); verify(threadContext3).shutdown(); }
@Test public void testCoverNullQueuedSender() throws Exception { final QueuedSender sender = new GrinderProcess.NullQueuedSender(); sender.send(null); sender.send(null); sender.flush(); sender.shutdown(); sender.send(null); sender.send(null); sender.flush(); sender.shutdown(); }