@Test
  public void shouldThrowAndCaptureIOException() throws BucketNotFoundException {
    doAnswer((m) -> {
      throw new IOException();
    }).when(manager).getRepository(any(), any(), any());
    AtomicReference<Throwable> lastException = new AtomicReference<>();
    LuceneEventListener.setExceptionObserver(lastException::set);
    AsyncEvent event = Mockito.mock(AsyncEvent.class);
    try {
      listener.processEvents(Arrays.asList(event));
      fail("should have thrown an exception");
    } catch (InternalGemFireError expected) {
      assertEquals(expected, lastException.get());
    }
  }
Unit test that async event listener dispatched the events to the appropriate repository.
geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneEventListenerJUnitTest.java