Package javax.transaction

Examples of javax.transaction.Transaction


      cache.put(fqn, k, v);

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

      // and now another simultaneous write
      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 a simultaneous write
      transactionManager.begin();
      try
      {
View Full Code Here

      allowedLevels.add(REPEATABLE_READ);

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

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

      // do a read
      transactionManager.begin();
      int numChildren = cache.getRoot().getChild(fqn).getChildren().size();
      assertEquals(1, numChildren);
      Transaction t1 = transactionManager.suspend();

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

   }

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

      // inject InvocationContext
      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);

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

      //assert we can see this with a key value get in the transaction
      assertEquals(pojo, cache.get("/one/two", "key1"));
      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();

      // inject InvocationContext
      setupTransactions(cache, tx2);

      assertNull(cache.get("/one/two", "key1"));
View Full Code Here

   }

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

      // inject InvocationContext
      setupTransactions(cache, tx);

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


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

      // inject InvocationContext
      setupTransactions(cache, tx);

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


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

      // inject InvocationContext
      setupTransactions(cache, tx);

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

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

      assertEquals(pojo, cache.get("/one/two", "key1"));
      //suspend current transaction
      mgr.suspend();

      //start a new transaction
      mgr.begin();
      Transaction tx2 = mgr.getTransaction();
      // inject InvocationContext
      setupTransactions(cache, tx2);

      SamplePojo pojo2 = new SamplePojo(22, "test2");
View Full Code Here

      // now load the node.
      expected.clear();
      eventLog.events.clear();
      tm.begin();
      Transaction tx = tm.getTransaction();
      cache.get(fqn, "DOES_NOT_EXIST");
      tm.commit();
      expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, false, null, TRANSACTION_REGISTERED));
      expected.add(new EventImpl(true, cache, null, null, fqn, tx, true, null, false, null, NODE_CREATED));
      expected.add(new EventImpl(false, cache, null, null, fqn, tx, true, null, false, null, NODE_CREATED));
View Full Code Here

      // now load the node.
      expected.clear();
      eventLog.events.clear();
      tm.begin();
      Transaction tx = tm.getTransaction();
      cache.put(fqn, "key2", "value2");
      tm.commit();
      expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, false, null, TRANSACTION_REGISTERED));
      expected.add(new EventImpl(true, cache, null, null, fqn, tx, true, null, false, null, NODE_CREATED));
      expected.add(new EventImpl(false, cache, null, null, fqn, tx, true, null, false, null, NODE_CREATED));
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.