org.jboss.test.jmx.compliance.timer
Class TimerTest

java.lang.Object
  extended byjunit.framework.Assert
      extended byjunit.framework.TestCase
          extended byorg.jboss.test.jmx.compliance.timer.TimerTest
All Implemented Interfaces:
EventListener, javax.management.NotificationListener, junit.framework.Test

public class TimerTest
extends junit.framework.TestCase
implements javax.management.NotificationListener

Basic timer test.

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

Author:
Adrian Brock.

Field Summary
static long PERIOD
          The period for a timer notification.
static long REPEATS
          The number of repeats for occurances tests
static long WAIT
           
 
Constructor Summary
TimerTest(String s)
           
 
Method Summary
 void checkNotificationID(javax.management.timer.TimerNotification pNotification, Integer pNotificationID)
          Checks if the given Notification ID is the same as the one of the given Notification
 void checkTimeDifference(javax.management.timer.TimerNotification pNotificationOne, javax.management.timer.TimerNotification 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(javax.management.Notification notification, 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 junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PERIOD

public static final long PERIOD
The period for a timer notification. This needs to be small so the tests * don't take too long. * The wait needs to be long enough to be sure the monitor has enough time * to send the notification and switch the context to the handler.

See Also:
Constant Field Values

WAIT

public static final long WAIT
See Also:
Constant Field Values

REPEATS

public static final long REPEATS
The number of repeats for occurances tests

See Also:
Constant Field Values
Constructor Detail

TimerTest

public TimerTest(String s)
Method Detail

testSingleNotification

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

Throws:
Exception

testRepeatedNotification

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

Throws:
Exception

testInfiniteNotification

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

Throws:
Exception

testTwoNotificationProducers

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

Throws:
Exception

handleNotification

public void handleNotification(javax.management.Notification notification,
                               Object handback)
Handle a notification, just add it to the list

Specified by:
handleNotification in interface javax.management.NotificationListener
Parameters:
notification - the notification received
handback - not used

expectNotifications

public void expectNotifications(int expected)
                         throws 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:
Exception - when the notifications are incorrect

expectNotifications

public void expectNotifications(int expected,
                                long wait)
                         throws 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:
Exception - when the notifications are incorrect

checkNotificationID

public void checkNotificationID(javax.management.timer.TimerNotification pNotification,
                                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(javax.management.timer.TimerNotification pNotificationOne,
                                javax.management.timer.TimerNotification 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


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.