Package com.sun.sgs.test.util

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


      flag.acquire();
      final int finalI = i;
      class MyRunnable implements Runnable {
    Exception exception2;
    public void run() {
        DummyTransaction txn2 = null;
        try {
      txn2 = createTransaction(
          UsePrepareAndCommit.ARBITRARY, 1000);
      store.getObject(txn2, id2, false);
      flag.release();
      store.getObject(txn2, id, true);
      System.err.println(finalI + " txn2: commit");
      txn2.commit();
        } catch (TransactionAbortedException e) {
      System.err.println(finalI + " txn2: " + e);
      exception2 = e;
        } catch (Exception e) {
      System.err.println(finalI + " txn2: " + e);
      exception2 = e;
      if (txn2 != null) {
          txn2.abort(new RuntimeException("abort"));
      }
        }
    }
View Full Code Here


    /** Create a TxnLocker. */
    TxnLocker<String> createTxnLocker(LockManager<String> lockManager,
              long requestedStartTime)
    {
  return createTxnLocker(
      lockManager, new DummyTransaction(), requestedStartTime);
    }
View Full Code Here

    @Test
    public void testMaxLockTimeout() throws Exception {
  init(Long.MAX_VALUE, numKeyMaps);
  Locker<String> locker2 = createTxnLocker(
      lockManager, new DummyTransaction(40), 0);
  assertGranted(acquireLock(locker, "o1", true));
  AcquireLock acquire2 = new AcquireLock(locker2, "o1", true);
  acquire2.assertBlocked();
  Thread.sleep(20);
  acquire2.assertBlocked();
View Full Code Here

    }

    @Test
    public void testTxnTimeout() throws Exception {
  Locker<String> locker2 = createTxnLocker(
      lockManager, new DummyTransaction(20), 0);
  assertGranted(acquireLock(locker, "o1", true));
  AcquireLock acquire2 = new AcquireLock(locker2, "o1", true);
  acquire2.assertBlocked();
  Thread.sleep(40);
  assertTimeout(acquire2.getResult(), locker);
View Full Code Here

    @Test
    public void testMaxTxnTimeout() throws Exception {
  init(40L, numKeyMaps);
  Locker<String> locker2 = createTxnLocker(
      lockManager, new DummyTransaction(Long.MAX_VALUE), 0);
  assertGranted(acquireLock(locker, "o1", true));
  AcquireLock acquire2 = new AcquireLock(locker2, "o1", true);
  acquire2.assertBlocked();
  Thread.sleep(20);
  acquire2.assertBlocked();
View Full Code Here

     * locker2:      => blocked
     * locker3:      => blocked
     */
    @Test
    public void testUpgradeWaiterConflictTimesOut() throws Exception {
  Transaction txn = new DummyTransaction();
  locker = createTxnLocker(lockManager, txn, 0);
  assertGranted(acquireLock(locker, "o1", false));
  Locker<String> locker2 = createLocker(lockManager);
  assertGranted(acquireLock(locker2, "o1", false));
  Locker<String> locker3 = createTxnLocker(
      lockManager, new DummyTransaction(txn.getTimeout() / 3), 0);
  AcquireLock acquire3 = new AcquireLock(locker3, "o1", true);
  acquire3.assertBlocked();
  AcquireLock acquire2 = new AcquireLock(locker2, "o1", true);
  acquire2.assertBlocked();
  lockManager.releaseLock(locker, "o1");
  acquire2.assertBlocked();
  acquire3.assertBlocked();
  Thread.sleep(txn.getTimeout() / 2);
  assertTimeout(acquire3.getResult(), locker2);
  assertGranted(acquire2.getResult());
    }
View Full Code Here

    }

    /** Initialize fields using the current value of properties. */
    protected void init() {
  coordinator = createAccessCoordinator();
  txn = new DummyTransaction();
  txnProxy.setCurrentTransaction(txn);
  coordinator.notifyNewTransaction(txn, 0, 1);
  reporter = coordinator.registerAccessSource("s", String.class);
    }
View Full Code Here

  }
    }

    @Test
    public void testReportObjectAccessTransactionNotKnown() {
  DummyTransaction txn2 = new DummyTransaction();
  try {
      reporter.reportObjectAccess(txn2, "o1", AccessType.READ);
      fail("Expected IllegalArgumentException");
  } catch (IllegalArgumentException e) {
      System.err.println(e);
  }
  try {
      reporter.reportObjectAccess(txn2, "o1", AccessType.READ, null);
      fail("Expected IllegalArgumentException");
  } catch (IllegalArgumentException e) {
      System.err.println(e);
  }
  txn2.abort(ABORT_EXCEPTION);
    }
View Full Code Here

          "s", "o4", AccessType.READ, null);
    }

    @Test
    public void testReportObjectAccessMultipleReporters() {
  DummyTransaction txn2 = new DummyTransaction();
  coordinator.notifyNewTransaction(txn2, 0, 1);
  AccessReporter<String> reporterPrime =
      coordinator.registerAccessSource("s", String.class);
  AccessReporter<String> reporter2 =
      coordinator.registerAccessSource("s2", String.class);
View Full Code Here

  }
    }

    @Test
    public void testSetObjectDescriptionTransactionNotKnown() {
  DummyTransaction txn2 = new DummyTransaction();
  try {
      reporter.setObjectDescription(txn2, "o1", null);
      fail("Expected IllegalArgumentException");
  } catch (IllegalArgumentException e) {
      System.err.println(e);
  }
  try {
      reporter.setObjectDescription(txn2, "o1", "description");
      fail("Expected IllegalArgumentException");
  } catch (IllegalArgumentException e) {
      System.err.println(e);
  }
  txn2.abort(ABORT_EXCEPTION);
    }
View Full Code Here

TOP

Related Classes of com.sun.sgs.test.util.DummyTransaction

Copyright © 2018 www.massapicom. 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.