@Test
  public void testConflicts() throws CacheException {
    final TXManagerImpl txMgrImpl = (TXManagerImpl) txMgr;
    TXStateProxy tx;
    // try a put with no conflict to show that commit works
    txMgrImpl.begin();
    region.put("key1", "value1");
    txMgrImpl.commit();
    assertEquals("value1", region.get("key1"));
    region.localDestroy("key1");

    // now try a put with a conflict and make sure it is detected
    txMgrImpl.begin();
    region.put("key1", "value1");
    tx = txMgrImpl.pauseTransaction();
    region.put("key1", "value2"); // do a non-tx put to force conflict
    txMgrImpl.unpauseTransaction(tx);
    try {
      txMgrImpl.commit();
      fail("expected CommitConflictException");
    } catch (CommitConflictException ignored) {
    }
    assertEquals("value2", region.get("key1"));
    region.localDestroy("key1");

    // slightly difference version where value already exists in cmt state
    region.put("key1", "value0");
    txMgrImpl.begin();
    region.put("key1", "value1");
    txMgrImpl.commit();
    assertEquals("value1", region.get("key1"));
    region.localDestroy("key1");

    // now the conflict
    region.put("key1", "value0");
    txMgrImpl.begin();
    region.put("key1", "value1");
    tx = txMgrImpl.pauseTransaction();
    region.put("key1", "value2"); // do a non-tx put to force conflict
    txMgrImpl.unpauseTransaction(tx);
    try {
      txMgrImpl.commit();
      fail("expected CommitConflictException");
    } catch (CommitConflictException ignored) {
    }
    assertEquals("value2", region.get("key1"));
    region.localDestroy("key1");

    // now test create
    txMgrImpl.begin();
    region.create("key1", "value1");
    txMgrImpl.commit();
    assertEquals("value1", region.get("key1"));
    region.localDestroy("key1");

    // now try a create with a conflict and make sure it is detected
    txMgrImpl.begin();
    region.create("key1", "value1");
    tx = txMgrImpl.pauseTransaction();
    region.put("key1", "value2"); // do a non-tx put to force conflict
    txMgrImpl.unpauseTransaction(tx);
    try {
      txMgrImpl.commit();
      fail("expected CommitConflictException");
    } catch (CommitConflictException ignored) {
    }
    assertEquals("value2", region.get("key1"));
    region.localDestroy("key1");

    // test localInvalidate
    region.put("key1", "value0");
    txMgrImpl.begin();
    region.localInvalidate("key1");
    txMgrImpl.commit();
    assertTrue(region.containsKey("key1") && !region.containsValueForKey("key1"));
    region.localDestroy("key1");

    // now the conflict
    region.put("key1", "value0");
    txMgrImpl.begin();
    region.localInvalidate("key1");
    tx = txMgrImpl.pauseTransaction();
    region.put("key1", "value2"); // do a non-tx put to force conflict
    txMgrImpl.unpauseTransaction(tx);
    try {
      txMgrImpl.commit();
      fail("expected CommitConflictException");
    } catch (CommitConflictException ignored) {
    }
    assertEquals("value2", region.get("key1"));
    region.localDestroy("key1");

    // test invalidate
    region.put("key1", "value0");
    txMgrImpl.begin();
    region.invalidate("key1");
    txMgrImpl.commit();
    assertTrue(region.containsKey("key1") && !region.containsValueForKey("key1"));
    region.localDestroy("key1");

    // now the conflict
    region.put("key1", "value0");
    txMgrImpl.begin();
    region.invalidate("key1");
    tx = txMgrImpl.pauseTransaction();
    region.put("key1", "value2"); // do a non-tx put to force conflict
    txMgrImpl.unpauseTransaction(tx);
    try {
      txMgrImpl.commit();
      fail("expected CommitConflictException");
    } catch (CommitConflictException ignored) {
    }
    assertEquals("value2", region.get("key1"));
    region.localDestroy("key1");

    // check C + DD is a NOOP that still gets conflict if non-tx entry created */
    txMgr.begin();
    region.create("newKey", "valueTX");
    tx = txMgrImpl.pauseTransaction();
    region.create("newKey", "valueNONTX");
    txMgrImpl.unpauseTransaction(tx);
    region.destroy("newKey");
    assertTrue(!region.containsKey("key1"));
    try {
      txMgrImpl.commit();
      fail("expected CommitConflictException");
    } catch (CommitConflictException ignored) {
    }
    assertEquals("valueNONTX", region.get("newKey"));
    region.localDestroy("newKey");

    // check C + LD is a NOOP that still gets conflict if non-tx entry created */
    txMgr.begin();
    region.create("newKey", "valueTX");
    tx = txMgrImpl.pauseTransaction();
    region.create("newKey", "valueNONTX");
    txMgrImpl.unpauseTransaction(tx);
    region.localDestroy("newKey");
    assertTrue(!region.containsKey("key1"));
    try {
      txMgrImpl.commit();
      fail("expected CommitConflictException");
    } catch (CommitConflictException ignored) {
    }
    assertEquals("valueNONTX", region.get("newKey"));
    region.localDestroy("newKey");

    // test localDestroy
    region.put("key1", "value0");
    txMgrImpl.begin();
    region.localDestroy("key1");
    txMgrImpl.commit();
    assertTrue(!region.containsKey("key1"));

    // now the conflict
    region.put("key1", "value0");
    txMgrImpl.begin();
    region.localDestroy("key1");
    tx = txMgrImpl.pauseTransaction();
    region.put("key1", "value2"); // do a non-tx put to force conflict
    txMgrImpl.unpauseTransaction(tx);
    try {
      txMgrImpl.commit();
      fail("expected CommitConflictException");
    } catch (CommitConflictException ignored) {
    }
    assertEquals("value2", region.get("key1"));
    region.localDestroy("key1");

    // test destroy
    region.put("key1", "value0");
    txMgrImpl.begin();
    region.destroy("key1");
    txMgrImpl.commit();
    assertTrue(!region.containsKey("key1"));

    // now the conflict
    region.put("key1", "value0");
    txMgrImpl.begin();
    region.destroy("key1");
    tx = txMgrImpl.pauseTransaction();
    region.put("key1", "value2"); // do a non-tx put to force conflict
    txMgrImpl.unpauseTransaction(tx);
    try {
      txMgrImpl.commit();
      fail("expected CommitConflictException");
    } catch (CommitConflictException ignored) {
    }
    assertEquals("value2", region.get("key1"));
    region.localDestroy("key1");

    checkUserAttributeConflict(txMgrImpl);

    // make sure non-tx local-invalidate followed by invalidate
    // does not cause conflict
    region.create("key1", "val1");
    region.localInvalidate("key1");
    txMgrImpl.begin();
    region.put("key1", "txVal1");
    tx = txMgrImpl.pauseTransaction();
    region.invalidate("key1");
    txMgrImpl.unpauseTransaction(tx);
    txMgrImpl.commit();
    assertEquals("txVal1", region.getEntry("key1").getValue());
    region.destroy("key1");

    // now try a put and a region destroy.
    txMgrImpl.begin();
    region.create("key1", "value1");
    TXStateProxy tis = txMgrImpl.pauseTransaction();
    region.localDestroyRegion(); // non-tx
    txMgrImpl.unpauseTransaction(tis);

    try {
      txMgrImpl.commit();
      fail("expected CommitConflictException");
    } catch (TransactionException ignored) {
    }
  }
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