@Test
  public void pdxReadSerializedFlagShouldBeResetBackToOriginalValueAfterProcessingEvents() {
    ArgumentCaptor valueCapture = ArgumentCaptor.forClass(Boolean.class);
    doNothing().when(cache).setPdxReadSerializedOverride((Boolean) valueCapture.capture());

    boolean originalPdxReadSerialized = cache.getPdxReadSerializedOverride();
    try {
      cache.setPdxReadSerializedOverride(true);
      Assert.assertTrue((Boolean) valueCapture.getValue());
      listener.process(new LinkedList<>());
      Assert.assertTrue(!(Boolean) valueCapture.getValue());
    } finally {
      cache.setPdxReadSerializedOverride(originalPdxReadSerialized);
    }
  }
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