### Question:
MessageBus implements IOFogModule { public void stop() { logInfo("Start closing receivers and publishers and stops ActiveMQ server"); if (receivers != null) { for (MessageReceiver receiver : receivers.values()) { try { receiver.close(); } catch (Exception e) { logError("Error closing receiver " + receiver.getName(), new AgentSystemException(e.getMessage(), e)); } } receivers.clear(); } if (publishers != null) { for (MessagePublisher publisher : publishers.values()) { try { publisher.close(); } catch (Exception e) { logError("Error closing publisher " + publisher.getName(), new AgentSystemException(e.getMessage(), e)); } } publishers.clear(); } try { messageBusServer.stopServer(); } catch (Exception exp) { logError("Error closing receivers and publishers and stops ActiveMQ server", new AgentSystemException(exp.getMessage(), exp)); } logInfo("Finished closing receivers and publishers and stops ActiveMQ server"); } private  MessageBus(); @Override int getModuleIndex(); @Override String getModuleName(); static MessageBus getInstance(); synchronized void enableRealTimeReceiving(String receiver); synchronized void disableRealTimeReceiving(String receiver); void update(); void instanceConfigUpdated(); void startServer(); void start(); void stop(); MessagePublisher getPublisher(String publisher); MessageReceiver getReceiver(String receiver); synchronized String getNextId(); synchronized Map<String, Route> getRoutes();  }### Answer:
@Test (timeout = 100000L) public void testStop() { try { initiateMockStart(); messageBus.stop(); Mockito.verify(messageBusServer, atLeastOnce()).stopServer(); PowerMockito.verifyStatic(LoggingService.class); LoggingService.logInfo(MODULE_NAME,"Start closing receivers and publishers and stops ActiveMQ server"); PowerMockito.verifyStatic(LoggingService.class); LoggingService.logInfo(MODULE_NAME,"Finished closing receivers and publishers and stops ActiveMQ server"); } catch (Exception e) { fail("This should not happen"); } }
@Test (timeout = 100000L) public void throwsExceptionWhenMessageServerStopIsCalled() { try { PowerMockito.doThrow(mock(Exception.class)).when(messageBusServer).stopServer(); initiateMockStart(); messageBus.stop(); Mockito.verify(messageBusServer, atLeastOnce()).stopServer(); PowerMockito.verifyStatic(LoggingService.class); LoggingService.logError(eq(MODULE_NAME), eq("Error closing receivers and publishers and stops ActiveMQ server"), any()); } catch (Exception e) { fail("This should not happen"); } }