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

Manik Surtani manik at jboss.org
Fri Jul 20 11:27:04 EDT 2007


  User: msurtani
  Date: 07/07/20 11:27:04

  Modified:    tests/functional/org/jboss/cache/optimistic  Tag:
                        Branch_JBossCache_1_4_0
                        ConcurrentTransactionTest.java
  Log:
  JBCACHE-1067
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.6   +43 -0     JBossCache/tests/functional/org/jboss/cache/optimistic/ConcurrentTransactionTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ConcurrentTransactionTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/optimistic/ConcurrentTransactionTest.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -b -r1.1.2.5 -r1.1.2.6
  --- ConcurrentTransactionTest.java	19 Jul 2007 12:28:08 -0000	1.1.2.5
  +++ ConcurrentTransactionTest.java	20 Jul 2007 15:27:04 -0000	1.1.2.6
  @@ -159,6 +159,49 @@
         assertTrue("Should not have caught any exceptions!!", exceptions.isEmpty());
      }
   
  +   public void testConcurrentPutReadAndRemove() throws Exception
  +   {
  +      final List exceptions = new LinkedList();
  +      final Latch readerLatch = new Latch();
  +      final Latch readerFinishedLatch = new Latch();
  +      final Fqn fqn = Fqn.fromString("/parent/child");
  +
  +      cache.put(fqn, "k", "v");
  +
  +      class Reader extends Thread
  +      {
  +         public void run()
  +         {
  +            try
  +            {
  +               cache.getTransactionManager().begin();
  +               cache.put(Fqn.ROOT, "x", "y"); // a dummy put to ensure that validation occurs
  +               cache.get(fqn, "k"); // read
  +               readerFinishedLatch.release();
  +               readerLatch.acquire(); // wait
  +               cache.getTransactionManager().commit();
  +            }
  +            catch (Exception e)
  +            {
  +               e.printStackTrace();
  +               exceptions.add(e);
  +
  +            }
  +         }
  +      }
  +
  +      Thread reader = new Reader();
  +
  +      reader.start();
  +      readerFinishedLatch.acquire();
  +      cache.remove(fqn.getParent());
  +      assertFalse(cache.exists(fqn.getParent()));
  +      readerLatch.release();
  +      reader.join();
  +
  +      assertTrue("Should not have caught any exceptions!!", exceptions.isEmpty());
  +   }
  +
   
      private void doConcurrentCreationTest(boolean prepopulateParent) throws Exception
      {
  
  
  



More information about the jboss-cvs-commits mailing list