Examples of DummyTransactionManager


Examples of org.jboss.cache.transaction.DummyTransactionManager

   }


   public void testTxPutCommit() throws Exception
   {
      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

Examples of org.jboss.cache.transaction.DummyTransactionManager

      cache.removeNode(Fqn.ROOT);
   }

   public void testTxReadCommit() throws Exception
   {
      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")));

      // now do a READ in a TX
      mgr.begin();
      assert cache.get("/one/two/three", "key1").equals("val1");
      assert cache.get("/one/two/three/four", "key2").equals("val2");
      mgr.commit();

      // these should NOT exist in the CL anymore!
      assert !loader.exists(Fqn.fromString("/one/two/three/four"));
   }
View Full Code Here

Examples of org.jboss.cache.transaction.DummyTransactionManager

   }


   public void testTxPutRollback() throws Exception
   {
      DummyTransactionManager mgr = DummyTransactionManager.getInstance();

      cache.removeNode("/one");
      addDelay();
      mgr.begin();

      cache.put("/one/two/three", "key1", "val1");
      cache.put("/one/two/three/four", "key2", "val2");
      mgr.rollback();
      addDelay();
      assertNull(cache.getNode("/one/two/three"));
      assert cache.getNode("/one") == null;

      assertFalse(loader.exists(Fqn.fromString("/one/two/three")));
View Full Code Here

Examples of org.jboss.cache.transaction.DummyTransactionManager

    */
   public void testBasicOperationsTransactional()
         throws Exception
   {

      DummyTransactionManager mgr = DummyTransactionManager.getInstance();
      mgr.begin();
      doTestBasicOperations();
      mgr.commit();
   }
View Full Code Here

Examples of org.jboss.cache.transaction.DummyTransactionManager

    * Tests basic operations with a transaction.
    */
   public void testModificationsTransactional()
         throws Exception
   {
      DummyTransactionManager mgr = DummyTransactionManager.getInstance();
      mgr.begin();
      doTestModifications();
      mgr.commit();
   }
View Full Code Here

Examples of org.jboss.cache.transaction.DummyTransactionManager

    public void testGetKeysIsolationTransaction() throws Exception
    {

        TreeCache cache = createCacheWithListener();

        DummyTransactionManager mgr = DummyTransactionManager.getInstance();
        if (mgr.getTransaction() != null) mgr.rollback();
        assertNull(mgr.getTransaction());

        // first put in a value
        mgr.begin();

        assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
        assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());

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

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

        mgr.commit();

        mgr.begin();
        Transaction tx = mgr.getTransaction();
        assertEquals(1, cache.getKeys("/one/two").size());
        // start another
        mgr.suspend();

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

        mgr.commit();

        // assert we can see this outsode the existing tx
        assertEquals(2, cache.getKeys("/one/two").size());

        // resume the suspended one
        mgr.resume(tx);
        // assert we can't see thge change from tx2 as we already touched the node
        assertEquals(1, cache.getKeys("/one/two").size());
        mgr.commit();
        destroyCache(cache);

    }
View Full Code Here

Examples of org.jboss.cache.transaction.DummyTransactionManager

    public void testTxRollbackThroughConcurrentWrite() throws Exception
    {
        TreeCache cache = createCacheWithListener();
        Set keys;

        DummyTransactionManager mgr = DummyTransactionManager.getInstance();
        if (mgr.getTransaction() != null) mgr.rollback();
        assertNull(mgr.getTransaction());

        // first put in a value
        mgr.begin();
        assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
        assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());
        cache.put("/one/two", "key1", "val1");
        mgr.commit();
        keys = cache.getKeys("/one/two");
        System.out.println("keys after TX #1: " + keys);
        assertEquals(1, keys.size());

        // First TX
        mgr.begin();
        Transaction tx = mgr.getTransaction();
        cache.put("/one/two", "key2", "val2"); // version for this is 1

        // start another
        mgr.suspend();

        // Second TX
        mgr.begin();
        cache.put("/one/two", "key3", "val3");
        mgr.commit(); // now version is 2, attrs are key1 and key3

        // assert we can see this outside the existing tx
        keys = cache.getKeys("/one/two");
        System.out.println("keys after TX #3 committed: " + keys);
        assertEquals(2, keys.size());

        // resume the suspended one
        mgr.resume(tx);
        // assert we can't see the change from tx2 as we already touched the node
        keys = cache.getKeys("/one/two");
        System.out.println("keys after TX #2 resumed (in private workspace of TX #2): " + keys);
        assertEquals(2, keys.size()); // we will see key1 and key2, but *not* key3

        // this will fail as our workspace has version 1, whereas cache has 2; TX will be rolled back
        try
        {
            mgr.commit();
            fail("TX should fail as other TX incremented version number");
        }
        catch (RollbackException rollback_ex)
        {
            System.out.println("TX was rolled back because the other TX committed first and incremented version ID." +
View Full Code Here

Examples of org.jboss.cache.transaction.DummyTransactionManager

    public void testPuts() throws Exception
    {
        TreeCache cache = createCache();
        Transaction tx;

        DummyTransactionManager mgr = DummyTransactionManager.getInstance();
        Assert.assertNull(cache.get(fqn));

        mgr.begin();
        cache.put(fqn, key, value);
        Assert.assertEquals(value, cache.get(fqn, key));
        tx = mgr.getTransaction();
        mgr.suspend();

        mgr.begin();
        Assert.assertNull(cache.get(fqn, key));
        mgr.commit();

        mgr.resume(tx);
        Assert.assertEquals(value, cache.get(fqn, key));
        mgr.commit();

        Assert.assertEquals(value, cache.get(fqn, key));

    }
View Full Code Here

Examples of org.jboss.cache.transaction.DummyTransactionManager

    public void testRemoves() throws Exception
    {
        TreeCache cache = createCache();
        Transaction tx;

        DummyTransactionManager mgr = DummyTransactionManager.getInstance();
        Assert.assertNull(cache.get(fqn));
        cache.put(fqn, key, value);
        Assert.assertEquals(value, cache.get(fqn, key));

        mgr.begin();
        Assert.assertEquals(value, cache.get(fqn, key));
        cache.remove(fqn);
        Assert.assertNull(cache.get(fqn));
        tx = mgr.getTransaction();
        mgr.suspend();

        mgr.begin();
        Assert.assertEquals(value, cache.get(fqn, key));
        mgr.commit();

        mgr.resume(tx);
        Assert.assertNull(cache.get(fqn));
        mgr.commit();

        Assert.assertNull(cache.get(fqn));
    }
View Full Code Here

Examples of org.jboss.cache.transaction.DummyTransactionManager

    public void testRemovesBeforeGet() throws Exception
    {
        TreeCache cache = createCache();
        Transaction tx;

        DummyTransactionManager mgr = DummyTransactionManager.getInstance();
        Assert.assertNull(cache.get(fqn));
        cache.put(fqn, key, value);
        Assert.assertEquals(value, cache.get(fqn, key));

        mgr.begin();
        cache.remove(fqn);
        Assert.assertNull(cache.get(fqn));
        tx = mgr.getTransaction();
        mgr.suspend();

        mgr.begin();
        Assert.assertEquals(value, cache.get(fqn, key));
        mgr.commit();

        mgr.resume(tx);
        Assert.assertNull(cache.get(fqn));
        mgr.commit();

        Assert.assertNull(cache.get(fqn));
    }
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.