Package org.jboss.cache.transaction

Examples of org.jboss.cache.transaction.DummyTransactionManager


   {
      CacheLoaderConfig cacheLoaderConfig = UnitTestConfigurationFactory.buildSingleCacheLoaderConfig(passivation, "", DummyInMemoryCacheLoader.class.getName(), "", false, true, false, false, false);
      Configuration cfg = new Configuration();
      cfg.setNodeLockingScheme(getNodeLockingScheme());
      cfg.setCacheLoaderConfig(cacheLoaderConfig);
      cfg.getRuntimeConfig().setTransactionManager(new DummyTransactionManager());
      Cache<String, String> cache = new UnitTestCacheFactory().createCache(cfg, getClass());
      cache.put(fqn, key, "value");

      // evict the node, so we have to go to the loader to do anything with it
      cache.evict(fqn);
View Full Code Here


      cache.removeNode(fqn);
      loader.remove(fqn);

      assertNull(loader.get(fqn));

      DummyTransactionManager mgr = DummyTransactionManager.getInstance();

      // put something in the cache
      mgr.begin();
      cache.put(fqn, key, value);
      mgr.commit();

      // should be nothing in the loader
      assertEquals(value, cache.get(fqn, key));
      assertNull(loader.get(fqn));

      // evict from cache
      mgr.begin();
      cache.evict(fqn);
      mgr.commit();

      mgr.begin();
      // should now be passivated in the loader
      // don't do a cache.get() first as this will activate this node from the loader again!
      // assertNull( cache.get( fqn ) );
      assertEquals(value, loader.get(fqn).get(key));

      // now do a cache.get()...
      assertEquals(value, cache.get(fqn, key));

      // and the object should now be removed from the loader
      assertNull(loader.get(fqn));
      mgr.commit();

      // clean up
      mgr.begin();
      cache.removeNode(fqn);
      loader.remove(fqn);
      mgr.commit();

   }
View Full Code Here

         public void run()
         {
            try
            {
               //start a new transaction in this thread
               DummyTransactionManager mgr = DummyTransactionManager.getInstance();
               mgr.begin();
               setTransactionsInInvocationCtx(mgr, cache);
               SamplePojo pojo = new SamplePojo(21, "test");

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

               randomSleep(minSleep, maxSleep);

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

               OptimisticTransactionContext entry = (OptimisticTransactionContext) cache.getTransactionTable().get(cache.getCurrentTransaction());
               assertEquals(3, entry.getTransactionWorkSpace().getNodes().size());
               assertTrue(entry.getTransactionWorkSpace().getNode(Fqn.fromString("/")) != null);
               assertTrue(entry.getTransactionWorkSpace().getNode(Fqn.fromString("/one")) != null);
               assertTrue(entry.getTransactionWorkSpace().getNode(Fqn.fromString("/one/two")) != null);
               mgr.commit();
               resetInvocationCtx(cache);
            }
            catch (Exception e)
            {
               e.printStackTrace();
View Full Code Here

      CommandInterceptor dummy = new MockInterceptor();
      interceptor.setNext(dummy);

      TestingUtil.replaceInterceptorChain(cache, interceptor);

      final DummyTransactionManager mgr = DummyTransactionManager.getInstance();
      mgr.begin();
      final Transaction tx = mgr.getTransaction();

      Runnable run = new Runnable()
      {

         public void run()
         {
            try
            {
               //start a new transaction in this thread

               mgr.setTransaction(tx);
               SamplePojo pojo = new SamplePojo(21, "test");

               setTransactionsInInvocationCtx(mgr, cache);
               cache.put("/one", "key1", pojo);
               OptimisticTransactionContext entry = (OptimisticTransactionContext) cache.getTransactionTable().get(cache.getCurrentTransaction());

               randomSleep(minSleep, maxSleep);

               cache.put("/one/two", "key2", pojo);
               assertEquals(3, entry.getTransactionWorkSpace().getNodes().size());
               assertTrue(entry.getTransactionWorkSpace().getNode(Fqn.fromString("/")) != null);
               assertTrue(entry.getTransactionWorkSpace().getNode(Fqn.fromString("/one")) != null);
               assertTrue(entry.getTransactionWorkSpace().getNode(Fqn.fromString("/one/two")) != null);
            }
            catch (Exception e)
            {
               e.printStackTrace();
            }
            finally
            {
               resetInvocationCtx(cache);
            }
         }
      };
      Thread[] threads = new Thread[numThreads];
      for (int i = 0; i < numThreads; i++)
      {
         Thread t = new Thread(run);
         t.start();
         threads[i] = t;
      }
      for (int i = 0; i < numThreads; i++)
      {
         threads[i].join();
      }
      mgr.commit();

      TestingUtil.sleepThread((long) 4000);
      cache.stop();
   }
View Full Code Here

      initializer.setInitialContextProperties(ctxProperties);
      initializer.start();

      new EJBContextBinder().start();
     
      DummyTransactionManager tm = new DummyTransactionManager();
      InitialContext ic = new InitialContext(ctxProperties);
      ic.bind("java:/TransactionManager", tm);
     
      EmbeddedTestMcBootstrap bootstrap = EmbeddedTestMcBootstrap.createEmbeddedMcBootstrap();
      Ejb3RegistrarLocator.bindRegistrar(new Ejb3McRegistrar(bootstrap.getKernel()));
View Full Code Here

         public void run()
         {
            try
            {
               //start a new transaction in this thread
               DummyTransactionManager mgr = DummyTransactionManager.getInstance();
               mgr.begin();
               setTransactionsInInvocationCtx(mgr, cache);
               SamplePojo pojo = new SamplePojo(21, "test");

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

               randomSleep(minSleep, maxSleep);

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

               OptimisticTransactionContext entry = (OptimisticTransactionContext) cache.getTransactionTable().get(cache.getCurrentTransaction());
               assertEquals(3, entry.getTransactionWorkSpace().getNodes().size());
               assertTrue(entry.getTransactionWorkSpace().getNode(Fqn.fromString("/")) != null);
               assertTrue(entry.getTransactionWorkSpace().getNode(Fqn.fromString("/one")) != null);
               assertTrue(entry.getTransactionWorkSpace().getNode(Fqn.fromString("/one/two")) != null);
               mgr.commit();
               resetInvocationCtx(cache);
            }
            catch (Exception e)
            {
               e.printStackTrace();
View Full Code Here

      CommandInterceptor dummy = new MockInterceptor();
      interceptor.setNext(dummy);

      TestingUtil.replaceInterceptorChain(cache, interceptor);

      final DummyTransactionManager mgr = DummyTransactionManager.getInstance();
      mgr.begin();
      final Transaction tx = mgr.getTransaction();

      Runnable run = new Runnable()
      {

         public void run()
         {
            try
            {
               //start a new transaction in this thread

               mgr.setTransaction(tx);
               SamplePojo pojo = new SamplePojo(21, "test");

               setTransactionsInInvocationCtx(mgr, cache);
               cache.put("/one", "key1", pojo);
               OptimisticTransactionContext entry = (OptimisticTransactionContext) cache.getTransactionTable().get(cache.getCurrentTransaction());

               randomSleep(minSleep, maxSleep);

               cache.put("/one/two", "key2", pojo);
               assertEquals(3, entry.getTransactionWorkSpace().getNodes().size());
               assertTrue(entry.getTransactionWorkSpace().getNode(Fqn.fromString("/")) != null);
               assertTrue(entry.getTransactionWorkSpace().getNode(Fqn.fromString("/one")) != null);
               assertTrue(entry.getTransactionWorkSpace().getNode(Fqn.fromString("/one/two")) != null);
            }
            catch (Exception e)
            {
               e.printStackTrace();
            }
            finally
            {
               resetInvocationCtx(cache);
            }
         }
      };
      Thread[] threads = new Thread[numThreads];
      for (int i = 0; i < numThreads; i++)
      {
         Thread t = new Thread(run);
         t.start();
         threads[i] = t;
      }
      for (int i = 0; i < numThreads; i++)
      {
         threads[i].join();
      }
      mgr.commit();

      TestingUtil.sleepThread((long) 4000);
      cache.stop();
   }
View Full Code Here

      cache.removeNode(fqn);
      loader.remove(fqn);

      assertNull(loader.get(fqn));

      DummyTransactionManager mgr = DummyTransactionManager.getInstance();

      // put something in the cache
      mgr.begin();
      cache.put(fqn, key, value);
      mgr.commit();

      // should be nothing in the loader
      assertEquals(value, cache.get(fqn, key));
      assertNull(loader.get(fqn));

      // evict from cache
      mgr.begin();
      cache.evict(fqn);
      mgr.commit();

      mgr.begin();
      // should now be passivated in the loader
      // don't do a cache.get() first as this will activate this node from the loader again!
      // assertNull( cache.get( fqn ) );
      assertEquals(value, loader.get(fqn).get(key));

      // now do a cache.get()...
      assertEquals(value, cache.get(fqn, key));

      // and the object should now be removed from the loader
      assertNull(loader.get(fqn));
      mgr.commit();

      // clean up
      mgr.begin();
      cache.removeNode(fqn);
      loader.remove(fqn);
      mgr.commit();

   }
View Full Code Here

      cache.evict(Fqn.fromString("/a/3"));// passivate node
      assertTrue(loader.exists(Fqn.fromString("/a/3")));
      cache.evict(Fqn.fromString("/a"));// passivate node
      assertTrue(loader.exists(Fqn.fromString("/a")));
      addDelay();
      DummyTransactionManager mgr = DummyTransactionManager.getInstance();
      mgr.begin();
      mgr.getTransaction();
      Set<?> children = cache.getNode("/a").getChildrenNames();
      assertEquals(3, children.size());
      assertTrue(children.contains("1"));
      assertTrue(children.contains("2"));
      assertTrue(children.contains("3"));
      mgr.commit();
   }
View Full Code Here

   public void testTxPutCommit() throws Exception
   {
      CacheSPI<Object, Object> cache = cacheTL.get();
      CacheLoader loader = loaderTL.get();

      DummyTransactionManager mgr = DummyTransactionManager.getInstance();
      mgr.begin();

      cache.put("/one/two/three", "key1", "val1");
      cache.put("/one/two/three/four", "key2", "val2");

      mgr.commit();

      assertNotNull(cache.getNode("/one/two/three").getKeys());
      assertEquals("val1", cache.get(Fqn.fromString("/one/two/three"), "key1"));
      mgr.begin();

      cache.evict(Fqn.fromString("/one/two/three"));
      cache.evict(Fqn.fromString("/one/two/three/four"));

      mgr.commit();
      assertTrue(loader.exists(Fqn.fromString("/one/two/three")));
      assertTrue(loader.exists(Fqn.fromString("/one/two/three/four")));
      assertNotNull(cache.getNode("/one/two/three").getKeys());
      Set<?> children = cache.getNode("/one").getChildrenNames();
      assertEquals(1, children.size());
View Full Code Here

TOP

Related Classes of org.jboss.cache.transaction.DummyTransactionManager

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.