### Question:
ConsoleListener { public void waitForMessage() { while (!checkForMessage(ConsoleListener.ANY)) { synchronized (m_notifyOnMessage) { m_notifyOnMessage.waitNoInterrruptException(); } } } ConsoleListener(Condition notifyOnMessage, Logger logger); void shutdown(); void waitForMessage(); boolean checkForMessage(int mask); void discardMessages(int mask); synchronized boolean received(int mask); void registerMessageHandlers(
    MessageDispatchRegistry messageDispatcher); StartGrinderMessage getLastStartGrinderMessage(); static final int START; static final int RESET; static final int STOP; static final int SHUTDOWN; static final int ANY; }### Answer:
@Test public void testWaitForMessage() throws Exception { final Condition myCondition = new Condition(); final ConsoleListener listener = new ConsoleListener(myCondition, m_logger); final MessageDispatchSender messageDispatcher = new MessageDispatchSender(); listener.registerMessageHandlers(messageDispatcher); final Thread t = new Thread() { public void run() { synchronized (myCondition) { try { messageDispatcher.send( new StartGrinderMessage(new GrinderProperties(), -1)); } catch (CommunicationException e) { e.printStackTrace(); } } } }; synchronized (myCondition) { t.start(); listener.waitForMessage(); } assertTrue(listener.received(ConsoleListener.START)); }