### Question:
ConsoleCommunicationImplementation implements ConsoleCommunication { public boolean processOneMessage() { while (true) { if (m_shutdown.get()) { return false; } if (m_processing.await(true)) { try { final Message message = m_receiver.waitForMessage(); if (message == null) { m_processing.set(false); } else { m_messageDispatcher.send(message); return true; } } catch (CommunicationException e) { m_errorHandler.handleException(e); } } } } ConsoleCommunicationImplementation(Resources resources,
			ConsoleProperties properties, ErrorHandler errorHandler,
			TimeAuthority timeAuthority);  ConsoleCommunicationImplementation(Resources resources,
                                            ConsoleProperties properties,
                                            ErrorHandler errorHandler,
                                            TimeAuthority timeAuthority,
                                            long idlePollDelay,
                                            long inactiveClientTimeOut); MessageDispatchRegistry getMessageDispatchRegistry(); @PreDestroy void shutdown(); boolean processOneMessage(); int getNumberOfConnections(); void sendToAgents(Message message); void sendToAddressedAgents(Address address, Message message);  }### Answer:
@Test public void testProcessOneMessage() throws Exception { m_consoleCommunication.getMessageDispatchRegistry() .addFallback(m_messageHandler); m_processMessagesThread.start(); final ProcessControl processControl = new ProcessControlImplementation(m_timer, m_consoleCommunication, s_resources); assertEquals(0, processControl.getNumberOfLiveAgents()); final StubAgentIdentity agentIdentity = new StubAgentIdentity("agent"); final Socket agentSocket = new StubConnector(InetAddress.getByName(null).getHostName(), m_properties.getConsolePort(), ConnectionType.AGENT) .connect(new AgentAddress(agentIdentity)); final AgentProcessReportMessage agentMessage = new AgentProcessReportMessage(State.STARTED, null); sendMessage(agentSocket, agentMessage); final WorkerProcessReportMessage message = new WorkerProcessReportMessage(State.STARTED, (short)0, (short)0); final Socket workerSocket = new StubConnector(InetAddress.getByName(null).getHostName(), m_properties.getConsolePort(), ConnectionType.WORKER) .connect(new WorkerAddress(agentIdentity.createWorkerIdentity())); sendMessage(workerSocket, message); sendMessage(workerSocket, new MyMessage()); verify(m_messageHandler, timeout(10000)).handle(isA(MyMessage.class)); assertEquals(1, processControl.getNumberOfLiveAgents()); sendMessage(workerSocket, new StopGrinderMessage()); verify(m_messageHandler, timeout(10000)) .handle(isA(StopGrinderMessage.class)); verifyNoMoreInteractions(m_messageHandler); }