[jboss-cvs] JBoss Messaging SVN: r4242 - trunk/tests/src/org/jboss/messaging/tests/unit/core/util.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon May 19 16:23:03 EDT 2008
Author: clebert.suconic at jboss.com
Date: 2008-05-19 16:23:03 -0400 (Mon, 19 May 2008)
New Revision: 4242
Modified:
trunk/tests/src/org/jboss/messaging/tests/unit/core/util/VariableLatchTest.java
Log:
Adding new test for latch
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/util/VariableLatchTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/util/VariableLatchTest.java 2008-05-19 18:07:29 UTC (rev 4241)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/util/VariableLatchTest.java 2008-05-19 20:23:03 UTC (rev 4242)
@@ -246,10 +246,70 @@
{
assertFalse (waits[i].waiting);
}
+ }
+
+ public void testReuseLatch() throws Exception
+ {
+ final VariableLatch latch = new VariableLatch();
+ latch.up();
+ class ThreadWait extends Thread
+ {
+ boolean waiting = false;
+ Exception e;
+ CountDownLatch readyLatch = new CountDownLatch(1);
+ public void run()
+ {
+ waiting = true;
+ readyLatch.countDown();
+ try
+ {
+ latch.waitCompletion(5);
+ }
+ catch (Exception e)
+ {
+ log.error(e);
+ this.e = e;
+ }
+ waiting = false;
+ }
+ }
+ ThreadWait t = new ThreadWait();
+ t.start();
+ t.readyLatch.await();
+ assertEquals(true, t.waiting);
+
+ latch.down();
+
+ t.join();
+
+ assertEquals(false, t.waiting);
+
+ assertNull(t.e);
+
+ latch.up();
+
+ t = new ThreadWait();
+ t.start();
+
+ t.readyLatch.await();
+
+ assertEquals(true, t.waiting);
+
+ latch.down();
+
+ t.join();
+
+ assertEquals(false, t.waiting);
+
+ assertNull(t.e);
+
+
+
+
}
More information about the jboss-cvs-commits
mailing list