org.jboss.test.jbossmx.compliance.timer
Class BasicTestCase

java.lang.Object
  extended byjunit.framework.TestCase
      extended byorg.jboss.test.jbossmx.compliance.TestCase (src) 
          extended byorg.jboss.test.jbossmx.compliance.timer.BasicTestCase
All Implemented Interfaces:
java.util.EventListener, NotificationListener (src)

public class BasicTestCase
extends TestCase (src)
implements NotificationListener (src)

Basic timer test.

The aim of these tests is to check the most common uses of the timer service.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jboss.test.jbossmx.compliance.TestCase (src)
log, MBEAN_SERVER_DELEGATE, PERIOD, REPEATS, WAIT
 
Constructor Summary
BasicTestCase(java.lang.String s)
           
 
Method Summary
 void checkNotificationID(TimerNotification (src)  pNotification, java.lang.Integer pNotificationID)
          Checks if the given Notification ID is the same as the one of the given Notification
 void checkTimeDifference(TimerNotification (src)  pNotificationOne, TimerNotification (src)  pNotificationTwo, long pTimeDiffernce)
          Checks if the time between the two Notification is in a +- 10% limit
 void expectNotifications(int expected)
          Wait for the timer notification and see if we have the correct number hopefully this should synchronize this test with the timer thread.
 void expectNotifications(int expected, long wait)
          Wait for the timer notification and see if we have the correct number hopefully this should synchronize this test with the timer thread.
 void handleNotification(Notification (src)  notification, java.lang.Object handback)
          Handle a notification, just add it to the list
 void testInfiniteNotification()
          Test infinite notification works.
 void testRepeatedNotification()
          Test a repeated notification works.
 void testSingleNotification()
          Test a single notification works.
 void testTwoNotificationProducers()
          Test two infinite notification works.
 
Methods inherited from class org.jboss.test.jbossmx.compliance.TestCase (src)
testServerFound
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicTestCase

public BasicTestCase(java.lang.String s)
Method Detail

testSingleNotification

public void testSingleNotification()
                            throws java.lang.Exception
Test a single notification works.

Throws:
java.lang.Exception

testRepeatedNotification

public void testRepeatedNotification()
                              throws java.lang.Exception
Test a repeated notification works.

Throws:
java.lang.Exception

testInfiniteNotification

public void testInfiniteNotification()
                              throws java.lang.Exception
Test infinite notification works.

Throws:
java.lang.Exception

testTwoNotificationProducers

public void testTwoNotificationProducers()
                                  throws java.lang.Exception
Test two infinite notification works.

Throws:
java.lang.Exception

handleNotification

public void handleNotification(Notification (src)  notification,
                               java.lang.Object handback)
Handle a notification, just add it to the list

Specified by:
handleNotification in interface NotificationListener (src)
Parameters:
notification - the notification received
handback - not used

expectNotifications

public void expectNotifications(int expected)
                         throws java.lang.Exception
Wait for the timer notification and see if we have the correct number hopefully this should synchronize this test with the timer thread.

Parameters:
expected - the number of notifications expected
Throws:
java.lang.Exception - when the notifications are incorrect

expectNotifications

public void expectNotifications(int expected,
                                long wait)
                         throws java.lang.Exception
Wait for the timer notification and see if we have the correct number hopefully this should synchronize this test with the timer thread.

Parameters:
expected - the number of notifications expected
wait - time in milli seconds to wait for the notification
Throws:
java.lang.Exception - when the notifications are incorrect

checkNotificationID

public void checkNotificationID(TimerNotification (src)  pNotification,
                                java.lang.Integer pNotificationID)
Checks if the given Notification ID is the same as the one of the given Notification

Parameters:
pNotification - Notification to be tested
pNotificationID - Id the Notification should have

checkTimeDifference

public void checkTimeDifference(TimerNotification (src)  pNotificationOne,
                                TimerNotification (src)  pNotificationTwo,
                                long pTimeDiffernce)
Checks if the time between the two Notification is in a +- 10% limit

Parameters:
pNotificationOne - First Notification to be tested
pNotificationTwo - Second Notification to be tested
pTimeDiffernce - Expected Time Difference