Package com.sun.jini.qa.harness

Examples of com.sun.jini.qa.harness.TestException


                                          Integer.MAX_VALUE);
    if(intfcM.totalMatches != expectedNMatchesIntfc[i][j]) {
        String message = "totalMatches ("+
      intfcM.totalMatches+") != expectedMatches["+
      i+"]["+j+"] ("+expectedNMatchesIntfc[i][j]+")";
        throw new TestException(message);
    } else {
        if (!setsAreEqual(j,intfcM)) {
      throw new TestException
          ("At index "+j+", the services do NOT match");
        }
    }
      }
  }
View Full Code Here


      for(int j=0;j<fieldStr[i].length;j++) {
    try {
              fieldValues = proxy.getFieldValues(tmpl,i,fieldStr[i][j]);
              if (!(fieldValuesEqualExpected(fieldValues,i,j)))
        {
                  throw new TestException
                              ("For Attr["+i+"], Field ("+fieldStr[i][j]+
                                                  "): Unexpected Value");
        }
    } catch (NoSuchFieldException e) {
              if (!(fieldValuesEqualExpected(fieldValues,i,j)))
        {
                  throw new TestException
                              ("For Attr["+i+"], Field ("+fieldStr[i][j]+
                                                  "): Unexpected Value");
        }
       }
      }
View Full Code Here

    set.clearExpirationWarningListener();
      }
  } catch (Exception ex) {
      String message = "Multiple calls to " +
    "clearExpirationWarningListener raises an exception.";
      throw new TestException(message, ex);
  }

  RemoteEvent[] events = rrl.getEvents();
  if (events.length < 1) {
      String message = "Listener did not receive any events.\n" +
    "Should have received exactly one.";
      throw new TestException(message);
  } else if (events.length > 1) {
      String message = "Listener received " + events.length +
    "events.\n" + "Should have received exactly one.";
      throw new TestException(message);
  }

  // There is only one event received, now allow lease to expire
  Lease setLease = rrl.getLastLeaseRenewed();
  rstUtil.waitForLeaseExpiration(setLease,
               "for renewal set to expire.");
 
  // lease should now be expired, prove it ...
  try {
      set.setExpirationWarningListener(rrl, minWarning, null);
      String message = "The set's lease did not expire as expected.";
      throw new TestException(message);
      // we should not get to this place
  } catch (NoSuchObjectException ex) {
      // we are golden if we get to here so just keep on trucking ...
      logger.log(Level.FINE, "Renewal set has expired as expected.");
  }     

  // presumably there has only been one call to renew
  events = rrl.getEvents();
  if (events.length > 1) {
      String message = "Listener has renewed the lease" +
    events.length + "times.\n" +
    "Should have renewed it exactly one.";
      throw new TestException(message);
  }
    }
View Full Code Here

    public void run() throws Exception {
  ServiceMatches exactM = null;
  for (int i=0; i<nClasses; i++) {
      exactM = proxy.lookup(exactClassTmpls[i],Integer.MAX_VALUE);
      if (exactM.totalMatches != expectedNMatchesExact[i]) {
    throw new TestException
        ("totalMatches ("+exactM.totalMatches+
         ") != expectedMatches["+
         i+"] ("+expectedNMatchesExact[i]+")");
      } else {
    if (!setsAreEqual(i,exactM)) {
        throw new TestException
      ("At index "+i+", the services do NOT match");
    }
      }
  }
    }
View Full Code Here

      classTypes = proxy.getServiceTypes(attrTmpls[i],null);
      if (!QATestUtils.classTypesEqualTypeDescriptors
    (classTypes,
     expectedTypeDescs))
          {
              throw new TestException("For Attribute["+i+
              "], not all service type descriptors were returned");
    }
  }
    }
View Full Code Here

        String message =
      "totalMatches ("+ superM.totalMatches +
      ") != expectedMatches[" +
      i + "]["+ j +
      "] ("+expectedNMatchesSuper[i][j]+")";
        throw new TestException(message);
    } else {
        if (!setsAreEqual(i,superM)) {
      throw new TestException
          ("At index "+i+", the services do NOT match");
        }
    }
      }
  }
View Full Code Here

  Class[] classTypes = null;
  classTypes = proxy.getEntryClasses(emptyTmpl);
  if (!QATestUtils.classTypesEqualTypeDescriptors(classTypes,
              expectedTypeDescs))
  {
      throw new TestException("not ALL service type descriptors "
            + "were returned");
  }
    }
View Full Code Here

  // wait for expiration warning event
  warnWaitThread.join(maxWaitTime);

  if (warnWaitThread.isAlive() == true) {
      String message = "ExpirationWarningEvent was never received.";
      throw new TestException(message);
  }
 
  // capture the expiration time of the warning event
  ExpirationWarningEvent warnEvent =
      (ExpirationWarningEvent) warnListener.getEvents()[0];
  long warnEventExpiration =
      prepareLease(warnEvent.getRenewalSetLease()).getExpiration();

  // wait for renewal failure event
  failWaitThread.join(maxWaitTime);

  // if the thread is still alive then the event was never received.
  if (failWaitThread.isAlive() == true) {
      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" +
    " of type " + failException.getClass() +
    "\nbut an exception of type " +
    targetException.getClass() + " is excepted.";
      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);
  }

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

  /* ASSERTION #4
     The lease whose renewal failed should have been removed
     from the renewal set. */
  Lease managedLease = set.remove(failLease);
  if (managedLease != null) {
      String message = "Assertion #4 failed.\n" +
    "Failed lease was never removed from renewal set.";
      throw new TestException(message);
  }
 
  logger.log(Level.FINE, "Assertion #4 passed.");
    }
View Full Code Here

  // they should be the same
  if (lease01.equals(lease02) == false) {
      String message = "GetRenewalSetLease has returned an\n" +
           "invalid lease.";
      throw new TestException(message);
  }

  /* okay they are the same lease but are they the correct lease??
     well, we can't be sure but we can check to make sure that the
     lease will expire in at least setRenewDur time. */
  logger.log(Level.FINE, "Removing lease from the LRM.");
  lrm.remove(lease01);
  lease01 = prepareLease(set.getRenewalSetLease());
  rstUtil.sleepAndTell(renewSetDur, "for client lease to expire.");
  if (rstUtil.isExpired(lease01) == false) {
      String message = "getRenewalSetLease seems to have\n" +
           "returned an invalid lease based upon\n" +
           "the expiration time.";
      throw new TestException(message);
  }
    }
View Full Code Here

  logger.log(Level.FINE, "Removing the managed lease from the set.");
  Lease managedLease = set.remove(testLease);
  if (managedLease == null) {
      String message = "Lease could not be removed from\n";
      message += "renewal set.";
      throw new TestException(message);
  }

  // wait the lease to expire
  boolean isExpired  =
      rstUtil.waitForLeaseExpiration(testLease,
             "for client lease to expire.");
  if (isExpired == false) {
      rstUtil.waitForLeaseExpiration(testLease,
             "a second time " +
             "for client lease to expire.");
  }

  // assert that renew was never called on the lease
  logger.log(Level.FINE, "Checking # of calls to renew.");
  if (owner.getRenewCalls() > 0) {
      String message = "An invalid call to renew was made on \n";
      message += "a lease that was not in a renewal set.";
      throw new TestException(message);
  }

  logger.log(Level.FINE, "Checking # of calls to batch renew.");
  if (owner.getRenewCalls() > 0) {
      String message = "An invalid call to batchRenew was made\n" +
           "on \n" + "a lease that was not in a" +
    "renewal set.";
      throw new TestException(message);
  }

  // assert that cancel was never called on the lease
  logger.log(Level.FINE, "Checking # of calls to cancel.");
  if (owner.getCancelCalls() > 0) {
      String message = "An invalid call to cancel was made on \n";
      message += "a lease that was not in a renewal set.";
      throw new TestException(message);
  }

  // also just to be certain check that the lease is expired.
  if (rstUtil.isExpired(testLease) == false) {
      String message = "Lease did not expire as expected.\n";
      message += "The renew method was somehow called in error.";
      throw new TestException(message);
  }
    }
View Full Code Here

TOP

Related Classes of com.sun.jini.qa.harness.TestException

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.