Examples of DummyTransactionListener


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

    @Test
    public void testRegisterListenerOtherThread() throws Exception {
  final AtomicReference<RuntimeException> exception =
      new AtomicReference<RuntimeException>(null);
  final TransactionListener listener = new DummyTransactionListener();
  Thread thread = new Thread() {
      public void run() {
    try {
        txn.registerListener(listener);
    } catch (RuntimeException e) {
View Full Code Here

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


    @Test
    public void testRegisterListenerCommit() throws Exception {
  DummyTransactionListener[] listeners = {
      new DummyTransactionListener(),
      new DummyTransactionListener(),
      new DummyTransactionListener()
  };
  for (DummyTransactionListener listener : listeners) {
      txn.registerListener(listener);
      /* Check that registering twice has no effect */
      txn.registerListener(listener);
View Full Code Here

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

    }

    @Test
    public void testRegisterListenerCommitBeforeThrows() throws Exception {
  RuntimeException exception = new RuntimeException();
  DummyTransactionListener listener = new DummyTransactionListener();
  txn.registerListener(listener);
  DummyTransactionListener failingListener =
      new DummyTransactionListener(exception, null);
  txn.registerListener(failingListener);
  try {
      handle.commit();
      fail("Expected RuntimeException");
  } catch (RuntimeException e) {
      assertSame(exception, e);
  }
  /*
   * Don't know which listener's beforeCompletion method was called
   * first, so don't check if this one's was called.
   */
  listener.assertCalledAfter(CalledAfter.ABORT);
  failingListener.assertCalled(true, CalledAfter.ABORT);
    }
View Full Code Here

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

    @Test
    public void testRegisterListenerCommitAfterThrows() throws Exception {
  RuntimeException exception = new RuntimeException();
  DummyTransactionListener[] listeners = {
      new DummyTransactionListener(null, exception),
      new DummyTransactionListener(null, exception)
  };
  for (DummyTransactionListener listener : listeners) {
      txn.registerListener(listener);
  }
  handle.commit();
View Full Code Here

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

    @Test
    public void testRegisterListenerCommitBothThrow() throws Exception {
  RuntimeException beforeException = new RuntimeException();
  RuntimeException afterException = new RuntimeException();
  DummyTransactionListener[] listeners = {
      new DummyTransactionListener(beforeException, afterException),
      new DummyTransactionListener(beforeException, afterException)
  };
  for (DummyTransactionListener listener : listeners) {
      txn.registerListener(listener);
  }
  try {
View Full Code Here

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

  }
    }

    @Test
    public void testRegisterListenerAbort() throws Exception {
  DummyTransactionListener listener = new DummyTransactionListener();
  txn.registerListener(listener);
  /* Check that registering twice has no effect. */
  txn.registerListener(listener);
  txn.abort(abortXcp);
  listener.assertCalled(false, CalledAfter.ABORT);
    }
View Full Code Here

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

    @Test
    public void testRegisterListenerAbortAfterThrows() throws Exception {
  RuntimeException exception = new RuntimeException();
  DummyTransactionListener[] listeners = {
      new DummyTransactionListener(null, exception),
      new DummyTransactionListener(null, exception)
  };
  for (DummyTransactionListener listener : listeners) {
      txn.registerListener(listener);
  }
  txn.abort(abortXcp);
View Full Code Here

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

    }

    @Test
    public void testRegisterListenerBeforeAborts() throws Exception {
  final RuntimeException exception = new RuntimeException();
  DummyTransactionListener listener =
      new DummyTransactionListener() {
    public void beforeCompletion() {
        super.beforeCompletion();
        txn.abort(exception);
    }
      };
  txn.registerListener(listener);
  try {
      handle.commit();
      fail("Expected TransactionAbortedException");
  } catch (TransactionAbortedException e) {
      System.err.println(e);
  }
  listener.assertCalled(true, CalledAfter.ABORT);
    }
View Full Code Here

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

  listener.assertCalled(true, CalledAfter.ABORT);
    }

    @Test
    public void testRegisterListenerAborting() {
  final DummyTransactionListener listener =
      new DummyTransactionListener();
  final Exception[] exception = { null };
  DummyTransactionParticipant participant =
      new DummyTransactionParticipant() {
    public void abort(Transaction txn) {
        try {
      txn.registerListener(listener);
        } catch (Exception e) {
      exception[0] = e;
        }
        super.abort(txn);
    }
      };
  txn.join(participant);
  txn.abort(abortXcp);
  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 testRegisterListenerAborted() {
  DummyTransactionListener listener = new DummyTransactionListener();
  txn.abort(abortXcp);
  try {
      txn.registerListener(listener);
      fail("Expected TransactionNotActiveException");
  } catch (TransactionNotActiveException e) {
      System.err.println(e);
  }
  listener.assertCalled(false, CalledAfter.NO);
    }
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.