@Test
  public void testNoopInvalidates() throws CacheException {
    final CachePerfStats stats = cache.getCachePerfStats();
    TransactionListener tl = new TransactionListenerAdapter() {
      @Override
      public void afterRollback(TransactionEvent event) {
        te = event;
      }
    };
    txMgr.addListener(tl);
    // Make sure invalidates done on invalid entries are noops

    { // distributed invalidate
      // first make sure invalidate is counted as a change
      long txRollbackChanges = stats.getTxRollbackChanges();
      region.create("key1", "value1");
      txMgr.begin();
      region.invalidate("key1");
      txMgr.rollback();
      assertEquals(txRollbackChanges + 1, stats.getTxRollbackChanges());
      assertEquals(1, te.getEvents().size());
      region.destroy("key1");

      region.create("key1", "value1");
      txMgr.begin();
      region.invalidate("key1");
      txMgr.commit();
      assertEquals(1, te.getEvents().size());
      region.destroy("key1");

      // now make sure a committed entry that is invalid is not counted as a change
      txRollbackChanges = stats.getTxRollbackChanges();
      region.create("key1", "value1");
      region.invalidate("key1");
      txMgr.begin();
      region.invalidate("key1");
      txMgr.rollback();
      assertEquals(txRollbackChanges, stats.getTxRollbackChanges());
      assertEquals(0, te.getEvents().size());
      region.destroy("key1");

      region.create("key1", "value1");
      region.invalidate("key1");
      txMgr.begin();
      region.invalidate("key1");
      txMgr.commit();
      assertEquals(0, te.getEvents().size());
      region.destroy("key1");

      // now make sure that multiple invalidates of same entry are a single change
      txRollbackChanges = stats.getTxRollbackChanges();
      region.create("key1", "value1");
      txMgr.begin();
      region.invalidate("key1");
      region.invalidate("key1");
      region.invalidate("key1");
      txMgr.rollback();
      assertEquals(txRollbackChanges + 1, stats.getTxRollbackChanges());
      assertEquals(1, te.getEvents().size());
      region.destroy("key1");

      region.create("key1", "value1");
      txMgr.begin();
      region.invalidate("key1");
      region.invalidate("key1");
      region.invalidate("key1");
      txMgr.commit();
      assertEquals(1, te.getEvents().size());
      region.destroy("key1");
    }

    { // local invalidate
      // first make sure invalidate is counted as a change
      long txRollbackChanges = stats.getTxRollbackChanges();
      region.create("key1", "value1");
      txMgr.begin();
      region.localInvalidate("key1");
      txMgr.rollback();
      assertEquals(txRollbackChanges + 1, stats.getTxRollbackChanges());
      region.destroy("key1");

      // now make sure a committed entry that is invalid is not counted as a change
      txRollbackChanges = stats.getTxRollbackChanges();
      region.create("key1", "value1");
      region.localInvalidate("key1");
      txMgr.begin();
      region.localInvalidate("key1");
      txMgr.rollback();
      assertEquals(txRollbackChanges, stats.getTxRollbackChanges());
      region.destroy("key1");

      // now make sure that multiple localInvalidates of same entry are a single change
      txRollbackChanges = stats.getTxRollbackChanges();
      region.create("key1", "value1");
      txMgr.begin();
      region.localInvalidate("key1");
      region.localInvalidate("key1");
      region.localInvalidate("key1");
      txMgr.rollback();
      assertEquals(txRollbackChanges + 1, stats.getTxRollbackChanges());
      region.destroy("key1");
    }
  }
Test to make sure CacheListener callbacks are called in place with the CacheEvents properly
constructed
geode-core/src/integrationTest/java/org/apache/geode/TXJUnitTest.java