@Test // parallel, PartitionedRegion, persistent, GatewayEventFilter
  public void testCacheClosedBeforeAEQWrite() {
    vm0.invoke(this::createCache);
    vm1.invoke(this::createCache);
    vm2.invoke(this::createCache);

    vm0.invoke(() -> createAsyncEventQueueWithGatewayEventFilter(asyncEventQueueId,
        new SpyAsyncEventListener(), new CloseCacheGatewayFilter(getCache(), 1000),
        createDiskStoreName(asyncEventQueueId), true, dispatcherThreadCount, true));
    vm1.invoke(() -> createAsyncEventQueueWithGatewayEventFilter(asyncEventQueueId,
        new SpyAsyncEventListener(), new CloseCacheGatewayFilter(getCache(), 1000),
        createDiskStoreName(asyncEventQueueId), true, dispatcherThreadCount, true));

    vm0.invoke(() -> createPartitionedRegion(partitionedRegionName, asyncEventQueueId, -1, 0, 16));
    vm1.invoke(() -> createPartitionedRegion(partitionedRegionName, asyncEventQueueId, -1, 0, 16));
    vm2.invoke(() -> createPartitionedRegionAccessor(partitionedRegionName, asyncEventQueueId, 16));

    vm2.invoke(() -> {
      Region<Integer, Integer> region = getCache().getRegion(partitionedRegionName);
      region.put(1, 1);
      region.put(2, 2);

      // This will trigger the gateway event filter to close the cache
      assertThatThrownBy(() -> region.removeAll(Collections.singleton(1)))
          .isInstanceOf(PartitionOfflineException.class);
    });
  }
Override as needed to add to the configuration, such as regionFactory.setOffHeap(boolean).
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/wan/asyncqueue/AsyncEventListenerWithFilterDistributedTest.java