Package net.jini.core.lease

Examples of net.jini.core.lease.Lease


  /* 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);
  }     
View Full Code Here


  // wait the lease to expire
  rstUtil.waitForLeaseExpiration(testLease,
               "for client lease to expire.");

  // assert that the lease is no longer in the renewal set
  Lease managedLease = set.remove(testLease);
  if (managedLease != null) {
      String message = "The lease that expired due to a definite";
      message += " exception was never removed from the\n";
      message += "renewal set.";
      return message;
View Full Code Here

  /* we need to sleep a bit longer because the LRS implementation
     might still be busy re-trying the renew operation */
  rstUtil.sleepAndTell(renewGrant/2, "to allow for lease removal.");

  // assert that the lease is no longer in the renewal set
  Lease managedLease = set.remove(testLease);
  if (managedLease != null) {
      String message = "The lease that expired due to a indefinite";
      message += " exception was never removed from the\n";
      message += "renewal set.";
      return message;
View Full Code Here

      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);
  }
View Full Code Here

  logger.log(Level.FINE, "Adding lease with membership of " +
        "Lease.FOREVER");
  set.renewFor(testLease, Lease.FOREVER);

  // remove the lease
  Lease managedLease = set.remove(testLease);
  if (managedLease.equals(testLease) == false) {
      String message = "Lease removed does not match the lease\n" +
           "originally added to the set.";
      throw new TestException(message);
  }
View Full Code Here

  set.renewFor(testLease2, Lease.FOREVER);
  set.renewFor(testLease3, Lease.FOREVER);
 
  // allow the lease of the renewal set to expire
  logger.log(Level.FINE, "Getting the renewal set lease.");
  Lease setLease = prepareLease(set.getRenewalSetLease());
  boolean success = expireRenewalSetLease(setLease);
  if (success == false) {
      String message = "Lease did not expire as expected.\n";
      throw new TestException(message);
  }

  // assert that any attempt to use the set results in an exception
  try {
      Lease managedLease = set.remove(testLease1);
      String message = "Performed successful remove operation on\n";
      message += " renewal set after its lease had expired.";
      throw new TestException(message);
  } catch (NoSuchObjectException ex) {
      // we passed so just keep on going ...
  }

  try {
      Lease managedLease = leaseProvider.createNewLease(owner,
                    renewGrant);
      set.renewFor(managedLease, Lease.FOREVER);
      managedLease.cancel();
      String message = "Performed successful add operation on\n";
      message += " renewal set after its lease had expired.";
      throw new TestException(message);
  } catch (NoSuchObjectException ex) {
      // we passed so just keep on going ...
View Full Code Here

    "\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

  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) {
      String message = "Removal of non-managed lease does NOT\n" +
           "return null as required.";
      throw new TestException(message);
  }
View Full Code Here

  logger.log(Level.FINE, "Created Set 02 with lease duration of " +
        "Lease.FOREVER.");

  /* assert that attempting to add the set's lease to itself
     generates an IllegalArgumentException */
  Lease setLease = prepareLease(set01.getRenewalSetLease());
  logger.log(Level.FINE, "Lease is " + setLease);
  try {
      set01.renewFor(setLease, renewGrant);
      String message = "An attempt to add a renewal set's lease\n";
      message += " to itself has succeeded.";
      throw new TestException(message);
  } catch (IllegalArgumentException ex) {
      // success, keep on trucking ...
  }     

  /* assert that attempting to add the set01's lease to set02
     generates an IllegalArgumentException */
  try {
      set02.renewFor(setLease, renewGrant);
      String message = "An attempt to add a renewal set's lease\n";
      message += " to another set has succeeded.";
      throw new TestException(message);
  } catch (IllegalArgumentException ex) {
      // success, keep on trucking ...
  }     

  // 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);

  /* assert that attempting to add the test lease to set02
     succeeds. */
  try {
      set02.renewFor(testLease, renewGrant);
      // success
  } catch (IllegalArgumentException ex) {
      String message = "An attempt to add a client lease\n";
      message += " to two different sets has failed.";
      throw new TestException(message, ex);
  }     

  /*
   * Assert that adding set01's lease to set02 succeeds if set01's
   * lease has been cancelled.
   */
  setLease.cancel();
  try {
      set02.renewFor(setLease, renewGrant);
  } catch (IllegalArgumentException ex) {
    throw new TestException("Failed to add an expired set "
          + "lease to another set",
View Full Code Here

  source =
      (LeaseRenewalSet)
      QAConfig.getConfig().prepare("test.normRenewalSetPreparer",
                source);
  // lease isn't prepared, since only equals is called
  Lease lease = source.getRenewalSetLease();

  // test to ensure that all fields match
  boolean isSameSet = source.equals(lrSet);
  boolean isSameLease = lease.equals(lrSet.getRenewalSetLease());
  boolean isExpectedID = evReg.getID() == evID;

  // create a failure message (if necessary)
  failureReason = new String();
  if (! isSameSet) {
View Full Code Here

TOP

Related Classes of net.jini.core.lease.Lease

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.