[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/optimistic ...
Manik Surtani
manik at jboss.org
Fri Jul 20 11:28:20 EDT 2007
User: msurtani
Date: 07/07/20 11:28:20
Modified: tests/functional/org/jboss/cache/optimistic
ConcurrentTransactionTest.java
Log:
JBCACHE-1067
Revision Changes Path
1.10 +44 -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.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- ConcurrentTransactionTest.java 19 Jul 2007 12:56:21 -0000 1.9
+++ ConcurrentTransactionTest.java 20 Jul 2007 15:28:20 -0000 1.10
@@ -159,6 +159,50 @@
}
+ public void testConcurrentPutReadAndRemove() throws Exception
+ {
+ final List exceptions = new LinkedList();
+ final CountDownLatch readerLatch = new CountDownLatch(1);
+ final CountDownLatch readerFinishedLatch = new CountDownLatch(1);
+ 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.countDown();
+ readerLatch.await(); // wait
+ cache.getTransactionManager().commit();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ exceptions.add(e);
+
+ }
+ }
+ }
+
+ Thread reader = new Reader();
+
+ reader.start();
+ readerFinishedLatch.await();
+ cache.removeNode(fqn.getParent());
+ assertNull(cache.peek(fqn.getParent(), false));
+ readerLatch.countDown();
+ reader.join();
+
+ assertTrue("Should not have caught any exceptions!!", exceptions.isEmpty());
+ }
+
+
private void doConcurrentCreationTest(boolean prepopulateParent) throws Exception
{
if (prepopulateParent) cache.put(Fqn.fromString("/parent/dummy"), "k", "v");
More information about the jboss-cvs-commits
mailing list