Examples of TransactionManager


Examples of javax.transaction.TransactionManager

   }

   public void testIgnoreModsTransactional() throws Exception
   {
      startCache(false, true);
      TransactionManager mgr = cache.getTransactionManager();

      // initialise the loaders
      loader1.put(fqn, key, value);
      loader2.put(fqn, key, value);

      // check contents
      assertEquals(value, cache.get(fqn, key));
      assertEquals(value, chainingCacheLoader.get(fqn).get(key));
      assertEquals(value, loader1.get(fqn).get(key));
      assertEquals(value, loader2.get(fqn).get(key));

      // do a put
      mgr.begin();
      cache.put(fqn, key, value + 2);
      assertEquals(value + 2, cache.get(fqn, key));
      assertEquals(value, chainingCacheLoader.get(fqn).get(key));
      assertEquals(value, loader1.get(fqn).get(key));
      assertEquals(value, loader2.get(fqn).get(key));
      mgr.commit();
      assertEquals(value + 2, cache.get(fqn, key));
      assertEquals(value + 2, chainingCacheLoader.get(fqn).get(key));
      assertEquals(value + 2, loader1.get(fqn).get(key));
      assertEquals(value, loader2.get(fqn).get(key));
View Full Code Here

Examples of javax.transaction.TransactionManager

   }

   public void testCrudsTransactional() throws Exception
   {
      startCache(false, false);
      TransactionManager mgr = cache.getTransactionManager();

      // assert that the loaders ae empty
      chainingCacheLoader.remove(cache.getRoot().getFqn());
      assertNull(loader1.get(fqn));
      assertNull(loader2.get(fqn));
      assertNull(chainingCacheLoader.get(fqn));

      // put something in the cache.
      mgr.begin();
      cache.put(fqn, key, value);
      assertEquals(value, cache.get(fqn, key));
      assertNull(chainingCacheLoader.get(fqn));
      assertNull(loader1.get(fqn));
      assertNull(loader2.get(fqn));
      mgr.commit();
      assertEquals(value, cache.get(fqn, key));
      assertEquals(value, chainingCacheLoader.get(fqn).get(key));
      assertEquals(value, loader1.get(fqn).get(key));
      assertEquals(value, loader2.get(fqn).get(key));
View Full Code Here

Examples of javax.transaction.TransactionManager

   }

   public void testSyncTxRepl() throws Exception
   {
      Integer age;
      TransactionManager tm = cache1.getTransactionManager();

      tm.begin();
      Transaction tx = tm.getTransaction();
      Listener lis = new Listener();
      cache1.getNotifier().addCacheListener(lis);
      lis.put("/a/b/c", "age", 38);

      tm.suspend();
      assertNull("age on cache2 must be null as the TX has not yet been committed", cache2.get("/a/b/c", "age"));
      tm.resume(tx);
      tm.commit();

      // value on cache2 must be 38
      age = (Integer) cache2.get("/a/b/c", "age");
      assertNotNull("\"age\" obtained from cache2 must be non-null ", age);
      assertTrue("\"age\" must be 38", age == 38);
View Full Code Here

Examples of javax.transaction.TransactionManager

   }

   public void testSyncTxReplMap() throws Exception
   {
      Integer age;
      TransactionManager tm = cache1.getConfiguration().getRuntimeConfig().getTransactionManager();
      tm.begin();
      Transaction tx = tm.getTransaction();
      Listener lis = new Listener();
      cache1.getNotifier().addCacheListener(lis);
      Map<String, Comparable> map = new HashMap<String, Comparable>();
      map.put("age", 38);
      map.put("name", "Ben");
      lis.put("/a/b/c", map);
      tm.suspend();
      assertNull("age on cache2 must be null as the TX has not yet been committed", cache2.get("/a/b/c", "age"));
      tm.resume(tx);
      tm.commit();

      // value on cache2 must be 38
      age = (Integer) cache2.get("/a/b/c", "age");
      assertNotNull("\"age\" obtained from cache2 must be non-null ", age);
      assertTrue("\"age\" must be 38", age == 38);
View Full Code Here

Examples of javax.transaction.TransactionManager

      }
   }

   private void destroyCache(CacheSPI c)
   {
      TransactionManager tm = c.getTransactionManager();
      try
      {
         if (tm != null && tm.getTransaction() != null)
            tm.rollback();
      }
      catch (Exception e)
      {
      }
      c.stop();
View Full Code Here

Examples of javax.transaction.TransactionManager

   {
      DataVersion version = new TestVersion("99");
      cache[0].getInvocationContext().getOptionOverrides().setDataVersion(version);
      cache[0].put(fqn, key, "value");// TestVersion-99 should be on both caches now

      TransactionManager mgr = cache[0].getTransactionManager();
      mgr.begin();
      // don't explicitly set a data version.

      // force an IC scrub
      //cache[1].getInvocationContext().setOptionOverrides(null);
      cache[1].put(fqn, key, "value2");
      try
      {
         mgr.commit();

         assertTrue("expected to fail", false);
      }
      catch (RollbackException e)
      {
View Full Code Here

Examples of javax.transaction.TransactionManager

   {
      DataVersion version = new TestVersion("99");
      cache[0].getInvocationContext().getOptionOverrides().setDataVersion(version);
      cache[0].put(fqn, key, "value");// TestVersion-99 should be on both caches now

      TransactionManager mgr = cache[0].getTransactionManager();
      mgr.begin();

      version = new TestVersion("999");
      cache[1].getInvocationContext().getOptionOverrides().setDataVersion(version);
      cache[1].put(fqn, key, "value2");
      mgr.commit();
   }
View Full Code Here

Examples of javax.transaction.TransactionManager

   {
      DataVersion version = new TestVersion("99");
      cache[0].getInvocationContext().getOptionOverrides().setDataVersion(version);
      cache[0].put(fqn, key, "value");// TestVersion-99 should be on both caches now

      TransactionManager mgr = cache[0].getTransactionManager();
      mgr.begin();

      version = new TestVersion("29");
      cache[1].getInvocationContext().getOptionOverrides().setDataVersion(version);
      cache[1].put(fqn, key, "value2");
      try
      {
         mgr.commit();
         assertTrue("expected to fail", false);
      }
      catch (RollbackException e)
      {
         // should fail.
View Full Code Here

Examples of javax.transaction.TransactionManager

    */
   public void testIncompatibleVersionTypes2() throws Exception
   {
      cache[0].put(fqn, key, "value");// default data version should be on both caches now

      TransactionManager mgr = cache[0].getTransactionManager();
      mgr.begin();

      // explicitly set data version
      DataVersion version = new TestVersion("99");
      cache[1].getInvocationContext().getOptionOverrides().setDataVersion(version);

      try
      {
         cache[1].put(fqn, key, "value2");
         mgr.commit();
         assertTrue("expected to fail", false);
      }
      catch (Exception e)
      {
         // should fail.
View Full Code Here

Examples of javax.transaction.TransactionManager

    */
   public void testCompatibleVersionTypes2() throws Exception
   {
      cache[0].put(fqn, key, "value");// TestVersion-99 should be on both caches now

      TransactionManager mgr = cache[0].getTransactionManager();
      mgr.begin();

      DataVersion version = new DefaultDataVersion(300);
      cache[1].getInvocationContext().getOptionOverrides().setDataVersion(version);
      cache[1].put(fqn, key, "value2");
      mgr.commit();
   }
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.