@Test
  public void testSingleDispatcherWithTimer() {
    ForeignExceptionListener listener1 = Mockito.mock(ForeignExceptionListener.class);
    ForeignExceptionListener listener2 = Mockito.mock(ForeignExceptionListener.class);

    ForeignExceptionDispatcher monitor = new ForeignExceptionDispatcher();

    // add the listeners
    monitor.addListener(listener1);
    monitor.addListener(listener2);

    TimeoutExceptionInjector timer = new TimeoutExceptionInjector(monitor, 1000);
    timer.start();
    timer.trigger();

    assertTrue("Monitor didn't get timeout", monitor.hasException());

    // verify that that we propagated the error
    Mockito.verify(listener1).receive(Mockito.any());
    Mockito.verify(listener2).receive(Mockito.any());
  }
Tests that a dispatcher only dispatches only the first exception, and does not propagate
subsequent exceptions.
hbase-server/src/test/java/org/apache/hadoop/hbase/errorhandling/TestForeignExceptionDispatcher.java