Examples of TestLease


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

  }

  // create the three leases to be managed
  logger.log(Level.FINE, "Creating lease #1 with duration of " +
        renewGrant + " milliseconds.");
  TestLease lease01 =
      leaseProvider.createNewLease(failingOwner,
           rstUtil.durToExp(renewGrant));
  set.renewFor(lease01, Long.MAX_VALUE);

  logger.log(Level.FINE, "Creating lease #2 with duration of " +
        renewGrant + " milliseconds.");
  TestLease lease02 =
      leaseProvider.createNewLease(failingOwner,
           rstUtil.durToExp(renewGrant));
  set.renewFor(lease02, Long.MAX_VALUE);

  logger.log(Level.FINE, "Creating lease #3 with duration of " +
        renewGrant + " milliseconds.");
  TestLease lease03 =
      leaseProvider.createNewLease(failingOwner,
           rstUtil.durToExp(renewGrant));
  set.renewFor(lease03, Long.MAX_VALUE);

  // sleep until the leases have expired.
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));
  testLease.setSerialFormat(Lease.ABSOLUTE);
  long originalExpTime = testLease.getExpiration();

  // start managing the lease
  logger.log(Level.FINE, "Adding lease with membership of " +
        "Long.MAX_VALUE");
  set.renewFor(testLease, Long.MAX_VALUE);
View Full Code Here

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

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

  // create 3 test leases to be managed
  logger.log(Level.FINE, "Creating a normal lease #1 to be managed.");
  logger.log(Level.FINE, "Duration == Lease.FOREVER");
  TestLease testLease01 =
      leaseProvider.createNewLease(leaseOwner, Lease.FOREVER);

  logger.log(Level.FINE, "Creating a normal lease #2 to be managed.");
  logger.log(Level.FINE, "Duration == Lease.FOREVER");
  TestLease testLease02 =
      leaseProvider.createNewLease(leaseOwner, Lease.FOREVER);

  logger.log(Level.FINE, "Creating a normal lease #3 to be managed.");
  logger.log(Level.FINE, "Duration == Lease.FOREVER");
  TestLease testLease03 =
      leaseProvider.createNewLease(leaseOwner, Lease.FOREVER);

  // start managing the normal leases forever
  logger.log(Level.FINE, "Adding normal lease #1 with membership of " +
        "Lease.FOREVER");
  set.renewFor(testLease01, Lease.FOREVER);

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

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

  // create 2 unreadable test leases to be managed
  logger.log(Level.FINE, "Creating an unreadable lease #1 to be" +
        " managed.");
  logger.log(Level.FINE, "Duration == Lease.FOREVER");
  TestLease specialLease01 =
      unreadableLeaseProvider.createNewLease(leaseOwner,
               Lease.FOREVER);

  logger.log(Level.FINE, "Creating an unreadable lease #2 to be" +
        " managed.");
  logger.log(Level.FINE, "Duration == Lease.FOREVER");
  TestLease specialLease02 =
      unreadableLeaseProvider.createNewLease(leaseOwner,
               Lease.FOREVER);
  // start managing the unreadable leases forever
  logger.log(Level.FINE, "Adding unreadable lease #1 with membership" +
        " of Lease.FOREVER");
  set.renewFor(specialLease01, Lease.FOREVER);

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

  /* Assert that a LeaseUnmarshalException is thrown when getLeases()
     is called */
  try {
      UnreadableTestLease.setFailMode(true);
      Lease[] leaseArray = set.getLeases();
      UnreadableTestLease.setFailMode(false);

      /* here we have succeeded to getLeases so something went
         frightfully wrong */
      String message =
    "The getLeases() method succeeded but should\n" +
    "have thrown a LeaseUnmarshalException.";
      throw new TestException(message);

  } catch (LeaseUnmarshalException ex) {
  // since this exception is expected, don't include it
  // in any throw TestExceptions which follow

      // set failure mode
      UnreadableTestLease.setFailMode(false);

      /* assert that the getLeases has exactly the
         3 leases we are expecting. */
      Lease[] goodLeases = ex.getLeases();
      if (goodLeases.length != 3) {
    String message = "The getLeases method returned " +
        goodLeases.length + " leases.\n" + "We were" +
        " expecting 3.";
        throw new TestException(message);
      }

      // are they the three that we expect??
      if (rstUtil.indexOfLease(testLease01, goodLeases) == -1) {
    String message = "Unmarshalled array is missing normal" +
        " lease #1";
    throw new TestException(message);
      }

      if (rstUtil.indexOfLease(testLease02, goodLeases) == -1) {
    String message = "Unmarshalled array is missing normal" +
        " lease #2";
    throw new TestException(message);
      }

      if (rstUtil.indexOfLease(testLease03, goodLeases) == -1) {
    String message = "Unmarshalled array is missing normal" +
        " lease #3";
    throw new TestException(message);
      }

      /* assert that the getMarshalledLeases has exactly the
         2 leases we are expecting. */
      MarshalledObject[] badLeases = ex.getMarshalledLeases();
      if (badLeases.length != 2) {
    String message = "The getLeases method returned " +
        badLeases.length + " marshalled objects.\n" +
        "We were expecting 2.";
        throw new TestException(message);
      }

      // are they the two that we expect??
      if (rstUtil.indexOfLease(specialLease01, badLeases) == -1) {
    String message = "StillMarshalled array is missing" +
        " special lease #1";
    throw new TestException(message);
      }

      if (rstUtil.indexOfLease(specialLease02, badLeases) == -1) {
    String message = "StillMarshalled array is missing" +
        " special lease #2";
    throw new TestException(message);
      }


      /* assert that the getExceptions has exactly the
         2 two we are expecting. */
      Throwable[] exception = ex.getExceptions();
      if (exception.length != 2) {
    String message = "The getExceptions method returned " +
        exception.length + " exceptions.\n" +
        "We were expecting 2.";
        throw new TestException(message);
      }

      /* the exceptions have the lease id embedded so we can
         check which exception goes with which lease */
      int[] exceptionID = new int[exception.length];
      for (int i = 0; i < exception.length; ++i) {
    String eMessage = exception[i].getMessage();
    StringTokenizer sTok =
        new StringTokenizer(eMessage, "=");
    sTok.nextToken(); // skip leading text
    String idStr = sTok.nextToken().trim();
    exceptionID[i] = Integer.parseInt(idStr);
      }

      // assert that the ids of the exceptions and leases match
      int leaseIndex =
    rstUtil.indexOfLease(specialLease01, badLeases);
      if (exceptionID[leaseIndex] != specialLease01.id()) {
    String message = "The order of the leases in the\n" +
        "bad leases array does not correspond to the\n" +
        "order of the exceptions in the exceptions array.";
    throw new TestException(message);
      }

      leaseIndex = rstUtil.indexOfLease(specialLease02, badLeases);
      if (exceptionID[leaseIndex] != specialLease02.id()) {
    String message = "The order of the leases in the\n" +
        "bad leases array does not correspond to the\n" +
        "order of the exceptions in the exceptions array.";
    throw new TestException(message);
      }
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.");
  logger.log(Level.FINE, "Duration == " + renewGrant);
  TestLease testLease =
      leaseProvider.createNewLease(owner,
           rstUtil.durToExp(renewGrant));

  // start managing the lease for only half of its grant time
  logger.log(Level.FINE, "Adding managed lease to lease renewal set.");
View Full Code Here

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

  set.setRenewalFailureListener(normalListener, null);

  // create a lease that will fail during renewal attempts
  logger.log(Level.FINE, "Creating lease with duration of " +
        renewGrant + " milliseconds.");
  TestLease lease =
      leaseProvider.createNewLease(failingOwner,
           rstUtil.durToExp(renewGrant));
 
  // add the lease to the renewal set w/ membership of renewGrant
  logger.log(Level.FINE, "Adding lease to renewal set.");
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

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