Examples of OptimisticTransactionContext


Examples of org.jboss.cache.transaction.OptimisticTransactionContext

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

      GlobalTransaction gtx = table.get(tx);

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

      TransactionWorkspace<Object, Object> workspace = entry.getTransactionWorkSpace();

      assertEquals(3, workspace.getNodes().size());
      assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
      assertEquals(pojo, workspace.getNode(Fqn.fromString("/one/two")).get("key1"));
      assertEquals(1, workspace.getNode(Fqn.fromString("/one/two")).getMergedData().size());
      assertTrue(entry.getLocks().isEmpty());
      assertEquals(1, entry.getModifications().size());
      assertTrue(!cache.exists("/one/two"));
      assertEquals(null, dummy.getCalledCommand());

      OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(gtx, entry.getModifications(), (Address) gtx.getAddress(), Boolean.FALSE);
      //now let us do a prepare
      TestingUtil.replicateCommand(cache, prepareCommand);


      assertEquals(3, workspace.getNodes().size());
      assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
      assertEquals(pojo, workspace.getNode(Fqn.fromString("/one/two")).get("key1"));
      assertEquals(1, workspace.getNode(Fqn.fromString("/one/two")).getMergedData().size());
      assertTrue(entry.getLocks().isEmpty());
      assertEquals(1, entry.getModifications().size());
      assertTrue(!cache.exists("/one/two"));
      assertEquals(prepareCommand, dummy.getCalledCommand());


      mgr.commit();
View Full Code Here

Examples of org.jboss.cache.transaction.OptimisticTransactionContext

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

      GlobalTransaction gtx = table.get(tx);

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

      TransactionWorkspace<Object, Object> workspace = entry.getTransactionWorkSpace();

      assertEquals(3, workspace.getNodes().size());
      assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
      assertEquals(pojo, workspace.getNode(Fqn.fromString("/one/two")).get("key1"));
      assertEquals(1, workspace.getNode(Fqn.fromString("/one/two")).getMergedData().size());
      assertTrue(entry.getLocks().isEmpty());
      assertEquals(1, entry.getModifications().size());
      assertTrue(!cache.exists("/one/two"));
      assertEquals(null, dummy.getCalledCommand());

      //lets change one of the underlying version numbers
      workspace.getNode(Fqn.fromString("/one/two")).getNode().setVersion(new DefaultDataVersion(2));
      //now let us do a prepare
      OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(gtx, entry.getModifications(), (Address) gtx.getAddress(), Boolean.FALSE);
      try
      {
         TestingUtil.replicateCommand(cache, prepareCommand);
         fail();
      }
View Full Code Here

Examples of org.jboss.cache.transaction.OptimisticTransactionContext

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

      GlobalTransaction gtx = table.get(tx);

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

      TransactionWorkspace<Object, Object> workspace = entry.getTransactionWorkSpace();

      assertEquals(3, workspace.getNodes().size());
      assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
      assertEquals(pojo, workspace.getNode(Fqn.fromString("/one/two")).get("key1"));
      assertEquals(1, workspace.getNode(Fqn.fromString("/one/two")).getMergedData().size());
      assertTrue(entry.getLocks().isEmpty());
      assertEquals(1, entry.getModifications().size());
      assertTrue(!cache.exists("/one/two"));
      assertEquals(null, dummy.getCalledCommand());

      //lets change one of the underlying version numbers
      //now let us do a prepare
      OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(gtx, entry.getModifications(), (Address) gtx.getAddress(), Boolean.FALSE);
      try
      {
         TestingUtil.replicateCommand(cache, prepareCommand);
         fail();
      }
      catch (Throwable t)
      {
         assertTrue(true);
      }

      CommitCommand commitCommand = new CommitCommand(gtx);
      TestingUtil.replicateCommand(cache, commitCommand);


      assertEquals(3, workspace.getNodes().size());
      assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
      assertEquals(pojo, workspace.getNode(Fqn.fromString("/one/two")).get("key1"));
      assertEquals(1, workspace.getNode(Fqn.fromString("/one/two")).getMergedData().size());
      assertTrue(entry.getLocks().isEmpty());
      assertEquals(1, entry.getModifications().size());


      assertEquals(commitCommand, dummy.getCalledCommand());
      NodeSPI<Object, Object> node = workspace.getNode(Fqn.ROOT).getNode();
      //assert we can navigate
View Full Code Here

Examples of org.jboss.cache.transaction.OptimisticTransactionContext

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

      GlobalTransaction gtx = table.get(tx);

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

      @SuppressWarnings("unchecked") TransactionWorkspace<Object, Object> workspace = entry.getTransactionWorkSpace();

      assertEquals(3, workspace.getNodes().size());
      assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
      assertEquals(pojo, workspace.getNode(Fqn.fromString("/one/two")).get("key1"));
      assertEquals(1, workspace.getNode(Fqn.fromString("/one/two")).getMergedData().size());
      assertTrue(entry.getLocks().isEmpty());
      assertEquals(1, entry.getModifications().size());
      assertTrue(!cache.exists("/one/two"));
      assertEquals(null, dummy.getCalledCommand());

      //lets change one of the underlying version numbers
      //now let us do a prepare
      OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(gtx, entry.getModifications(), (Address) gtx.getAddress(), Boolean.FALSE);
      try
      {
         TestingUtil.replicateCommand(cache, prepareCommand);
         fail();
      }
      catch (Throwable t)
      {
         assertTrue(true);
      }


      CommitCommand commitCommand = new CommitCommand(gtx);
      TestingUtil.replicateCommand(cache, commitCommand);


      assertEquals(3, workspace.getNodes().size());
      assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
      assertEquals(pojo, workspace.getNode(Fqn.fromString("/one/two")).get("key1"));
      assertEquals(1, workspace.getNode(Fqn.fromString("/one/two")).getMergedData().size());
      assertTrue(entry.getLocks().isEmpty());
      assertEquals(1, entry.getModifications().size());


      assertEquals(commitCommand, dummy.getCalledCommand());
      NodeSPI<Object, Object> node = workspace.getNode(Fqn.fromString("/")).getNode();
      //assert we can navigate
View Full Code Here

Examples of org.jboss.cache.transaction.OptimisticTransactionContext

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

      GlobalTransaction gtx = table.get(tx);

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

      TransactionWorkspace<Object, Object> workspace = entry.getTransactionWorkSpace();

      assertEquals(3, workspace.getNodes().size());
      assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
      assertEquals(pojo, workspace.getNode(Fqn.fromString("/one/two")).get("key1"));
      assertEquals(1, workspace.getNode(Fqn.fromString("/one/two")).getMergedData().size());
      assertTrue(entry.getLocks().isEmpty());
      assertEquals(1, entry.getModifications().size());
      assertTrue(!cache.exists("/one/two"));
      assertEquals(null, dummy.getCalledCommand());

      //lets change one of the underlying version numbers
      //now let us do a prepare
      OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(gtx, entry.getModifications(), (Address) gtx.getAddress(), Boolean.FALSE);

      try
      {
         TestingUtil.replicateCommand(cache, prepareCommand);
         fail();
      }
      catch (Throwable t)
      {
         assertTrue(true);
      }

      RollbackCommand rollbackCommand = new RollbackCommand(gtx);
      TestingUtil.replicateCommand(cache, rollbackCommand);


      assertEquals(0, workspace.getNodes().size());
      assertNull(workspace.getNode(Fqn.fromString("/one/two")));
      assertNull(workspace.getNode(Fqn.fromString("/one")));
      assertTrue(entry.getLocks().isEmpty());
      assertEquals(1, entry.getModifications().size());

      mgr.commit();
   }
View Full Code Here

Examples of org.jboss.cache.transaction.OptimisticTransactionContext

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

      GlobalTransaction gtx = table.get(tx);

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

      TransactionWorkspace workspace = entry.getTransactionWorkSpace();

      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());
   }
View Full Code Here

Examples of org.jboss.cache.transaction.OptimisticTransactionContext

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

      GlobalTransaction gtx = table.get(tx);

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

      TransactionWorkspace workspace = entry.getTransactionWorkSpace();

      mgr.commit();
      //assert what should be the results of our call
      assertEquals(3, workspace.getNodes().size());
      assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
      assertEquals(pojo2, workspace.getNode(Fqn.fromString("/one/two")).get("key1"));
      assertTrue(entry.getLocks().isEmpty());
      assertEquals(2, entry.getModifications().size());
      assertTrue(!cache.exists("/one/two"));
      assertEquals(null, dummy.getCalledCommand());
   }
View Full Code Here

Examples of org.jboss.cache.transaction.OptimisticTransactionContext

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

      GlobalTransaction gtx = table.get(tx);

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

      TransactionWorkspace workspace = entry.getTransactionWorkSpace();

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

Examples of org.jboss.cache.transaction.OptimisticTransactionContext

   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

Examples of org.jboss.cache.transaction.OptimisticTransactionContext

      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
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.