Lease Renewal Service Tests

Test Name & Motivation

Description

Categorization

Specification Requirements

EqualsTest

Tests the LRS equals method.

Matrix ID 1.

  1. Register two LRS services with a lookup (service #1 and service #2)

  2. Obtain two proxies for service #1 and one proxy for service #2.

  3. Assert that the two proxies from service #1 return true from the “equals” method.

  4. Assert that the proxy from service #1 and the proxy from service #2 return false from the “equals” method.

  5. Create an Integer object new Integer(99).

  6. Assert that service #1 equals the integer returns false.

A1, M1

LRS section 9.3 pg. 107

AddRemoveTest

Tests that the addLease and removeLease methods work as expected.

Matrix ID 26.

  1. Create a lease renewal set with a lease of forever.

  2. Create a valid lease or obtain one from a service with a duration value of forever.

  3. Add the lease to the set using the addLease method with a membership duration of forever.

  4. Remove the lease using the removeLease method.

  5. Assert that the lease returned by removeLease is equal to the lease that was added to the set.

  6. Attempt to remove the lease from the set again.

  7. Assert that removeLease returns a null value.

A1, M1

LRS section 9.3 pg. 109-110

ExpireRemoveTest

Assert that a lease whose membership expiration has expired is removed from the set and that no further attempts to renew the lease are made for at least half the lease duration time, after the lease has expired.

Matrix ID 2, 3, 13

  1. Create a lease renewal set with a lease of forever.

  2. Create a special lease that maintains a count of renewal attempts with a duration value of 60000 milliseconds.

  3. Add the lease to the set using the addLease method with a membership duration of 30000 milliseconds.

  4. Sleep for 40000 milliseconds.

  5. Attempt to remove the lease from the set.

  6. Assert that the call to removeLease returns a null value.

  7. Assert that no lease renewal attempts have been made on the lease.

A1, M1

LRS section 9.3 pg. 108

ExpireSetSleepTest

Assert that a lease renewal set is nullified when its lease expires or is cancelled but the leases it holds remain unaffected.

Matrix ID 4, 10, 19

  1. Create a lease renewal set with a lease of 30000 milliseconds.

  2. Create 3 valid leases with durations of 50000, 100000, and 150000 milliseconds respectively.

  3. Add leases to the lease renewal set with membership duration of forever.

  4. Sleep for 35000 milliseconds.

  5. Use the getLease method to assert that the lease has expired.

  6. Assert that the three original leases are still active and that their expiration times have not changed.

  7. Assert that attempts to remove one of the three original leases fails with a NoSuchObjectException.

  8. Assert that an attempt to add a lease fails with a NoSuchObjectException.

A1, M1

LRS section 9.3 pg. 108

ExpireSetCancelTest

Assert that a lease renewal set is nullified when its lease expires or is cancelled but the leases it holds remain unaffected.

Matrix ID 4, 10, 19

  1. Create a lease renewal set with a lease of 30000 milliseconds.

  2. Create 3 valid leases with durations of 50000, 100000, and 150000 milliseconds respectively.

  3. Add leases to the lease renewal set with membership duration of forever.

  4. Call cancel on the renewal set’s lease.

  5. Use the getLease method to assert that the lease has expired.

  6. Assert that the three original leases are still active and that their expiration times have not changed.

  7. Assert that attempts to remove one of the three original leases fails with a NoSuchObjectException.

  8. Assert that an attempt to add a lease fails with a NoSuchObjectException.

  9. Perform the above 8 steps again except in step #4 cancel the set’s lease instead of sleeping.

A1, M1

LRS section 9.3 pg. 108

ExpirationListenerTest

Assert the following:

  1. An event gets delivered to a RemoteEventListener before a lease in the lease renewal set expires.

  2. The handback in the ExpirationWarningEvent is rational

  3. The listener must be non-null.

  4. The minWarning must be 0 or greater.

  5. A minWarning value that exceeds the current duration of the set’s lease causes immediate delivery of the ExpirationWarningEvent.


Matrix ID 5, 30, 31, 32, 33, 34, 35, 36

  1. Create a special RemoteEventListener which will log the times when it receives notify callbacks.

  2. Create a lease renewal set with lease of 120000 milliseconds.

  3. Create a MarshalledObject from “new Integer(99)” to serve as the handback arg.

  4. Pass the listener to the set’s setExpirationWarningListener method with a minWarning of 60000 milliseconds. Use the MarshalledObject created in step 3 as the handback.

  5. Wait until the renewal set lease has expired.

  6. Assert that the event notification was logged and the current time is approximately lease expiration time minus 60000 milliseconds.

  7. Assert that the MarshalledObject handed back in the ExpirationWarningEvent is equal to the original object handed in. Use the MarshalledObject equals method to make this determination.

  8. Create a lease renewal set with lease of 120000 milliseconds.

  9. Assert that an attempt to call the setExpirationWarningListener method with a null listener throws a NullPointerException.

  10. Assert that an attempt to call the setExpirationWarningListener method with a minWarning value of less than 0 throws an IllegalArgumentException.

  11. Assert that an attempt to call the setExpirationWarningListener method with a minWarning value of 0 does not throw an IllegalArgumentException.

  12. Assert that an attempt to call the setExpirationWarningListener method with a minWarning of 120000 milliseconds the event is logged immediately (minus some slop for propagation time).

A1, M1

LRS section 9.3 pg. 108

RenewalFailureListenerTest


  1. Assert that an event gets delivered to a RemoteEventListener when a lease expires before its expiration time runs out.

  2. The handback in the RnewalFailureEvent is rational

  3. Assert that the lease for the EventRegistration is the same as the set’s lease.

  4. The listener must be non-null.


Matrix ID 7, 44, 45, 46, 47, 49

  1. Create a special lease (duration of 20000 milliseconds) that will throw a definite exception when any attempt is made to renew it.

  2. Create a lease renewal set with a lease of forever.

  3. Create a special RemoteEventListener which will log the times when it receives notify callbacks.

  4. Create a MarshalledObject from “new Integer(99)” to serve as the handback arg.

  5. Establish the listener using the set’s setRenewalFailureListener method and the handback arg. Save the EventRegistration object (eventReg).

  6. Add lease to the set with membership duration of forever.

  7. Assert that eventReg getLease() equals set getLease().

  8. Wait 30000 milliseconds for the listener to send notification.

  9. Assert that the event notification was logged before lease expiration time.

  10. Assert that the MarshalledObject handed back in the RenewalFailureEvent is equal to the original object handed in. Use the MarshalledObject equals method to make this determination.

  11. Assert that an attempt to call the setRenewalFailureListener method with a null listener throws a NullPointerException.

A1, M1

LRS section 9.3 pg. 108

RenewalFailureIndefiniteTest

Assert that an event gets delivered for an indefinite exception only after the expiration time of the lease.

Not in matrix.

  1. Create a special lease (duration of 30000 milliseconds) that will throw an indefinite exception when any attempt is made to renew it and will count the number of times it has been renewed.

  2. Create a lease renewal set with a lease of forever.

  3. Create a special RemoteEventListener which will log the times when it receives notify callbacks.

  4. Establish the listener using the set’s setRenewalFailureListener method.

  5. Add lease to the set with membership duration of forever.

  6. Wait 40000 milliseconds for the listener to send notification.

  7. Assert that the event notification was logged at some time at or after the lease expiration time.

A1, M1

LRS section 9.3 pg. 113-114







RemovalTest

Assert that that removal of a lease actually results in it being removed (according to the remove method) and no further action is taken on the lease for a period up to and including its expiration time plus one half.

Matrix ID 11.

  1. Create a special lease (duration of 30000 milliseconds) that will count the number of times it has been renewed.

  2. Create a lease renewal set with a lease of 50000 milliseconds.

  3. Add the lease to the set with membership duration of forever.

  4. Remove the lease from the set.

  5. Sleep for 35000 milliseconds to allow the set to expire.

  6. Assert that there have been no renewals made on the lease.

  7. Assert that a call to remove the lease again returns a null value.

  8. Sleep for 25000 milliseconds to allow the managed lease to expire.

  9. Assert that attempts to renew the lease result in an UnknownLeaseException and that no other renewal attempts have been made.


A1, M1

LRS section 9.3 pg. 108

LeaseExpirationTest

Assert that that expiration of a lease actually results in it being removed (according to the remove method) and no further action is taken on the lease for a period up to and including its expiration time. The only way that a lease can expire while being managed by the LRS is for the grantor of the lease to throw an Exception.

Matrix ID 12, 14

  1. Create a special lease (duration of 30000 milliseconds) that will count the number of times it has been renewed and throw a definite exception every time it’s renew method is called.

  2. Create a lease renewal set with a lease of forever.

  3. Add the lease to the set with membership duration of forever.

  4. Sleep for 35000 milliseconds to allow the managed lease to expire.

  5. Assert that there have been no renewals made on the lease.

  6. Assert that a call to remove the lease returns a null value .

  7. Create a special lease (duration of 30000 milliseconds) that will throw an indefinite exception every time it’s renew method is called.

  8. Create a lease renewal set with a lease of forever.

  9. Add the lease to the set with membership duration of forever.

  10. Sleep for 35000 milliseconds to allow the managed lease to expire.

  11. Assert that there have been no renewals made on the lease.

  12. Assert that a call to remove the lease returns a null value.


A1, M1

LRS section 9.3 pg. 108

LeaseDurationTest

Assert that for a range of lease duration values given to the createLeaseRenewalSet method, the LRS will only grant times less than or equal to the amount requested.

Matrix ID 16.

  1. Create lease renewal sets with the following lease duration values: 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000 milliseconds.

  2. Assert that the duration times for the leases returned are less than or equal to the amount requested or a LeaseDeniedException is thrown.

  3. Create a lease renewal set with a duration time of Lease.ANY.

  4. Assert that the expiration time of the lease returned is in the future.

  5. Create a lease renewal set with a duration time of Lease.FOREVER.

  6. Assert that the expiration time of the lease returned is in the future.


A1, M1

LRS section 9.3 pg.

ValidLeaseDurationTest

Assert that a lease duration time of 0 or less will cause the createLeaseRenewalSet method to throw an IllegalArgumentException. Also assert that a positive number, Lease.FOREVER, and Lease.ANY do not generate IllegalArgumentExceptions.

Matrix ID 17

  1. Create lease renewal sets with the following lease duration values: 0, -99 milliseconds.

  2. Assert that in each case an IllegalArgumentException is thrown.

  3. Create lease renewal sets with the following lease duration values: Lease.FOREVER, Lease.ANY.

  4. Assert that IllegalArgumentException is not thrown.

  5. Create a lease renewal set with a value of 1024 milliseconds.

  6. Assert that IllegalArgumentException is not thrown.

A1, M1

LRS section 9.3 pg. 109

SetEqualsTest

Assert that two lease renewal set proxies are equal only if they are proxies for the same set created by the same LeaseRenewalService.

Matrix ID 18.

  1. Obtain two LRS services proxies (service #1 and service #2)

  2. Using service #1 create one lease renewal set (set #1).

  3. Using service #2 create one lease renewal set (set #2).

  4. Using service #1 create one lease renewal set (set #3).

  5. Assert that set #1.equals(set #2) returns a value of false.

  6. Assert that set #1.equals(set #3) returns a value of true.

  7. Create a MarshalledObject from set #1.

  8. Unmarshall the MarshalledObject into set #4.

  9. Assert that set #1 == set #4 returns a value of false.

  10. Assert that set #1.equals(set #4) returns a value of true.


A1, M1

LRS section 9.3 pg. 109

IlegalLeaseTest

Assert that attempts to add a set’s lease to itself or a lease that is currently a member of another set throws an IllegalArgumentException.

Matrix ID #21, 22

  1. Create a lease renewal set #1 with a lease of forever.

  2. Use the getLease method to obtain a reference to the set’s lease.

  3. Assert that an attempt to pass the lease to the set #1’s addLease method generates an IllegalArgumentException.

  4. Assert that an attempt to pass the lease to the set #2’s addLease method generates an IllegalArgumentException.

  5. Create a lease renewal set #2 with a lease of forever.

  6. Obtain or create a valid lease with duration of forever.

  7. Add the lease to set #1.

  8. Assert that an attempt to pass the lease to set #2’s addLease method generates an IllegalArgumentException.

A1, M1

LRS section 9.3 pg. 110

MembershipDurationTest

Assert that the membership duration argument to the addLease method is interpreted correctly.

Matrix ID 23, 24

  1. Create a lease renewal set with a lease of forever.

  2. Obtain or create a lease with duration of forever.

  3. Assert that when the lease is added to the set with a membership duration of 0 an IllegalArgumentException is thrown.

  4. Assert that an attempt to remove the lease from the set returns a null value.

  5. Assert that when the lease is added to the set with a membership duration of 1 millisecond, no IllegalArgumentException is thrown.

  6. Assert that when the lease is added to the set with a membership duration of Long.MAX_VALUE, no IllegalArgumentException is thrown.

  7. Assert that an attempt to remove the lease from the set returns a reference to the lease itself.

  8. Assert that when the lease is added to the set with a membership duration of 30000 milliseconds., no IllegalArgumentException is thrown.

A1, M1

LRS section 9.3 pg. 111

ReAddLeaseTest

Assert that when a lease is added to a set in which it already resides that the membership duration is updated appropriately.

Matrix ID 25

  1. Create a lease renewal set with a lease of forever.

  2. Obtain or create a lease with duration of forever.

  3. Add lease to the set with membership duration value of 20000 milliseconds.

  4. Sleep for 10000 milliseconds.

  5. Add the lease to the set again with a membership duration of 30000 milliseconds.

  6. Sleep 25000 milliseconds.

  7. Assert that an attempt to remove the lease from the set results in a non-null return value.

  8. Sleep 10000 milliseconds.

  9. Assert that an attempt to remove the lease from the set results in a null value being returned.

  10. Add lease to the set with membership duration value of 60000 milliseconds.

  11. Sleep 10000 milliseconds.

  12. Add lease to the set again with membership duration of 20000 milliseconds.

  13. Sleep 25000 milliseconds.

  14. Assert that an attempt to remove the lease from the set results in a null value being returned.

A1, M1

LRS section 9.3 pg. 111

RemoveCancelTest

Assert that removal of a lease from a set will not cancel the lease.

Matrix ID 26

  1. Create a lease renewal set with a lease of forever.

  2. Create a special lease that counts the number of times cancel has been called.

  3. Add lease to the set with membership duration of forever.

  4. Remove lease from the set.

  5. Assert that the cancel method has not been called.

A1, M1

LRS section 9.3 pg. 111

RenewalTimeTest

Assert that the expiration time of a returned lease reflects either the original time or the time set as a result of the last successful renewal.

Matrix ID 27.

  1. Create a lease renewal set with a lease of forever.

  2. Create a lease with a duration value of 60000 milliseconds.

  3. Add lease to the set with membership duration of forever.

  4. Sleep for 20000 milliseconds.

  5. Assert that the lease obtained from the remove method still has the original expiration time.

  6. Create a lease with a duration value of 60000 milliseconds.

  7. Add the lease to the set with membership duration of 90000 milliseconds.

  8. Sleep 75000 milliseconds.

  9. Assert that the lease obtained from the remove method has an expiration time equal to approximately the original expiration time + 30000 millisecond.



LeaseNotInSetTest

Assert that the remove method returns null when the lease is not in the set.

Matrix ID 28.

  1. Create a lease renewal set with a lease of forever.

  2. Create a lease with a duration value of forever.

  3. Assert that the set’s remove method returns a null value when an attempt is made to remove the lease.

A1, M1

LRS section 9.3 pg. 111

GetLeaseTest

Assert that the getLease method returns the lease of the set itself.

Matrix ID 29

  1. Create a lease renewal set with a lease of forever.

  2. Save a reference to the lease as lease #1.

  3. Using the set’s getLease method save reference to the returned lease as lease #2.

  4. Assert lease #1 equals (lease #2).

A1, M1

LRS section 9.3 pg. 111

EventRegistrationTest

Assert the following:

  1. An event registration and the set from which it is generated share the same lease.

  2. An event registration is valid with respect to all other active registrations generated by the same LRS. (weak test because only 40 cases are tested. It would be impractical to test all cases exhaustively.)

  3. Assert that when a registration is replaced it is replaced with a new one that has the same event ID.



Matrix ID 37, 38, 39, 40, 48, 50

  1. Create 20 lease renewal sets #1 - #20 with a lease of forever.

  2. Create 20 RemoteEventListener objects #1 - #20.

  3. Save a reference to the lease of renewal set #1as lease #1.

  4. Register RemoteEventListener #1 with renewal set #1 to receive ExpirationWarningEvents.

  5. Save a reference to the event registration object returned from a call to the setExpirationWarningListener method.

  6. Using the EventRegistration object’s getLease() method save a reference to the registration’s lease as lease #2.

  7. Assert lease #1 equals (lease #2).

  8. Register RemoteEventListener #1 with renewal set #1 to receive RenewalFailureEvents Events.

  9. Save a reference to the event registration object returned from a call to the setRenewalFailureListener method.

  10. Using the EventRegistration’s object’s getLease() method save a reference to the registration’s lease as lease #3.

  11. Assert lease #1 equals (lease #3).

  12. Register each listener with its corresponding set for both ExpirationWarningEvents and RenewalFailureEvents and save references to each registrations warnReg #1-#20 and failReg #1 - #20.

  13. Assert that the event ID of each registration is unique with respect to each of the others.

  14. Create a RemoteEventListener newListener.

  15. Install newListener into set #1 by using the set’s setExpirationWarningListener method.

  16. Capture the registration as newWarnReg.

  17. Assert that warnReg #1 getLease() equals newWarnReg getLease() returns a value of false.

  18. Assert warnReg #1 getID() == newWarnReg getID().

  19. Install newListener into set #1 by using its setRenewalFailureListener method.

  20. Capture the registration as newFailReg.

  21. Assert that failReg #1 getLease() equals newFailReg getLease() returns a value of false.

  22. Assert failReg #1 getID() == newFailReg getID().

A1, M1

LRS section 9.3 pg. 112-113

EventSequenceWarnTest

Assert that events of the WarningExpirationEvent type sent to a newly registered listener are in the same sequence as those sent to the previously registered listener.

(weak test : because partial failure may cause the test to fail when it really should succeed. This is because retransmission of events is valid and in some cases it is impossible to tell if two events with the same sequence number are in fact the same event or different).

Matrix ID 41


  1. Create two RemoteEventListeners, listener #1 and listener #2. The notify methods will automatically renew the lease of the set for 30000 milliseconds and save each event received.

  2. Create a lease renewal set with a lease of 30000 milliseconds.

  3. Register listener #1 to receive ExpirationWarningEvents with a minWarning of 10000 milliseconds.

  4. After listener #1 has received three events register listener #2 in its place.

  5. After listener #2 has received three events then call the set’s clearExpirationWarningListener method.

  6. Assert that the sequence numbers for the events received by listener #1 are all in the proper sequence with no gaps.

  7. Assert that the sequence numbers of the events received by listener #2 have no gaps and do not overlap with those of listener #1.

A1, M1


LRS section 9.3 pg. 113

EventSequenceFailTest

Assert that events of the RenewalFailureEvent type sent to a newly registered listener are in the same sequence as those sent to the previously registered listener.

(Note: This test is stronger than the EventSequenceWarnTest because the RenewalFailureEvent carries a reference to the lease whose renewal failed and thus imparts to the event an identity that can be used to distinguish between two different events that might have the same sequence number).

Matrix ID 51


  1. Create two RemoteEventListeners, listener #1 and listener #2. The notify methods will save each event received.

  2. Create a lease renewal set with a lease of forever.

  3. Create 6 leases (lease #1 – lease #6) that will throw a definite exception when their renew methods are called. Use a duration value of 30000 * N milliseconds for each.

  4. Add each lease to the renewal set with membership duration value of forever.

  5. Register listener #1 to receive RenewalFailureEvents.

  6. After listener #1 has received three events register listener #2 in its place.

  7. After listener #2 has received three events then call the set’s clearRenewalFailureListener.

  8. Assert that the sequence numbers for the events received by listener #1 are all in the proper sequence with no gaps.

  9. Assert that the sequence numbers of the events received by listener #2 have no gaps and do not overlap with those of listener #1 where the leases of any two overlapping events are the different.

A1, M1

LRS section 9.3 pg. 113

ClearWarningListenerTest

Assert that the clearExpirationWarningListener method operates as expected.

Assert that this method may be called multiple times with no ill effect.

Matrix ID 42, 43

  1. Create a RemoteEventListener whose notify method will log the number of times it has been called and will automatically renew the lease of the set for 30000 milliseconds.

  2. Create a lease renewal set with a lease of 30000 milliseconds.

  3. Register the listener to receive ExpirationWarningEvents with a minWarning of 10000 milliseconds.

  4. Sleep for 35000 milliseconds.

  5. Call the set’s clearExpirationWarningListener method.

  6. Assert that only one call to notify has been made.

  7. Sleep for 60000 milliseconds.

  8. Assert that only one call to notify has been made.

  9. Assert that the set’s lease has expired.

  10. Assert that the set’s clearExpirationWarningListener method can be called 10 more times without generating any definite exceptions.

A1, M1

LRS section 9.3 pg. 112

ClearFailureListenerTest

Assert that the clearRenewalFailureListener method operates as expected.

Assert that this method may be called multiple times with no ill effect.

Matrix ID 52, 53.


  1. Create a RemoteEventListener whose notify method will log the number of times it has been called and will automatically renew the lease of the set for 30000 milliseconds.

  2. Create a lease renewal set with a lease of forever.

  3. Register the listener to receive RenewalFailureEvents .

  4. Create 6 leases (lease #1 – lease #6) that will throw definite exceptions each time their renew methods are called. Create leases #1 - #3 with a lease duration value of 30000 milliseconds and the remaining 3 with a lease duration value of 60000 milliseconds.

  5. Sleep for 35000 milliseconds.

  6. Call the set’s clearRenewalFailureListener method.

  7. Assert that only three calls to notify has been made.

  8. Sleep for 60000 milliseconds.

  9. Assert that only three calls to notify has been made.

  10. Assert that the leases #4 - #6 can successfully be removed from the set.

  11. Assert that the set’s clearRenewalFailureListener method can be called 10 more times without generating any definite exceptions

A1, M1

LRS section 9.3 pg. 113

EventLeaseTest


  1. Assert that when a RemoteEventListener’s notify method is called that the event contains the expected lease. This test covers both ExpirationWarningEvents and RenewalFailureEvents.

  2. Assert that the expiration time will reflect the expiration of the lease when the event occurred.

  3. In the case of the lease encapsulated in an ExpirationWarningEvent, assert that the expiration time is correct.

  4. Assert that the Throwable object encapsulated by the RenewalFailureEvent is of the correct type.

  5. Assert that the lease that caused the renewal failure event is removed from the renewal set.


Matrix ID 54, 55, 57, 58, 59, 62

  1. Create two RemoteEventListeners, listener #1 to receive ExpirationWarningEvents and listener #2 to receive RenewalFailureEvents

  2. Create a special lease #1 (duration of 30000 milliseconds) that will throw a definite exception when any attempt is made to renew it.

  3. Create a lease renewal set with a lease of 60000 milliseconds and save a reference to the lease as lease #2.

  4. Register listener #1 using the set’s setExpirationWarningListener method with a minWarning of 10000 milliseconds.

  5. Register listener #2 using the set’s setRenewalFailureListener.

  6. In the notify method of listener #1 assert that the lease returned by the event’s getLease() method is equal to lease #1 and the expiration times are also equal.

  7. In the notify method of listener #1 assert that the lease returned in the event object is no longer in the lease renewal set (use the remove method).

  8. In the notify method of listener #2 assert that the lease returned by the event’s getLease() method is equal to lease #2 .

  9. In the notify method of listener #2 assert that the Throwable object returned by getThrowable method of the event object is the correct type of Exception based upon the definite exception thrown by the lease.


A1, M3

LRS section 9.3 pg. 113

LeaseRenewalTest

Assert that if the renewal service was able to renew the lease before the event occurred, the lease’s expiration will reflect the result of the last successful renewal call.


Matrix ID 61

  1. Create a listener to receive RenewalFailureEvents.

  2. Create a lease renewal set with a lease of forever.

  3. Create a special lease with a duration value of 30000 milliseconds that will throw a definite exception after allowing one successful call to renew.

  4. Save a reference to the lease as lease #1.

  5. Register the listener to receive RenewalFailureEvents.

  6. Add the lease to the set with duration of forever.

  7. Assert in notify method of the listener that the lease encapsulated in the event object has an expiration time later than that of lease #1.

A1, M4


LRS section 9.3 pg. 113


Note: This test is categorized as M4 because it is not certain that every implementation will allow for 3 failures before a renewal is granted.

IndefiniteRenewalTest

Assert that if the renewal service was unable to call renew before the lease expired, then the Throwable returned in the event object is null.


Matrix ID 62

  1. Create a listener to receive RenewalFailureEvents.

  2. Create a lease renewal set with a lease of forever.

  3. Create a test lease with a duration of 10000 milliseconds.

  4. Sleep for 20000 milliseconds to allow the lease to expire.

  5. Register the listener to receive RenewalFailureEvents.

  6. Add the lease to the set with duration of forever.

  7. Assert in notify method of the listener that the value returned by the getThrowable method of the event is null.

A1, M4

LRS section 9.3 pg. 114


This test is categorized M4 because it is not certain from the specification that the LRS must send a RenewalFailureEvent in the case where an expired lease is added to the renewal set, althrough Norm does this.

EventSequenceTest

Assert that events arrive in strictly increasing order. (This is a weak test because it is possible to fail if events are lost on the network and the test is not and can not be exhaustive.)


Matrix ID 63

  1. Create 10 lease renewal sets each with a lease of 40000 milliseconds.

  2. Create a listener to receive ExpirationWarningEvents.

  3. For each set register the listener to receive events with a minWarning of 10000 milliseconds.

  4. In the notify method of the listener collect each sequence number as it comes in.

  5. Sort the sequence numbers.

  6. Assert that there are 10 sequence numbers and that they are strictly increasing.

  7. Create a listener to receive RenewalFailureEvents.

  8. Create a lease renewal set with a lease of forever.

  9. Register the listener with the set.

  10. Create 10 leases with duration values of 30000 milliseconds that will throw definite exceptions when attempts are made to renew them.

  11. Add each lease to the set.

  12. In the notify method of the listener collect each sequence number as it comes in.

  13. Sort the sequence numbers.

  14. Assert that there are 10 sequence numbers and that they are strictly increasing.

A1, M1

LRS section 9.3 pg. 114

MaxMembershipTest

Assert that if a lease is added to a set with a membership duration of Long.MAX_VALUE then its membership expiration is Long.MAX_VALUE.


Matrix ID 64

  1. Create a lease renewal set with a lease of forever.

  2. Create a test lease with duration value of 30000 milliseconds.

  3. Add the test lease to the set with a membership duration of Long.MAX_LONG.

  4. Sleep until the test lease expires and is renewed by the LRS.

  5. Remove the test lease from the renewal set.

  6. Assert that the expiration time on the lease is Long.MAX_VALUE.

A1, M1

LRS section 9.3 pg. 113

DurationExpirationTest

Assert that if the membership duration of a managed lease is less than its expiration time then the lease will not be renewed but it will remain in the set.


Matrix ID 65

  1. Create a lease renewal set with a lease of forever.

  2. Create a test lease with duration of 60000 milliseconds.

  3. Add the test lease to the set with a membership duration value of 30000 milliseconds.

  4. Sleep 25000 milliseconds.

  5. Assert that the array returned from the getLeases method is of size one and contains the test lease.

  6. Assert that the expiration time of the test lease has not changed.

  7. Sleep 10000 milliseconds.

  8. Assert that the array returned from the getLeases method is of size 0.

A1, M1

LRS section 9.3.1 pg. 113

GetLeasesTest

Assert that the getLeases method returns all the client leases in the set at the time of the call as an array of type Lease.


Matrix ID 66

  1. Create a lease renewal set with a lease of forever.

  2. Create a test lease #1 with duration of 30000.

  3. Create a test lease #2 with duration of 60000.

  4. Create a test lease #3 with duration of 90000.

  5. Add all three leases to the renewal set each with a membership duration of 10000 milliseconds.

  6. Obtain an array #1 of leases using the getLeases method.

  7. Sleep 35000 milliseconds.

  8. Obtain an array #2 of leases using the getLeases method.

  9. Sleep 35000 milliseconds.

  10. Obtain an array #3 of leases using the getLeases method.

  11. Sleep 35000 milliseconds.

  12. Obtain an array #4 of leases using the getLeases method.

  13. Assert that array #1 has exactly 3 leases no two of which are the same.

  14. Assert that array #2 has exactly 2 different test leases that are equal to test lease #2 and test lease #3.

  15. Assert that array #3 has exactly 1 test lease that is equal to test lease #3.

  16. Assert that array #4 is empty.

A1, M1

LRS section 9.3.1 pg. 113

LeaseUnmarshalExceptionTest

Assert that if one or more of the leases in the array can not be de-serialized a LeaseUnmarshalException is thrown and the getMarshalledLeases, getStillMarshalledLeases, and getExceptions methods work as advertised.


Matrix ID 67, 68, 70

  1. Create a lease renewal set with a lease of forever.

  2. Create two special test leases (called specialLease01 and specialLease02) with duration of forever that has the property of throwing an exception when an attempt is made to de-serialize it.

  3. Create three test leases (called testLease01, testLease02 and testLease03) with duration of forever.

  4. Add all the leases to the set with a membership duration of forever.

  5. Obtain an array of leases by calling the getLeases method.

  6. Assert that a LeaseUnmarshalException is thrown.

  7. Assert that the array returned from the getUnmarshalledLeases method of the exception has a size of 3 and contains exactly testLease01, testLease02, and testLease03.

  8. Assert that the array returned from the getStillMarshalledLeases method of the exception has a size of 2 and contains exactly the marshalled representation of specialLease01 and speciallease02.

  9. Assert that the array returned from the getExceptions method of the exception has a size of 2 and contains exactly two Throwable objects that where the original cause of the de-serialization errors and the order of their appearance in the array parallels the order of the array returned from getStillMarshalledLeases.

A1, M1

LRS section 9.3.1 pg. 113

LeaseUnmarshalNoneTest

Assert that if none of the leases in the array can be de-serialized a LeaseUnmarshalException is thrown and the getMarshalledLeases method returns a 0 length array.


Matrix ID 69

  1. Create a lease renewal set with a lease of forever.

  2. Create two special test leases (called specialLease01 and specialLease02) with duration of forever that has the property of throwing an exception when an attempt is made to de-serialize it.

  3. Add all the leases to the set with a membership duration of forever.

  4. Obtain an array of leases by calling the getLeases method.

  5. Assert that a LeaseUnmarshalException is thrown.

  6. Assert that the array returned from the getUnmarshalledLeases method of the exception has a size of 0.

A1, M1

LRS 9.3.1 pg. 113

AssocExpWarnSetTest

Each event generated by the lease renewal service has as its source the renewal set that the event is associated with. In the case of an expiration warning event this is the set which is about to expire.


Matrix ID 71

  1. Create two lease renewal sets (set01 and set02) with leases for forever.

  2. Create a lease renewal set (set03) with a lease of 30000 milliseconds.

  3. Create a listener to receive ExpirationWarningEvents..

  4. Register the listener with the set to receive events with a minWarning of 10000 milliseconds.

  5. Sleep for 30000 milliseconds.

  6. In the notify method of the ExpirationWarningEvent listener assert that the source of the event is equal to the set set03.

A1, M1

LRS 9.3.1 pg. 113

AssocRenewalFailSetTest

Each event generated by the lease renewal service has as its source the renewal set that the event is associated with. In the case of a renewal failure event this is the set the client lease was in when the event occurred.


Matrix ID 71

  1. Create a lease renewal set with a lease of forever,

  2. Create a listener to receive RenewalFailureEvents..

  3. Register the listener with the to receive events.

  4. Create a special test lease called specialLease01 with duration of 30000 that has the property of throwing an exception when an attempt is made to renew it.

  5. Create a test lease called testLease01 with duration of 30000 milliseconds.

  6. Add testLease01 to the set with membership duration values of forever.

  7. Add specialLease01 to the set with membership duration value of forever.

  8. Sleep for 30000 milliseconds.

  9. In the notify method of the RenewalFailureEvent listener assert that the source of the event is equal to the set.

A1, M1

LRS 9.3.1 pg. 113

EventIDWarnTest

Because a given set will only have one expiration warning event registration at a given time all expiration warning events will have the same event ID, LeaseRenewalSet.EXPIRATION_WARNING_EVENT_ID.


Matrix ID 72

  1. Create three lease renewal sets with a lease of 40000 milliseconds (called set01, set02 and set03).

  2. Create a listener to receive ExpirationWarningEvents..

  3. Register the listener with the set01, set02, and set03 to receive events with a minWarning of 10000 milliseconds.

  4. Sleep for 80000 milliseconds.

  5. In the notify method of the ExpirationWarningEvent listener assert that the event id of all events received is LeaseRenwalSet.EXPIRATION_WARNING_EVENT_ID.

  6. As an extra measure assert that the number of events received by the listener is 3.

A1, M1

LRS 9.3.1 pg. 113

EventIDFailTest

Because a given set will only have one renewal failure event registration at a given time all renewal failure events will have the same event ID, LeaseRenewalSet.RENEWAL_FAILURE_EVENT_ID.


Matrix ID 72

  1. Create a lease renewal sets with a lease of forever.

  2. Create a listener to receive RenewalFailureEvents..

  3. Register the listener with the set to receive events.

  4. Create 3 special test lease called specialLease01, specialLease02 and specialLease03 with duration of 40000 that has the property of throwing an exception when an attempt is made to renew it.

  5. Add specialLease01, specialLease02, and specialLease03 to set with membership duration values of forever.

  6. Sleep for 80000 milliseconds.

  7. In the notify method of the RenewalFailureEvent listener assert that the event is of all events received is LeaseRenwalSet.RENEWAL_FAILURE_EVENT_ID.

  8. As an extra measure assert that the number of events received by the listener is 3.

A1, M1

LRS 9.3.1 pg. 113

ClearEventRegistrationTest

If a RemoteListener registered for a renewal failure or an expiration warning event throws an UnknownEventException, this will only clear the specific event registration, it will not cancel the lease on the renewal set, or affect any other event registration on the set.


Matrix ID 73



  1. Create two lease renewal sets with a lease of 100000 milliseconds (called set01 and set02).

  2. Create a special listener (specialListener01) to receive ExpirationWarningEvents that will throw an UnknownEventException from its notify method as well as count the number of times the notify method has been called.

  3. Create a listener (normalListener01) to receive ExpirationWarningEvents that counts the number of times its notify method has been called.

  4. Register the specialListener01 with the set01 to receive events with a minWarning of 40000 milliseconds.

  5. Register the normalListener01 with the set02 to receive events with a minWarning of 25000 milliseconds.

  6. Create a special listener (specialListener02) to receive RenewalFailureEvents that will throw an UnknownEventException from its notify method as well as count the number of times the notify method has been called.

  7. Create a listener (normalListener02) to receive RenewalFailureEvents that counts the number of times its notify method has been called.

  8. Register the specialListener02 with the set02.

  9. Register the normalListener02 with the set01.

  1. Create three special leases (specialLease01, specialLease02 and specialLease03 with duration values of 30000, 50000 and 600000 milliseconds respectively) that will throw a definite exception when any attempt is made to renew it.

  1. Add specialLease01 to set01 and specialLease02 to set02 with membership duration values of forever.

  2. Sleep for 80000 milliseconds.

  3. Renew each lease for 60000 milliseconds.

  4. Assert that renewals on both lease sets do not result in an UnknownLeaseException.

  5. Assert that calls to remove on set01 and set02 do not result in a NoSuchObjectException.

  6. Add specialLease03 to set02.

  7. Sleep for 60000 milliseconds.

  8. Assert that exactly one call to notify was made to specialListener01 and specialListener02.

  9. Assert that exactly two calls were made to normalListener01 and normalListener02.

A1, M1

LRS 9.3.1 pg. 113

NewListenerEventTest

If an event listener is replaced, and one or more event delivery attempts on the original listener failed or were indeterminate, implementations may chose to send some or all of these events to the new listener.


Matrix ID 74


  1. Create a lease renewal set with a lease of forever.

  2. Create a special listener (specialListener01) to receive renewal failure events whose notify method throws an exception.

  3. Create a normal listener (normalListener01) to receive renewal failure events.

  4. Register specialListener01 with the lease renewal set.

  5. Create 3 special leases (duration value 40000 milliseconds) whose renew method will throw a definite exception each time it is called.

  6. Add the leases to the set with membership duration of forever.

  7. Sleep 60000 milliseconds.

  8. Register normalListener01 to receive renewal failure events.

  9. Sleep 60000 milliseconds.

  10. Assert that at lease one event was received by normalListener01.

A1, M4

LRS 9.3.1 pg. 114

NormalEventReturnTest

Both the getLease and getThrowable methods are declared to throw IOException and ClassNotFoundException, this delcaration allows implementations to delay unmarshalling this state until it is actually needed. Once either method of a given RenewalFailureEvent object returns normally, future calls on that method must return the same object and may not throw an exception.


Matrix ID 75

  1. Create a lease renewal set with a lease of forever.

  2. Create a listener to receive renewal failure events.

  3. Register the listener with the set.

  4. Create a lease whose renew method will throw a definite exception each time it is called.

  5. Add the lease to the set with membership duration of 30000 milliseconds.

  6. Sleep 90000 milliseconds.

  7. In the notify method of the listener assert that multiple calls to getLease and getThrowable always return the same object and they throw no exceptions.

A1, M1

LRS 9.3.1 pg. 116

RenewalFailureEventTest

RenewalFailureEventIndefiniteTest

The RenewalFailureEvent is a subclass of RemoteEvent, adding two additional items of abstract state – the client lease which could not be renewed before expiration and the Throwable object that was thrown by the first failed renewal attempt in the last series of consecutive failures.


Matrix ID 76

  1. Create a lease renewal set with a lease of forever.

  2. Create a listener to receive renewal failure events. This listener saves the last event received by its notify method in an accessible instance variable.

  3. Register the listener with the set.

  4. Create a special lease that will throw a ServerErrorException when its renew method is called for the first time and a RemoteException every time after that. Create it with a duration value of 60000 milliseconds.

  5. Add lease to the set with membership duration of forever.

  6. Sleep 70000 milliseconds.

  7. Assert that the getThrowable method of the event returns a ServerErrorException.

  8. Assert the the getLease method returns the lease being used for the test.

A1, M1

LRS 9.3.1 pg. 115

RenewAtIntervalTest

Assert that the renewFor/3 method causes leases to be renewed with a value that is equal to the lease duration specified in the call (3RD argument).


Not in Matrix

  1. Create a lease renewal set with a lease of forever.

  2. Create 3 leases (lease01, lease02, lease03) with renewal times of 30000, 60000, and 90000 milliseconds respectively.

  3. Add them to the renewal set using the renewFor/4 method with a lease duration of 75000 milliseconds.

  4. Wait until lease01 expires.

  5. Remove lease01 from the set.

  6. Assert that lease01 has an expiration time that is greater than the original expiration time of lease01 but not greater than the original expiration time + 75000 milliseconds.

  7. Repeat steps 4 through 6 for lease02 and lease03.


LS2.0 pg 193-194