assertTrue( messageHandler.process(new StartGrinderMessage(new File("bah")))); assertTrue(messageHandler.process(new ResetGrinderMessage()));
messageDispatcher.send(new StartGrinderMessage(new File("bah"))); messageDispatcher.send(new ResetGrinderMessage());
  public void testCheckForMessageAndReceive() 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();    assertTrue(      messageHandler.process(new StartGrinderMessage(new File("foo"))));    assertFalse(messageHandler.process(new MyMessage()));    assertTrue(messageHandler.process(new ResetGrinderMessage()));    m_loggerFactory.assertSuccess("output", new Class[] { String.class });    m_loggerFactory.assertSuccess("output", new Class[] { String.class });    m_loggerFactory.assertNoMoreCalls();    assertFalse(listener.checkForMessage(ConsoleListener.ANY ^                                         (ConsoleListener.START |                                          ConsoleListener.RESET)));    assertTrue(listener.checkForMessage(ConsoleListener.START |                                        ConsoleListener.STOP));    assertTrue(listener.received(ConsoleListener.START));    assertFalse(listener.received(ConsoleListener.STOP));    assertTrue(listener.received(ConsoleListener.ANY));    assertFalse(listener.received(ConsoleListener.STOP |                                 ConsoleListener.RESET));    assertFalse(listener.received(ConsoleListener.STOP));    assertFalse(listener.received(ConsoleListener.SHUTDOWN));    assertFalse(listener.received(ConsoleListener.RESET));    assertFalse(listener.checkForMessage(ConsoleListener.START));    assertFalse(listener.received(ConsoleListener.ANY));    assertFalse(listener.received(ConsoleListener.START));    assertTrue(listener.checkForMessage(ConsoleListener.RESET));    assertTrue(listener.received(ConsoleListener.RESET));    assertTrue(listener.received(ConsoleListener.RESET));    assertFalse(listener.checkForMessage(ConsoleListener.RESET));    assertFalse(listener.received(ConsoleListener.RESET));    assertTrue(      messageHandler.process(new StartGrinderMessage(new File("bah"))));    assertTrue(messageHandler.process(new ResetGrinderMessage()));    m_loggerFactory.assertSuccess("output", new Class[] { String.class });    m_loggerFactory.assertSuccess("output", new Class[] { String.class });    m_loggerFactory.assertNoMoreCalls();    assertTrue(listener.checkForMessage(ConsoleListener.RESET |                                        ConsoleListener.START));    assertTrue(messageHandler.process(new ResetGrinderMessage()));    m_loggerFactory.assertSuccess("output", new Class[] { String.class });    m_loggerFactory.assertNoMoreCalls();    assertTrue(listener.checkForMessage(ConsoleListener.RESET |                                        ConsoleListener.START));    assertTrue(listener.received(ConsoleListener.RESET));    assertFalse(listener.checkForMessage(ConsoleListener.RESET |                                         ConsoleListener.START));    assertFalse(listener.received(ConsoleListener.START));    messageHandler.shutdown();    assertTrue(listener.checkForMessage(ConsoleListener.SHUTDOWN));    assertTrue(listener.received(ConsoleListener.SHUTDOWN));    assertTrue(listener.received(ConsoleListener.SHUTDOWN));  }