Examples of DummyTransactionListener


Examples of com.sun.sgs.test.util.DummyTransactionListener

  listener.assertCalled(false, CalledAfter.NO);
    }

    @Test
    public void testRegisterListenerPreparing() throws Exception {
  final DummyTransactionListener listener =
      new DummyTransactionListener();
  final Exception[] exception = { null };
  DummyTransactionParticipant[] participants = {
      new DummyNonDurableTransactionParticipant() {
    public boolean prepare(Transaction txn) throws Exception {
        try {
      txn.registerListener(listener);
        } catch (Exception e) {
      exception[0] = e;
        }
        return super.prepare(txn);
    }
      },
      new DummyTransactionParticipant()
  };
  for (TransactionParticipant participant : participants) {
      txn.join(participant);
  }
  handle.commit();
  if (exception[0] instanceof TransactionNotActiveException) {
      System.err.println(exception[0]);
  } else {
      fail("Expected TransactionNotActiveException: " + exception[0]);
  }
  listener.assertCalled(false, CalledAfter.NO);
    }
View Full Code Here

Examples of com.sun.sgs.test.util.DummyTransactionListener

  listener.assertCalled(false, CalledAfter.NO);
    }

    @Test
    public void testRegisterListenerPrepareAndCommitting() throws Exception {
  final DummyTransactionListener listener =
      new DummyTransactionListener();
  final Exception[] exception = { null };
  DummyTransactionParticipant participant =
      new DummyTransactionParticipant() {
    public void prepareAndCommit(Transaction txn)
        throws Exception
    {
        try {
      txn.registerListener(listener);
        } catch (Exception e) {
      exception[0] = e;
        }
        super.prepareAndCommit(txn);
    }
      };
  txn.join(participant);
  handle.commit();
  if (exception[0] instanceof TransactionNotActiveException) {
      System.err.println(exception[0]);
  } else {
      fail("Expected TransactionNotActiveException: " + exception[0]);
  }
  listener.assertCalled(false, CalledAfter.NO);
    }
View Full Code Here

Examples of com.sun.sgs.test.util.DummyTransactionListener

  listener.assertCalled(false, CalledAfter.NO);
    }

    @Test
    public void testRegisterListenerCommitting() throws Exception {
  final DummyTransactionListener listener =
      new DummyTransactionListener();
  final Exception[] exception = { null };
  DummyTransactionParticipant[] participants = {
      new DummyNonDurableTransactionParticipant() {
    public void commit(Transaction txn) {
        try {
      txn.registerListener(listener);
        } catch (Exception e) {
      exception[0] = e;
        }
        super.commit(txn);
    }
      },
      new DummyTransactionParticipant()
  };
  for (TransactionParticipant participant : participants) {
      txn.join(participant);
  }
  handle.commit();
  if (exception[0] instanceof TransactionNotActiveException) {
      System.err.println(exception[0]);
  } else {
      fail("Expected TransactionNotActiveException: " + exception[0]);
  }
  listener.assertCalled(false, CalledAfter.NO);
    }
View Full Code Here

Examples of com.sun.sgs.test.util.DummyTransactionListener

  listener.assertCalled(false, CalledAfter.NO);
    }

    @Test
    public void testRegisterListenerCommitted() throws Exception {
  DummyTransactionListener listener = new DummyTransactionListener();
  handle.commit();
  try {
      txn.registerListener(listener);
      fail("Expected TransactionNotActiveException");
  } catch (TransactionNotActiveException e) {
      System.err.println(e);
  }
  listener.assertCalled(false, CalledAfter.NO);
    }
View Full Code Here

Examples of com.sun.sgs.test.util.DummyTransactionListener

  listener.assertCalled(false, CalledAfter.NO);
    }

    @Test
    public void testRegisterListenerBeforeCompletion() throws Exception {
  final DummyTransactionListener lateListener =
      new DummyTransactionListener();
  DummyTransactionListener[] listeners = {
      new DummyTransactionListener(),
      new DummyTransactionListener() {
    public void beforeCompletion() {
        super.beforeCompletion();
        txn.registerListener(lateListener);
    }
      },
      new DummyTransactionListener()
  };
  for (DummyTransactionListener listener : listeners) {
      txn.registerListener(listener);
  }
  handle.commit();
  for (DummyTransactionListener listener : listeners) {
      listener.assertCalled(true, CalledAfter.COMMIT);
  }
  /*
   * Since there is no guarantee of listener order, don't check if the
   * late-added listener's beforeCompletion method was called.
   */
  lateListener.assertCalledAfter(CalledAfter.COMMIT);
    }
View Full Code Here

Examples of com.sun.sgs.test.util.DummyTransactionListener

    }

    @Test
    public void testRegisterListenerAfterCompletion() throws Exception {
  final Exception[] exception = { null };
  final DummyTransactionListener listener =
      new DummyTransactionListener() {
    public void afterCompletion(boolean commited) {
        super.afterCompletion(commited);
        DummyTransactionListener anotherListener =
      new DummyTransactionListener();
        try {
      txn.registerListener(anotherListener);
        } catch (Exception e) {
      exception[0] = e;
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.