Examples of TestLease


Examples of com.sun.jini.test.share.TestLease

        "Lease.FOREVER.");

  // create a test lease to be managed
  logger.log(Level.FINE, "Creating the lease to be managed.");
  logger.log(Level.FINE, "Duration == Lease.FOREVER");
  TestLease testLease =
      leaseProvider.createNewLease(leaseOwner, Lease.FOREVER);

  /* assert that using a membership duration of 0
     does NOT generate an IllegalArgumentException */
  try {
View Full Code Here

Examples of com.sun.jini.test.share.TestLease

        "Lease.FOREVER.");

  // create a test lease to be managed
  logger.log(Level.FINE, "Creating the lease to be managed.");
  logger.log(Level.FINE, "Duration == Lease.FOREVER");
  TestLease testLease =
      leaseProvider.createNewLease(leaseOwner, Lease.FOREVER);

  // start managing the lease for the base membership time
  logger.log(Level.FINE, "Adding lease with membership of " +
        membershipDuration + " milliseconds");
View Full Code Here

Examples of com.sun.jini.test.share.TestLease

  set = prepareSet(set);
 
  // get a lease for some time less than the renewal set
  logger.log(Level.FINE, "Creating the lease to be managed.");
  logger.log(Level.FINE, "Duration = " + renewGrant);
  TestLease testLease =
      leaseProvider.createNewLease(owner,
           rstUtil.durToExp(renewGrant));

  // start managing the lease for as long as we can
  logger.log(Level.FINE, "Adding managed lease to lease renewal set.");
View Full Code Here

Examples of com.sun.jini.test.share.TestLease

  lrm.renewFor(prepareLease(set.getRenewalSetLease()), renewSetDur, null);

  // create a test lease to be managed
  logger.log(Level.FINE, "Creating the lease to be managed.");
  logger.log(Level.FINE, "Duration == Lease.FOREVER");
  TestLease testLease =
      leaseProvider.createNewLease(leaseOwner, Lease.FOREVER);

  // remove the lease
  Lease managedLease = set.remove(testLease);
  if (managedLease != null) {
View Full Code Here

Examples of com.sun.jini.test.share.TestLease

  evReg = prepareRegistration(evReg);

  // create a lease that will fail to renew
  logger.log(Level.FINE, "Creating the lease to be managed.");
  logger.log(Level.FINE, "Duration == " + renewGrant);
  TestLease testLease =
      leaseProvider.createNewLease(definiteOwner,
           rstUtil.durToExp(renewGrant));

  // start managing the lease for as long as we can
  logger.log(Level.FINE, "Adding managed lease to lease renewal set.");
  logger.log(Level.FINE, "Membership = Lease.FOREVER.");
  set.renewFor(testLease, Lease.FOREVER);
 
  // wait for the lease to expire
  rstUtil.waitForLeaseExpiration(testLease,
               "for client lease to expire.");

  /* Assert that the notification was received at approximately
     the lease expiration time */
  Long[] arrivalTimes = rrl.getArrivalTimes();

  // must at lease have received one event
  if (arrivalTimes.length == 0) {
      String message = "RenewalFailure event never received.";
      throw new TestException(message);
  }

  // must NOT have received more than one event
  if (arrivalTimes.length > 1) {
      String message = "Too many events received.";
      throw new TestException(message);
  }

  /* TESTING ASSERTION #1
     was the event received around the right time? */
  long leaseExpiration = testLease.getExpiration();
  long maxAllowed = leaseExpiration + latencySlop;

  long actualArrivalTime = arrivalTimes[0].longValue();

  // event must arrive within our assumed constraints
View Full Code Here

Examples of com.sun.jini.test.share.TestLease

  }     

  // create a lease that renews normally
  logger.log(Level.FINE, "Creating the lease to be managed.");
  logger.log(Level.FINE, "Duration == " + renewGrant);
  TestLease testLease =
      leaseProvider.createNewLease(leaseOwner,
           rstUtil.durToExp(renewGrant));

  // add the lease to set01
  set01.renewFor(testLease, renewGrant);
View Full Code Here

Examples of com.sun.jini.test.share.TestLease

  lrm.renewFor(prepareLease(set.getRenewalSetLease()), renewSetDur, null);

  // create a test lease to be managed
  logger.log(Level.FINE, "Creating the lease to be managed.");
  logger.log(Level.FINE, "Duration == " + renewGrant);
  TestLease testLease =
      leaseProvider.createNewLease(leaseOwner,
           rstUtil.durToExp(renewGrant));
  long originalExpTime = testLease.getExpiration();

  // start managing the lease
  logger.log(Level.FINE, "Adding lease with membership of " +
        "Lease.FOREVER");
  long time01 = System.currentTimeMillis();
  set.renewFor(testLease, Lease.FOREVER);

  // Assert that the managed lease has original expiration time
  Lease managedLease = set.remove(testLease);
  long time02 = System.currentTimeMillis();
  long actualExpTime = managedLease.getExpiration();
  long deltaExpTime = actualExpTime - originalExpTime;
  long roundTrip = time02 - time01;
  if (deltaExpTime >= roundTrip) {
      String message = "Expiration time was permaturely altered.";
      throw new TestException(message);
  }

  // just to make certain assert that there are no renew or cancels
  if (leaseOwner.getRenewCalls() > 0) {
      String message = "LRS made an erronous call to renew.";
      throw new TestException(message);
  }
  if (leaseOwner.getCancelCalls() > 0) {
      String message = "LRS made a forbidden call to cancel.";
      throw new TestException(message);
  }

  // create a test lease to be managed
  logger.log(Level.FINE, "Creating the lease to be managed.");
  logger.log(Level.FINE, "Duration == " + renewGrant);
  long leaseCreation = System.currentTimeMillis();
  testLease =
      leaseProvider.createNewLease(leaseOwner,
           rstUtil.durToExp(renewGrant));
  originalExpTime = testLease.getExpiration();

  // start managing the lease
  long membershipDuration = renewGrant + (renewGrant / 2);
  logger.log(Level.FINE, "Adding lease with membership of " +
        membershipDuration + " millseconds.");
View Full Code Here

Examples of com.sun.jini.test.share.TestLease

        "Lease.FOREVER.");

  // create a test lease to be managed
  logger.log(Level.FINE, "Creating the lease to be managed.");
  logger.log(Level.FINE, "Duration == " + renewGrant);
  TestLease testLease =
      leaseProvider.createNewLease(leaseOwner,
           rstUtil.durToExp(renewGrant));
  long originalExpTime = testLease.getExpiration();

  // start managing the lease
  long membershipDur = renewGrant / 2;
  logger.log(Level.FINE, "Adding lease with membership of " +
        membershipDur + " milliseconds.");
View Full Code Here

Examples of com.sun.jini.test.share.TestLease

  // create a 2 leases that will fail on renewal
  long renewGrant = renewSetDur * 5 / 10;
  logger.log(Level.FINE, "Creating failing lease #1 with duration of " +
        renewGrant + " milliseconds.");
  TestLease lease01 =
      leaseProvider.createNewLease(failingOwner,
           rstUtil.durToExp(renewGrant));
 
  logger.log(Level.FINE, "Creating failing lease # 2 with duration of " +
        renewGrant + " milliseconds.");
  TestLease lease02 =
      leaseProvider.createNewLease(failingOwner,
           rstUtil.durToExp(renewGrant));
 
  // add lease01 to set01 and lease02 to set02
  logger.log(Level.FINE, "Adding lease #1 to set #1");
  set01.renewFor(lease01, Long.MAX_VALUE);
  logger.log(Level.FINE, "Adding lease #2 to set #2");
  set02.renewFor(lease02, Long.MAX_VALUE);
 
  /* wait for the expiration warning events to arrive.
     By the time they do, all RenewalFailureEvents should also
     have arrived. */
  rstUtil.waitForRemoteEvents(normalListener01, 1, renewSetDur);
  rstUtil.waitForRemoteEvents(failingListener01, 1, renewSetDur);
 
  // Assert that we had one call each on the failing listeners
  RemoteEvent[] events01 = failingListener01.getEvents();
  RemoteEvent[] events02 = failingListener02.getEvents();

  if (events01.length != 1) {
      String message = "Failing Listener #1 received " +
    events01.length + " events but is required to\n" +
    "receive exactly 1.";
      throw new TestException(message);
  }

  if (events02.length != 1) {
      String message = "Failing Listener #2 received " +
    events02.length + " events but is required to\n" +
    "receive exactly 1.";
      throw new TestException(message);
  }

  // Assert that we had one call each on the normal listeners
  events01 = normalListener01.getEvents();
  events02 = normalListener02.getEvents();

  if (events01.length != 1) {
      String message = "Normal Listener #1 received " +
    events01.length + " events but is required to\n" +
    "receive exactly 1.";
      throw new TestException(message);
  }

  if (events02.length != 1) {
      String message = "Normal Listener #2 received " +
    events02.length + " events but is required to\n" +
    "receive exactly 1.";
      throw new TestException(message);
  }

  // Assert we can renew both set's leases without error
  renewSetDur = renewSetDur * 6 / 10; // use a shorter time

  try {
      logger.log(Level.FINE, "Renewing set #1's lease with duration " +
            "of " + renewSetDur + " milliseconds.");
      prepareLease(set01.getRenewalSetLease()).renew(renewSetDur);
  } catch (UnknownLeaseException ex) {
      String message = "Attempt to renew lease for renewal set\n" +
    "#1 has failed due to " + ex;
      throw new TestException(message, ex);
  }     

  try {
      logger.log(Level.FINE, "Renewing set #2's lease with duration " +
            "of " + renewSetDur + " milliseconds.");
      prepareLease(set02.getRenewalSetLease()).renew(renewSetDur);
  } catch (UnknownLeaseException ex) {
      String message = "Attempt to renew lease for renewal set\n" +
    "#2 has failed due to " + ex;
      throw new TestException(message, ex);
  }     

  /* Assert that calls to remove do not result in a
     NoSuchObjectException. Given the renewal of the leases
     above this assertion is probably somewhat redundant. */

  try {
      Lease managedLease = set01.remove(lease01);
  } catch (NoSuchObjectException ex) {
      String message = "Attempt to call remove on set\n" +
    "#1 has failed due to a NoSuchObjectException";
      throw new TestException(message, ex);
  }     

  try {
      Lease managedLease = set02.remove(lease02);
  } catch (NoSuchObjectException ex) {
      String message = "Attempt to call remove on set\n" +
    "#2 has failed due to a NoSuchObjectException";
      throw new TestException(message, ex);
  }     

  // Restore both sets to original configurations
  renewGrant = renewSetDur * 3 / 10;
  logger.log(Level.FINE, "Creating failing lease #3 with duration of " +
        renewGrant + " milliseconds.");
  TestLease lease03 =
      leaseProvider.createNewLease(failingOwner,
           rstUtil.durToExp(renewGrant));
  logger.log(Level.FINE, "Adding lease #3 to set #1");
  set01.renewFor(lease03, Long.MAX_VALUE);
 
  logger.log(Level.FINE, "Creating failing lease #4 with duration of " +
        renewGrant + " milliseconds.");
  TestLease lease04 =
      leaseProvider.createNewLease(failingOwner,
           rstUtil.durToExp(renewGrant));
  logger.log(Level.FINE, "Adding lease #4 to set #2");
  set02.renewFor(lease04, Long.MAX_VALUE);
 
View Full Code Here

Examples of com.sun.jini.test.share.TestLease

  set = prepareSet(set);
 
  // get a lease for 2 hours (that ought to suffice).
  logger.log(Level.FINE, "Creating the lease to be managed.");
  long duration = 120 * 60 * 1000;
  TestLease testLease =
      leaseProvider.createNewLease(rstUtil.durToExp(duration));

  // start managing the lease for as long as we can
  logger.log(Level.FINE, "Adding managed lease to lease renewal set.");
  set.renewFor(testLease, Lease.FOREVER);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.