Package net.jini.lease

Examples of net.jini.lease.RenewalFailureEvent


    " events but is required to receive exactly 1.";
      throw new TestException(message);
  }

  // the encapsulated Throwable should be null
  RenewalFailureEvent rfe = (RenewalFailureEvent) events[0];
  Throwable except = rfe.getThrowable();
  if (except != null) {
      String message = "The event encapsulated a Throwable of " +
    "type " + except.getClass() + " but should have returned" +
    " a value of null.";
      throw new TestException(message);
View Full Code Here


      String message = "RenewalFailureEvent was never received.";
      throw new TestException(message);
  }

  // capture the expiration time of the renewal failure event
  RenewalFailureEvent failEvent =
      (RenewalFailureEvent) failListener.getEvents()[0];
  long failEventExpiration = failEvent.getLease().getExpiration();

  logger.log(Level.FINE, "Number of failure events = " +
        warnListener.getEvents().length);
  logger.log(Level.FINE, "Number of warning events = " +
        failListener.getEvents().length);


  /* ASSERTION #1 :
     assert that the leases are the ones we expect */
  if (warnLease.equals(prepareLease(warnEvent.getRenewalSetLease())) == false) {
      String message = "Assertion #1 failed.\n" +
    "Expiration warning lease does not match\n" +
    "the lease encapsulated in the ExpirationWarningEvent " +
    "object.";
      throw new TestException(message);
  }

  if (failLease.equals(failEvent.getLease()) == false) {
      String message = "Assertion #1 has failed.\n" +
    "Renewal failure lease does not match the " +
    "lease encapsulated in the RenewalFailureEvent object.";
      throw new TestException(message);
  }

  logger.log(Level.FINE, "Assertion #1 passed.");

  /* ASSERTION #2 :
     the expiration will reflect the expiration of the lease
     when the event occurred. */

  long delta = warnLeaseExpiration - warnEventExpiration;
  if (Math.abs(delta) > roundTrip) {
      logger.log(Level.FINE, "Assertion #2 failed, delta = " + delta
          + "  10*roundTrip = " + roundTrip);
      String message = "Assertion #2 has failed.\n" +
    "Expiration time of lease in warning event does not\n" +
    "reflect the expiration of the lease when the event " +
    "occurred.";
      throw new TestException(message);
  } else {
      logger.log(Level.FINE, "Assertion #2 passed, delta = " + delta
          + "  10*roundTrip = " + roundTrip);
  }

  /*
   * This portion of the assertion is pretty weak. All it says
   * is that the expiration time on the lease is at least
   * within one renewGrant times worth of the original lease.
   * That's pretty broad and may not be particularly useful.
   * The problem is that there is no real way of determining
   * exactly what the lease expiration was at the time the renewal
   * failure event occurred and there is a significant (5 second)
   * time interval between the delivery of the marshalling of the
   * lease object and the delivery of the event.
   */
  if (failEventExpiration > nextFailExpiration) {
      String message = "Assertion #2 has failed.\n" +
    "Expiration time of lease in failure event does not\n" +
    "reflect the expiration of the lease when the event " +
    "occurred.";
      throw new TestException(message);
  }

  logger.log(Level.FINE, "Assertion #2 passed.");

  /* ASSERTION #3 :
     The Throwable Object is the one expected. */        
  Throwable failException = failEvent.getThrowable();
  Throwable targetException = getExpectedException();

  if (! (failException.getClass() == targetException.getClass())) {
      String message = "Assertion #3 has failed.\n" +
    "Throwable encapsulated by the RenewalFailureEvent is" +
View Full Code Here

        the original expiration time.
     2) and greater than the arrival time of the renewal
        failure event
     3) and less than the expiration time that would have been
        granted had the renewal succeeded. */
  RenewalFailureEvent rfe = (RenewalFailureEvent) events[0];
  Lease managedLease = rfe.getLease();
  long currentExpiration = managedLease.getExpiration();
  long arrTime = arrivalTimes[0].longValue();
  boolean assert01 = currentExpiration > initialExpiration;
  boolean assert02 = currentExpiration > arrTime;
  boolean assert03 = currentExpiration < (arrTime + renewGrant);
View Full Code Here

  int evtIndex02 = indexOf(evtArr02, seqNum);
  /* we assume the above two calls will always return a non-negative
     number since this is a private method only used in this class. */

  // capture the two event whose sequence numbers overlap
  RenewalFailureEvent evt01 = (RenewalFailureEvent) evtArr01[evtIndex01];
  RenewalFailureEvent evt02 = (RenewalFailureEvent) evtArr02[evtIndex02];
 
  // they are the same if the leases that failed are the same
  Lease lease01 = evt01.getLease();
  Lease lease02 = evt02.getLease();

  // return the truth of the matter
  return lease01.equals(lease02) == false;
    }
View Full Code Here

    "receive exactly 1.";
      throw new TestException(message);
  }

  // get the lease and throwable objects from the event.
  RenewalFailureEvent rfe = (RenewalFailureEvent) events[0];
  Lease eventLease = rfe.getLease();
  IllegalArgumentException eventException =
      (IllegalArgumentException) rfe.getThrowable();

  /* try to recall 50 times and make certain that nothing changes
     and no exceptions are thrown */
  for(int i = 0; i < 50; ++i) {

      try {
    if (eventLease.equals(rfe.getLease()) == false) {
        String message = "The lease returned by getLeases()" +
      "has changed.";
        throw new TestException(message);
    }
      } catch (Exception ex) {
    String message = "A successive call to getLease() has" +
        " raised an Exception " + ex;
    throw new TestException(message, ex);
      }

      try {
    if (eventException.equals(rfe.getThrowable()) == false) {
        String message = "The Exception returned by" +
      "getThrowable() has changed.";
        throw new TestException(message);
    }
      } catch (Exception ex) {
View Full Code Here

      throw new TestException(message);
  }

  // assert that each event holds the expected ID value
  for (int i = 0; i < events.length; ++i) {
      RenewalFailureEvent rfe = (RenewalFailureEvent) events[i];
      if (rfe.getID() !=
    LeaseRenewalSet.RENEWAL_FAILURE_EVENT_ID) {
      String message = "Event #" + i + " has the wrong event ID.\n" +
    "ID = " + rfe.getID() + " but it should be " +
    LeaseRenewalSet.RENEWAL_FAILURE_EVENT_ID;
      throw new TestException(message);
      }
  }
    }
View Full Code Here

    " events but is required to receive exactly 1.";
      throw new TestException(message);
  }

  // assert it's the set that failed
  RenewalFailureEvent rfe = (RenewalFailureEvent) events[0];
  Lease failedLease = rfe.getLease();
  if (failedLease.equals(lease03) == false) {
      String message = "The source of the event was not the set" +
    " that caused the RenewalFailureEvent.";
      throw new TestException(message);
  }

  // just for grins, make certain that the exception is the right one
  Throwable exception = rfe.getThrowable();
  if (exception.getClass() != UnknownLeaseException.class) {
      String message = "The Throwable returned was the wrong" +
    " type.\n";
      throw new TestException(message);
  }
View Full Code Here

    " events but is required to receive exactly 1.";
      throw new TestException(message);
  }

  // Assert that the Throwable is the one we expect.
  RenewalFailureEvent rfe = (RenewalFailureEvent) events[0];
  Throwable failException = rfe.getThrowable();
  Throwable targetException = getExpectedException();
  if (failException.getClass() != targetException.getClass()) {
      String message = "The getThrowable() method returned an\n" +
    "exception of type " + failException.getClass().getName() +
    " but should have returned an instance\n" +
    "of " + targetException.getClass().getName() + ".";
      throw new TestException(message);
  }

  if ((failException.getMessage().equals
       (targetException.getMessage())) == false) {
      String message = "Assertion #3 has failed.\n" +
    "Throwable encapsulated by the RenewalFailureEvent is" +
    " of type " + failException.getClass() +
    "\nas expected but the instances are different.";
      throw new TestException(message);
  }

  // Assert that getLease() returns the one we expect
  Lease managedLease = rfe.getLease();
  if (managedLease.equals(lease) == false) {
      String message = "The getLease() method did not return\n" +
    "the expected lease.";
      throw new TestException(message);
  }
View Full Code Here

  int evtIndex02 = indexOf(evtArr02, seqNum);
  /* we assume the above two calls will always return a non-negative
     number since this is a private method only used in this class. */

  // capture the two event whose sequence numbers overlap
  RenewalFailureEvent evt01 = (RenewalFailureEvent) evtArr01[evtIndex01];
  RenewalFailureEvent evt02 = (RenewalFailureEvent) evtArr02[evtIndex02];
 
  // they are the same if the leases that failed are the same
  Lease lease01 = evt01.getLease();
  Lease lease02 = evt02.getLease();

  // return the truth of the matter
  return lease01.equals(lease02) == false;
    }
View Full Code Here

    " events but is required to receive exactly 1.";
      throw new TestException(message);
  }

  // assert it's the set that failed
  RenewalFailureEvent rfe = (RenewalFailureEvent) events[0];
  Lease failedLease = rfe.getLease();
  if (failedLease.equals(lease03) == false) {
      String message = "The source of the event was not the set" +
    " that caused the RenewalFailureEvent.";
      throw new TestException(message);
  }

  // just for grins, make certain that the exception is the right one
  Throwable exception = rfe.getThrowable();
  if (exception.getClass() != UnknownLeaseException.class) {
      String message = "The Throwable returned was the wrong" +
    " type.\n";
      throw new TestException(message);
  }
View Full Code Here

TOP

Related Classes of net.jini.lease.RenewalFailureEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.