Package javax.transaction

Examples of javax.transaction.Transaction


   }

   public void testTransactionKeyValOverwriteNullMethod() throws Exception
   {
      mgr.begin();
      Transaction tx = mgr.getTransaction();

      setupTransactions(cache, tx);

      SamplePojo pojo = new SamplePojo(21, "test");
View Full Code Here


      cache.getTransactionManager().commit();
   }

   private WorkspaceNode getWorkspaceNode(Fqn fqn) throws Exception
   {
      Transaction tx = cache.getTransactionManager().getTransaction();
      GlobalTransaction gtx = cache.getTransactionTable().get(tx);
      OptimisticTransactionContext te = (OptimisticTransactionContext) cache.getTransactionTable().get(gtx);
      TransactionWorkspace tw = te.getTransactionWorkSpace();
      return tw.getNode(fqn);
   }
View Full Code Here

   }

   public void testNotifyTransactionCompleted()
   {
      assert allEventsListener.transactionCompleted == null;
      Transaction tx = createNiceMock(Transaction.class);
      notifier.notifyTransactionCompleted(tx, false, ctx);
      assert allEventsListener.transactionCompleted != null;
      assert allEventsListener.transactionCompleted.getTransaction() == tx;
      assert !allEventsListener.transactionCompleted.isSuccessful();
      assert allEventsListener.transactionCompleted.getType() == Event.Type.TRANSACTION_COMPLETED;
View Full Code Here

   }

   public void testNotifyTransactionRegistered()
   {
      assert allEventsListener.transactionRegistered == null;
      Transaction tx = createNiceMock(Transaction.class);
      notifier.notifyTransactionRegistered(tx, ctx);
      assert allEventsListener.transactionRegistered != null;
      assert allEventsListener.transactionRegistered.getTransaction() == tx;
      assert allEventsListener.transactionRegistered.getType() == Event.Type.TRANSACTION_REGISTERED;
   }
View Full Code Here

   @SuppressWarnings("unchecked")
   public void testTransactionGetNamesMethod() throws Exception
   {
      mgr.begin();
      Transaction tx = mgr.getTransaction();

      setupTransactions(cache, tx);

      SamplePojo pojo = new SamplePojo(21, "test");

      cache.put("/one/two", "key1", pojo);

      assertEquals(null, dummy.getCalledCommand());
      TransactionTable table = cache.getTransactionTable();

      GlobalTransaction gtx = table.get(tx);

      OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);

      TransactionWorkspace workspace = entry.getTransactionWorkSpace();

      //assert we can see this with a key value get in the transaction
      assertEquals(1, cache.getNode("/one").getChildrenNames().size());
      mgr.commit();

      //assert what should be the results of our call
      assertEquals(3, workspace.getNodes().size());
      assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
      assertEquals(pojo, workspace.getNode(Fqn.fromString("/one/two")).get("key1"));
      assertTrue(entry.getLocks().isEmpty());
      assertEquals(1, entry.getModifications().size());
      assertTrue(!cache.exists("/one/two"));
      assertEquals(null, dummy.getCalledCommand());

      //assert that we cannot see the change if we have not put it into the cache
      // we need to do this as we do not have the tx interceptor in this stack
      mgr.begin();

      Transaction tx2 = mgr.getTransaction();

      setupTransactions(cache, tx2);

      assertEquals(0, cache.getRoot().getChildrenNames().size());
      mgr.commit();
View Full Code Here


   public void testTransactionGetNoNamesMethod() throws Exception
   {
      mgr.begin();
      Transaction tx = mgr.getTransaction();

      setupTransactions(cache, tx);

      assertEquals(null, dummy.getCalledCommand());
      TransactionTable table = cache.getTransactionTable();
View Full Code Here


   public void testTransactionGetNamesIteratorMethod() throws Exception
   {
      mgr.begin();
      Transaction tx = mgr.getTransaction();

      setupTransactions(cache, tx);

      SamplePojo pojo = new SamplePojo(21, "test");
View Full Code Here

      allowedLevels.add(READ_UNCOMMITTED);

      // do a write
      transactionManager.begin();
      cache.put(fqn, k, v);
      Transaction t1 = transactionManager.suspend();

      // and now a simultaneous read
      transactionManager.begin();
      try
      {
View Full Code Here

      allowedLevels.add(REPEATABLE_READ);

      // do a write
      transactionManager.begin();
      assertNull(cache.get(fqn, k));
      Transaction t1 = transactionManager.suspend();

      // and now a simultaneous read
      transactionManager.begin();
      try
      {
View Full Code Here

      cache.put(fqn, k, v);

      // do a read
      transactionManager.begin();
      assertEquals(v, cache.get(fqn, k));
      Transaction t1 = transactionManager.suspend();

      // and now another simultaneous read
      transactionManager.begin();
      try
      {
View Full Code Here

TOP

Related Classes of javax.transaction.Transaction

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.