@Test
  public void testListener() {
    assertTrue(txMgr.getListener() == null);
    TransactionListener oldListener = txMgr.setListener(new TransactionListener() {
      @Override
      public void afterCommit(TransactionEvent event) {
        listenerAfterCommit = 1;
        te = event;
      }

      @Override
      public void afterFailedCommit(TransactionEvent event) {
        listenerAfterFailedCommit = 1;
        te = event;
      }

      @Override
      public void afterRollback(TransactionEvent event) {
        listenerAfterRollback = 1;
        te = event;
      }

      @Override
      public void close() {
        listenerClose = 1;
      }
    });
    assertTrue(oldListener == null);
    txMgr.begin();
    TransactionId myTxId = txMgr.getTransactionId();
    assertEquals(0, listenerAfterRollback);
    txMgr.rollback();
    assertEquals(1, listenerAfterRollback);
    assertEquals(0, TxEventTestUtil.getCreateEvents(te.getEvents()).size());
    assertEquals(0, TxEventTestUtil.getPutEvents(te.getEvents()).size());
    assertEquals(0, TxEventTestUtil.getInvalidateEvents(te.getEvents()).size());
    assertEquals(0, TxEventTestUtil.getDestroyEvents(te.getEvents()).size());
    assertEquals(0, te.getEvents().size());
    assertEquals(myTxId, te.getTransactionId());

    txMgr.begin();
    myTxId = txMgr.getTransactionId();
    try {
      assertEquals(0, listenerAfterCommit);
      txMgr.commit();
    } catch (CommitConflictException unexpected) {
      fail("did not expect " + unexpected);
    }
    assertEquals(1, listenerAfterCommit);
    assertEquals(0, TxEventTestUtil.getCreateEvents(te.getEvents()).size());
    assertEquals(0, TxEventTestUtil.getPutEvents(te.getEvents()).size());
    assertEquals(0, TxEventTestUtil.getInvalidateEvents(te.getEvents()).size());
    assertEquals(0, TxEventTestUtil.getDestroyEvents(te.getEvents()).size());
    assertEquals(0, te.getEvents().size());
    assertEquals(myTxId, te.getTransactionId());

    assertEquals(0, listenerClose);
    oldListener = txMgr.setListener(new TransactionListener() {
      @Override
      public void afterCommit(TransactionEvent event) {
        listenerAfterCommit = 2;
        te = event;
      }

      @Override
      public void afterFailedCommit(TransactionEvent event) {
        listenerAfterFailedCommit = 2;
      }

      @Override
      public void afterRollback(TransactionEvent event) {
        listenerAfterRollback = 2;
        te = event;
      }

      @Override
      public void close() {
        listenerClose = 2;
      }
    });
    assertEquals(1, listenerClose);

    txMgr.begin();
    assertEquals(1, listenerAfterRollback);
    txMgr.rollback();
    assertEquals(2, listenerAfterRollback);
    txMgr.begin();
    txMgr.setListener(oldListener);
    assertEquals(2, listenerClose);
    txMgr.rollback();
    assertEquals(1, listenerAfterRollback);

    closeCache();
    assertEquals(1, listenerClose);
  }
Tests basic transaction functionality

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