@Test
  public void testSimpleOps() throws CacheException {
    final CachePerfStats stats = cache.getCachePerfStats();
    // See if things are ok when no transaction
    checkNoTxState();

    txMgr.begin();
    // now that a transaction exists make sure things behave as expected
    assertTrue(txMgr.getTransactionId() != null);
    assertTrue(txMgr.exists());
    try {
      txMgr.begin();
      fail("expected IllegalStateException");
    } catch (IllegalStateException ignored) {
    }
    try {
      txMgr.commit();
    } catch (CommitConflictException unexpected) {
      fail("did not expect " + unexpected);
    }
    checkNoTxState();

    txMgr.begin();
    txMgr.rollback();
    checkNoTxState();

    region.put("uaKey", "val");

    {
      Region.Entry cmtre = region.getEntry("uaKey");
      cmtre.setUserAttribute("uaValue1");
      assertEquals("uaValue1", cmtre.getUserAttribute());

      long txRollbackChanges = stats.getTxRollbackChanges();
      long txCommitChanges = stats.getTxCommitChanges();
      long txFailureChanges = stats.getTxFailureChanges();
      txMgr.begin();
      Region.Entry txre = region.getEntry("uaKey");
      assertEquals(region, txre.getRegion());
      if (isPR()) {
        region.put("1", "one");
        try {
          txre.setUserAttribute("uaValue2");
        } catch (UnsupportedOperationException e) {
          // expected
        }
        try {
          txre.getUserAttribute();
        } catch (UnsupportedOperationException e) {
          // expected
        }
      } else {
        assertEquals("uaValue1", txre.getUserAttribute());
        txre.setUserAttribute("uaValue2");
        assertEquals("uaValue2", txre.getUserAttribute());
      }
      txMgr.rollback();
      try {
        txre.getValue();
        fail("expected IllegalStateException");
      } catch (IllegalStateException ignored) {
      }
      try {
        txre.isDestroyed();
        fail("expected IllegalStateException");
      } catch (IllegalStateException ignored) {
      }
      try {
        txre.getUserAttribute();
        fail("expected IllegalStateException");
      } catch (IllegalStateException ignored) {
      }
      try {
        txre.setUserAttribute("foo");
        fail("expected IllegalStateException");
      } catch (IllegalStateException ignored) {
      }
      assertEquals(txRollbackChanges + 1, stats.getTxRollbackChanges());
      assertEquals(txCommitChanges, stats.getTxCommitChanges());
      assertEquals(txFailureChanges, stats.getTxFailureChanges());

      assertEquals("uaValue1", cmtre.getUserAttribute());
    }

    {
      long txRollbackChanges = stats.getTxRollbackChanges();
      long txCommitChanges = stats.getTxCommitChanges();
      long txFailureChanges = stats.getTxFailureChanges();
      region.create("key1", "value1");
      txMgr.begin();
      region.invalidate("key1");
      txMgr.rollback();
      assertEquals(region.get("key1"), "value1");
      assertEquals(txRollbackChanges + 1, stats.getTxRollbackChanges());
      assertEquals(txCommitChanges, stats.getTxCommitChanges());
      assertEquals(txFailureChanges, stats.getTxFailureChanges());

      txRollbackChanges = stats.getTxRollbackChanges();
      txMgr.begin();
      region.destroy("key1");
      txMgr.rollback();
      assertEquals(region.get("key1"), "value1");
      assertEquals(txRollbackChanges + 1, stats.getTxRollbackChanges());
      assertEquals(txCommitChanges, stats.getTxCommitChanges());
      assertEquals(txFailureChanges, stats.getTxFailureChanges());

      txRollbackChanges = stats.getTxRollbackChanges();
      txMgr.begin();
      region.put("key1", "value2");
      txMgr.rollback();
      assertEquals(region.get("key1"), "value1");
      assertEquals(txRollbackChanges + 1, stats.getTxRollbackChanges());
      assertEquals(txCommitChanges, stats.getTxCommitChanges());
      assertEquals(txFailureChanges, stats.getTxFailureChanges());
    }
  }
Tests basic transaction functionality

@since GemFire 4.0
geode-core/src/integrationTest/java/org/apache/geode/TXJUnitTest.java