[jboss-svn-commits] JBL Code SVN: r19803 - labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu May 1 09:03:43 EDT 2008


Author: kevin.conner at jboss.com
Date: 2008-05-01 09:03:43 -0400 (Thu, 01 May 2008)
New Revision: 19803

Modified:
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests/InVMCourierUnitTest.java
Log:
fix race: JBESB-1700

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests/InVMCourierUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests/InVMCourierUnitTest.java	2008-05-01 12:04:04 UTC (rev 19802)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests/InVMCourierUnitTest.java	2008-05-01 13:03:43 UTC (rev 19803)
@@ -65,14 +65,8 @@
         producer.start();
         consumer.start();
 
-        try {
-            synchronized (consumer.condition()) {
-                consumer.condition().wait();
-            }
-        }
-        catch (Exception ex) {
-            ex.printStackTrace();
-        }
+        consumer.join(TIMEOUT) ;
+        Assert.assertTrue("Consumer valid", consumer.valid()) ;
 
         Assert.assertEquals(consumer.valid(), true);
     }
@@ -87,21 +81,15 @@
         consumer.start();
 
         try {
-            Thread.currentThread().sleep(500);
+            Thread.sleep(500);
         }
         catch (Exception ex) {
         }
 
         producer.start();
 
-        try {
-            synchronized (consumer.condition()) {
-                consumer.condition().wait();
-            }
-        }
-        catch (Exception ex) {
-            ex.printStackTrace();
-        }
+        consumer.join(TIMEOUT) ;
+        Assert.assertTrue("Consumer valid", consumer.valid()) ;
 
         Assert.assertEquals(consumer.valid(), true);
     }
@@ -115,19 +103,14 @@
         consumer.start();
 
         try {
-            Thread.currentThread().sleep(500);
+            Thread.sleep(500);
         }
         catch (Exception ex) {
         }
 
-        try {
-            synchronized (consumer.condition()) {
-                consumer.condition().wait();
-            }
-        }
-        catch (Exception ex) {
-            ex.printStackTrace();
-        }
+        consumer.join(TIMEOUT) ;
+        Assert.assertFalse("Consumer terminated", consumer.isAlive()) ;
+        Assert.assertFalse("Consumer valid", consumer.valid()) ;
 
         Assert.assertEquals(consumer.valid(), false);
     }
@@ -142,14 +125,8 @@
         consumer.start();
         producer.start();
 
-        try {
-            synchronized (consumer.condition()) {
-                consumer.condition().wait();
-            }
-        }
-        catch (Exception ex) {
-            ex.printStackTrace();
-        }
+        consumer.join(TIMEOUT) ;
+        Assert.assertTrue("Consumer valid", consumer.valid()) ;
 
         Assert.assertEquals(consumer.valid(), true);
     }
@@ -188,14 +165,8 @@
         for (int j = 0; j < numberOfProducers; j++)
             producer[j].start();
 
-        try {
-            synchronized (consumer.condition()) {
-                consumer.condition().wait();
-            }
-        }
-        catch (Exception ex) {
-            ex.printStackTrace();
-        }
+        consumer.join(TIMEOUT) ;
+        Assert.assertTrue("Consumer valid", consumer.valid()) ;
 
         long ftime = System.currentTimeMillis();
         double factor = 1000.00 / (ftime - stime);
@@ -237,6 +208,7 @@
     }*/
 
     public static final int ITERATIONS = 10;
+    public static final int TIMEOUT = 30000;
 }
 
 class Producer extends Thread {
@@ -293,10 +265,6 @@
         _debug = debug;
     }
 
-    public Object condition() {
-        return _condition;
-    }
-
     public void run() {
         try {
             int i;
@@ -324,11 +292,6 @@
         catch (Exception ex) {
             ex.printStackTrace();
         }
-        finally {
-            synchronized (condition()) {
-                condition().notify();
-            }
-        }
 
         courier = null;
     }
@@ -350,6 +313,4 @@
     private boolean _debug;
 
     private int _itersCompleted = 0;
-
-    private Object _condition = new Object();
 }
\ No newline at end of file




More information about the jboss-svn-commits mailing list