Index: src/main/org/jboss/test/jbossmx/compliance/timer/BasicTestCase.java
===================================================================
--- src/main/org/jboss/test/jbossmx/compliance/timer/BasicTestCase.java	(revision 113578)
+++ src/main/org/jboss/test/jbossmx/compliance/timer/BasicTestCase.java	(working copy)
@@ -21,8 +21,9 @@
  */
 package org.jboss.test.jbossmx.compliance.timer;
 
-import java.util.ArrayList;
 import java.util.Date;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
 
 import javax.management.MBeanServer;
 import javax.management.MBeanServerFactory;
@@ -59,7 +60,7 @@
   /**
    * The received notifications
    */
-  ArrayList receivedNotifications = new ArrayList();
+  LinkedBlockingQueue receivedNotifications = new LinkedBlockingQueue();
 
   // Constructor ---------------------------------------------------------------
 
@@ -82,7 +83,7 @@
 
       Integer id = addNotification("test", "hello", "data", calcTime(PERIOD),
                                    0, 1);
-      expectNotifications(1);
+      expectedNotifications();
 
 // TODO
 //      if (getNotificationType(id) != null)
@@ -105,8 +106,8 @@
       startTimerService();
       Integer id = addNotification("test", "hello", "data", calcTime(PERIOD),
                                    PERIOD, REPEATS);
-      expectNotifications(1);
-      expectNotifications(2);
+      expectedNotifications();
+      expectedNotifications();
 
 // TODO
 //      if (getNotificationType(id) != null)
@@ -130,8 +131,8 @@
 
       Integer id = addNotification("test", "hello", "data", calcTime(PERIOD),
                                    PERIOD, 0);
-      expectNotifications(1);
-      expectNotifications(2);
+      expectedNotifications();
+      expectedNotifications();
 
       if (getNotificationType(id) == null)
         fail("Infinite notification not registered");
@@ -160,38 +161,33 @@
          Integer lIdTwo = addNotification( "test-2", "hello", "data", lStart + lTimeTwo,
                                            lTimeTwo, 0);
          
-         expectNotifications( 1, lWait );
-         expectNotifications( 2, lWait );
-         // Check time differences which should be around TIME ONE
-         TimerNotification lNotificationOne = (TimerNotification) receivedNotifications.get( 0 );
-         TimerNotification lNotificationTwo = (TimerNotification) receivedNotifications.get( 1 );
+       // Check time differences which should be around TIME ONE
+         TimerNotification lNotificationOne = expectNotifications(lWait);
+         TimerNotification lNotificationTwo = expectNotifications(lWait);
          checkNotificationID( lNotificationOne, lIdOne );
          checkNotificationID( lNotificationTwo, lIdOne );
          checkTimeDifference( lNotificationOne, lNotificationTwo, lTimeOne );
          
-         expectNotifications( 3, lWait );
          lNotificationOne = lNotificationTwo;
-         lNotificationTwo = (TimerNotification) receivedNotifications.get( 2 );
+         lNotificationTwo = expectNotifications(lWait);
          checkNotificationID( lNotificationTwo, lIdTwo );
          checkTimeDifference( lNotificationOne, lNotificationTwo, ( lTimeTwo - ( 2 * lTimeOne ) ) );
          
-         expectNotifications( 4, lWait );
          lNotificationOne = lNotificationTwo;
-         lNotificationTwo = (TimerNotification) receivedNotifications.get( 3 );
+         lNotificationTwo = expectNotifications(lWait);
          checkNotificationID( lNotificationTwo, lIdOne );
          checkTimeDifference( lNotificationOne, lNotificationTwo, ( ( 3 * lTimeOne ) - lTimeTwo ) );
          
-         expectNotifications( 5, lWait );
          lNotificationOne = lNotificationTwo;
-         lNotificationTwo = (TimerNotification) receivedNotifications.get( 4 );
+         lNotificationTwo = expectNotifications(lWait);
          checkNotificationID( lNotificationTwo, lIdOne );
          checkTimeDifference( lNotificationOne, lNotificationTwo, lTimeOne );
          
-         expectNotifications( 6, lWait );
          lNotificationOne = lNotificationTwo;
-         lNotificationTwo = (TimerNotification) receivedNotifications.get( 5 );
+         lNotificationTwo = expectNotifications(lWait);
          checkNotificationID( lNotificationTwo, lIdTwo );
          checkTimeDifference( lNotificationOne, lNotificationTwo, ( ( 2 * lTimeTwo ) - ( 4 * lTimeOne ) ) );
+       
       }
       finally
       {
@@ -249,53 +245,35 @@
 
   /**
    * Handle a notification, just add it to the list
-   *
    * @param notification the notification received
    * @param handback not used
    */
   public void handleNotification(Notification notification, Object handback)
   {
-    synchronized (receivedNotifications)
-    {
       receivedNotifications.add(notification);
-      receivedNotifications.notifyAll();
-    }
   }
 
   /**
-   * Wait for the timer notification and see if we have the correct number
-   * hopefully this should synchronize this test with the timer thread.
-   *
-   * @param expected the number of notifications expected
-   * @throws Exception when the notifications are incorrect
+   * Wait for the timer notification and see if we have one in the queue
+   * @param wait
+   * @return the head of this queue
+   * @throws Exception
    */
-  public void expectNotifications(int expected)
+  public TimerNotification expectNotifications(long wait)
     throws Exception
   {
-     expectNotifications( expected, WAIT );
+      TimerNotification notification = (TimerNotification) receivedNotifications.poll(wait,TimeUnit.MILLISECONDS);
+      assertNotNull("No notification received before time out." , notification);
+      return notification;
   }
 
   /**
-   * Wait for the timer notification and see if we have the correct number
-   * hopefully this should synchronize this test with the timer thread.
-   *
-   * @param expected the number of notifications expected
-   * @param wait time in milli seconds to wait for the notification
-   * @throws Exception when the notifications are incorrect
+   * Wait for the timer notification and see if we have one in the queue
+   * @throws InterruptedException
    */
-  public void expectNotifications(int expected, long wait)
-    throws Exception
-  {
-     synchronized (receivedNotifications)
-     {
-       if (receivedNotifications.size() > expected)
-         fail("too many notifications");
-       if (receivedNotifications.size() < expected)
-       {
-         receivedNotifications.wait( wait );
-       }
-       assertEquals(expected, receivedNotifications.size());
-     }
+  public void expectedNotifications() throws InterruptedException{
+
+      assertNotNull("No notification received before time out." , receivedNotifications.poll(WAIT, TimeUnit.MILLISECONDS));
   }
 
   /**
Index: src/main/org/jboss/test/jbossmx/compliance/monitor/BasicTestCase.java
===================================================================
--- src/main/org/jboss/test/jbossmx/compliance/monitor/BasicTestCase.java	(revision 113578)
+++ src/main/org/jboss/test/jbossmx/compliance/monitor/BasicTestCase.java	(working copy)
@@ -21,7 +21,8 @@
  */
 package org.jboss.test.jbossmx.compliance.monitor;
 
-import java.util.ArrayList;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
 
 import javax.management.Attribute;
 import javax.management.AttributeList;
@@ -83,7 +84,7 @@
   /**
    * The received notifications
    */
-  ArrayList receivedNotifications = new ArrayList();
+  LinkedBlockingQueue receivedNotifications = new LinkedBlockingQueue();
 
   // Constructor ---------------------------------------------------------------
 
@@ -112,10 +113,10 @@
        assertTrue("ObservedObjects[0] == Monitor:type=CounterSupport",
           observed[0].equals(observedObject));
 
-      setAttribute(null, 0);
-      setAttribute(new Integer(10), 1);
-      setAttribute(new Integer(9), 1);
-      setAttribute(new Integer(10), 2);
+      setAttribute(null, false);
+      setAttribute(new Integer(10), true);
+      setAttribute(new Integer(9), false);
+      setAttribute(new Integer(10), true);
     }
     finally
     {
@@ -136,11 +137,11 @@
       observedAttribute = "Value";
       startCounterService(true, 0, 0, 10);
 
-      setAttribute(null, 0);
-      setAttribute(new Integer(10), 1);
-      setAttribute(new Integer(9), 1);
-      setAttribute(new Integer(10), 1);
-      setAttribute(new Integer(20), 2);
+      setAttribute(null, false);
+      setAttribute(new Integer(10), true);
+      setAttribute(new Integer(9), false);
+      setAttribute(new Integer(10), false);
+      setAttribute(new Integer(20), true);
     }
     finally
     {
@@ -161,13 +162,13 @@
       observedAttribute = "Value";
       startGaugeService(true, true, false, 10, 0);
 
-      setAttribute(null, 1);
-      setAttribute(new Integer(10), 2);
-      setAttribute(new Integer(9), 2);
-      setAttribute(new Integer(10), 2);
-      setAttribute(new Integer(0), 3);
-      setAttribute(new Integer(1), 3);
-      setAttribute(new Integer(0), 3);
+      setAttribute(null, true);
+      setAttribute(new Integer(10), true);
+      setAttribute(new Integer(9), false);
+      setAttribute(new Integer(10), false);
+      setAttribute(new Integer(0), true);
+      setAttribute(new Integer(1), false);
+      setAttribute(new Integer(0), false);
     }
     finally
     {
@@ -188,12 +189,12 @@
       observedAttribute = "Value";
       startGaugeService(true, false, false, 10, 0);
 
-      setAttribute(null, 0);
-      setAttribute(new Integer(10),1 );
-      setAttribute(new Integer(9), 1);
-      setAttribute(new Integer(10), 1);
-      setAttribute(new Integer(0), 1);
-      setAttribute(new Integer(10), 2);
+      setAttribute(null, false);
+      setAttribute(new Integer(10),true);
+      setAttribute(new Integer(9), false);
+      setAttribute(new Integer(10), false);
+      setAttribute(new Integer(0), false);
+      setAttribute(new Integer(10), true);
     }
     finally
     {
@@ -214,12 +215,12 @@
       observedAttribute = "Value";
       startGaugeService(false, true, false, 10, 0);
 
-      setAttribute(null, 1);
-      setAttribute(new Integer(10), 1);
-      setAttribute(new Integer(9), 1);
-      setAttribute(new Integer(0), 2);
-      setAttribute(new Integer(1), 2);
-      setAttribute(new Integer(0), 2);
+      setAttribute(null, true);
+      setAttribute(new Integer(10), false);
+      setAttribute(new Integer(9), false);
+      setAttribute(new Integer(0), true);
+      setAttribute(new Integer(1), false);
+      setAttribute(new Integer(0), false);
     }
     finally
     {
@@ -242,9 +243,9 @@
 
       // until sun-bug #6200031 gets resolved, reduce the counters by one
       // not expecting a MonitorNotification.OBSERVED_ATTRIBUTE_TYPE_ERROR
-      setAttribute(null, 0);
-      setAttribute("test", 1);
-      setAttribute("not-test", 2);
+      setAttribute(null, false);
+      setAttribute("test", true);
+      setAttribute("not-test", true);
     }
     finally
     {
@@ -267,9 +268,9 @@
 
       // until sun-bug #6200031 gets resolved, reduce the counters by one
       // not expecting a MonitorNotification.OBSERVED_ATTRIBUTE_TYPE_ERROR
-      setAttribute(null, 0);
-      setAttribute("test", 1);
-      setAttribute("not-test", 1);
+      setAttribute(null, false);
+      setAttribute("test", true);
+      setAttribute("not-test", false);
     }
     finally
     {
@@ -292,9 +293,9 @@
 
       // until sun-bug #6200031 gets resolved, reduce the counters by one
       // not expecting a MonitorNotification.OBSERVED_ATTRIBUTE_TYPE_ERROR
-      setAttribute(null, 0);
-      setAttribute("test", 0);
-      setAttribute("not-test", 1);
+      setAttribute(null, false);
+      setAttribute("test", false);
+      setAttribute("not-test", true);
     }
     finally
     {
@@ -439,10 +440,10 @@
    * Set an attribute and check the correct notifications are received
    * @param value the value to set, null is past at the start - only
    *        the check is perform
-   * @param expected the expected number of notifications after setting
-   *        the value
+   * @param expected the expected boolean value, to check if queue is empty
+   * @throws Exception
    */
-  private void setAttribute(Object value, int expected)
+  private void setAttribute(Object value, boolean expected)
     throws Exception
   {
     // Set the attribute unless the test has just started
@@ -452,15 +453,12 @@
       server.setAttribute(observedObject, attribute);
     }
 
-    // Wait for the notification
-    synchronized (receivedNotifications)
-    {
-      if (receivedNotifications.size() > expected )
-        fail("too many notifications");
-      if (receivedNotifications.size() <= expected )
-        receivedNotifications.wait(WAIT);
-      assertEquals(expected, receivedNotifications.size());
-    }
+    // Wait for the notification, and check if queue have one element
+      
+      if(expected)
+          assertNotNull("No notification received before time out." ,receivedNotifications.poll(WAIT, TimeUnit.MILLISECONDS));
+      else
+          assertNull("Wrong notification received." ,receivedNotifications.poll(WAIT,TimeUnit.MILLISECONDS));
   }
 
   /**
@@ -471,10 +469,6 @@
    */
   public void handleNotification(Notification notification, Object handback)
   {
-    synchronized (receivedNotifications)
-    {
       receivedNotifications.add(notification);
-      receivedNotifications.notifyAll();
-    }
   }
 }
