[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/optimistic ...

Manik Surtani msurtani at jboss.com
Wed Dec 6 11:00:14 EST 2006


  User: msurtani
  Date: 06/12/06 11:00:14

  Added:       tests/functional/org/jboss/cache/optimistic  Tag:
                        Branch_JBossCache_1_4_0 RemoveBeforeCreateTest.java
  Log:
  JBCACHE-894
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +102 -0    JBossCache/tests/functional/org/jboss/cache/optimistic/Attic/RemoveBeforeCreateTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: RemoveBeforeCreateTest.java
  ===================================================================
  RCS file: RemoveBeforeCreateTest.java
  diff -N RemoveBeforeCreateTest.java
  --- /dev/null	1 Jan 1970 00:00:00 -0000
  +++ RemoveBeforeCreateTest.java	6 Dec 2006 16:00:14 -0000	1.1.2.1
  @@ -0,0 +1,102 @@
  +package org.jboss.cache.optimistic;
  +
  +import org.jboss.cache.TreeCache;
  +import org.jboss.cache.OptimisticTreeNode;
  +import org.jboss.cache.Fqn;
  +import org.jboss.cache.misc.TestingUtil;
  +
  +import javax.transaction.TransactionManager;
  +
  +/**
  + * Tests removal of a node before the node is even created.
  + */
  +public class RemoveBeforeCreateTest extends AbstractOptimisticTestCase
  +{
  +   TreeCache[] c = null;
  +   TransactionManager t;
  +
  +   protected void setUp() throws Exception
  +   {
  +      c = new TreeCache[2];
  +      c[0] = createReplicatedCache(TreeCache.REPL_ASYNC);
  +      c[1] = createReplicatedCache(TreeCache.REPL_ASYNC);
  +
  +      TestingUtil.blockUntilViewsReceived(c, 20000);
  +
  +      t = c[0].getTransactionManager();
  +   }
  +
  +   protected void tearDown()
  +   {
  +      if (c != null)
  +      {
  +         destroyCache(c[0]);
  +         destroyCache(c[1]);
  +         c = null;
  +      }
  +   }
  +
  +   public RemoveBeforeCreateTest(String name)
  +   {
  +      super(name);
  +   }
  +
  +   public void testControl() throws Exception
  +   {
  +      t.begin();
  +      c[0].put("/control", "key", "value");
  +      t.commit();
  +
  +      assertEquals("value", c[0].get("/control", "key"));
  +      assertEquals("value", c[1].get("/control", "key"));
  +      
  +      DefaultDataVersion v1 = (DefaultDataVersion) ((OptimisticTreeNode) c[0].get("/control")).getVersion();
  +      assertEquals(1, v1.getRawVersion());
  +
  +      DefaultDataVersion v2 = (DefaultDataVersion) ((OptimisticTreeNode) c[1].get("/control")).getVersion();
  +      assertEquals(1, v2.getRawVersion());
  +
  +
  +   }
  +
  +   public void testRemoveBeforePut() throws Exception
  +   {
  +      Fqn f = Fqn.fromString("/test");
  +      assertNull(c[0].get(f));
  +      assertNull(c[1].get(f));
  +
  +      t.begin();
  +      c[0].remove(f);
  +
  +      // should NOT barf!!!
  +      t.commit();
  +
  +      assertNull(c[0].get(f));
  +      assertNull(c[1].get(f));
  +   }
  +
  +   public void testCCEOnPrepare() throws Exception
  +   {
  +      Fqn f = Fqn.fromString("/test");
  +
  +      try
  +      {
  +         t.begin();
  +         c[0].remove(f);
  +
  +         // should NOT barf!!!
  +         t.commit();
  +      }
  +      catch (Exception e)
  +      {
  +         e.printStackTrace();
  +         System.out.println("***** Expected *****");
  +      }
  +
  +      t.begin();
  +      c[0].put(f, "key", "value");
  +      t.commit();
  +   }
  +  
  +
  +}
  
  
  



More information about the jboss-cvs-commits mailing list