final MessageHandler messageHandler = listener.getMessageHandler();
final MessageDispatchSender messageDispatcher = new MessageDispatchSender(); listener.registerMessageHandlers(messageDispatcher);
  public void testWaitForMessage() throws Exception {    final Monitor myMonitor = new Monitor();    final ConsoleListener listener = new ConsoleListener(myMonitor, m_logger);    final MessageHandler messageHandler = listener.getMessageHandler();    final Thread t = new Thread() {        public void run() {          synchronized (myMonitor) {} // Wait until we're listening.          try {            messageHandler.process(new StartGrinderMessage(new File("lah")));          }          catch (CommunicationException e) {            e.printStackTrace();          }        }    };    synchronized (myMonitor) {      t.start();      listener.waitForMessage();    }    assertTrue(listener.received(ConsoleListener.START));  }