assertTrue(messageHandler.process(new StartGrinderMessage(new File("x")))); assertFalse(messageHandler.process(new MyMessage())); assertTrue(messageHandler.process(new ResetGrinderMessage()));
messageDispatcher.send(new StartGrinderMessage(new File("x"))); messageDispatcher.send(new MyMessage()); messageDispatcher.send(new ResetGrinderMessage());
  public void testDiscardMessages() throws Exception {    final Monitor myMonitor = new Monitor();    final ConsoleListener listener = new ConsoleListener(myMonitor, m_logger);    assertFalse(listener.checkForMessage(ConsoleListener.ANY));    assertFalse(listener.checkForMessage(ConsoleListener.RESET |                                         ConsoleListener.SHUTDOWN));    assertFalse(listener.checkForMessage(ConsoleListener.SHUTDOWN));    final MessageHandler messageHandler = listener.getMessageHandler();    listener.discardMessages(ConsoleListener.ANY);    assertTrue(messageHandler.process(new StartGrinderMessage(new File("x"))));    assertFalse(messageHandler.process(new MyMessage()));    assertTrue(messageHandler.process(new ResetGrinderMessage()));    assertTrue(listener.checkForMessage(ConsoleListener.START |                                        ConsoleListener.STOP));    assertTrue(listener.received(ConsoleListener.START));    assertFalse(listener.received(ConsoleListener.RESET));    listener.discardMessages(ConsoleListener.RESET);    assertFalse(listener.checkForMessage(ConsoleListener.RESET));    assertFalse(listener.received(ConsoleListener.RESET));    assertTrue(messageHandler.process(new ResetGrinderMessage()));    assertTrue(listener.checkForMessage(ConsoleListener.RESET));    listener.discardMessages(ConsoleListener.RESET);    assertFalse(listener.received(ConsoleListener.RESET));    listener.discardMessages(ConsoleListener.RESET);    assertFalse(listener.received(ConsoleListener.RESET));    messageHandler.shutdown();    assertTrue(listener.checkForMessage(ConsoleListener.SHUTDOWN));    assertTrue(listener.received(ConsoleListener.SHUTDOWN));    listener.discardMessages(ConsoleListener.SHUTDOWN);    assertFalse(listener.received(ConsoleListener.SHUTDOWN));  }