Package com.sun.jini.qa.harness

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


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


     * event; and that the transition associated with the event equals
     * the expected transition.
     */
    private void verifyNotification(int transition) throws TestException {
  if(srvcItems.length != numEvnt )
            throw new TestException("# of Events Received ("+
            numEvnt+
            ") != # of Events Expected ("+
            srvcItems.length+")");

  for(int i=0; i <srvcItems.length; i++) {
      if(!verifyServiceItemTransition(srvcItems[i],transition)) {
                throw new TestException("transition mismatch (index "+i+")");
      }
  } 
    }
View Full Code Here

      set.renewFor(testLease, 0);
      // success, keep on trucking ...
  } catch (IllegalArgumentException ex) {
      String message = "An attempt to add a client lease\n";
      message += " with a 0 membership duration has failed.";
      throw new TestException(message, ex);
  }     

  /* assert that using a membership duration of -99 (negative test)
     does NOT generate an IllegalArgumentException */
  try {
      set.renewFor(testLease, -99);
      // success, keep on trucking ... 
  } catch (IllegalArgumentException ex) {
      String message = "An attempt to add a client lease\n";
      message += "with a negative membership duration has ";
      message += "failed.";
      throw new TestException(message, ex);
  }     

  // trying to remove the lease should result in null value
  Lease managedLease = set.remove(testLease);
  if (managedLease != null) {
      String message = "Lease was added to renewal set in error\n";
      message += "from a call to renewFor with 0 membership.";
      throw new TestException(message);
  }
 
  /* assert that using a membership duration of Lease.ANY
     does NOT generate an IllegalArgumentException */
  try {
      set.renewFor(testLease, Lease.ANY);
      set.remove(testLease);
      // success, keep on trucking ...
  } catch (IllegalArgumentException ex) {
      String message = "An attempt to add a client lease\n";
      message += "with a Lease.ANY membership duration\n";
      message += "has failed with an IllegalArgumentException.";
      throw new TestException(message, ex);
  }     

  /* assert that using a membership duration of Lease.FOREVER
     does NOT generate an IllegalArgumentException */
  try {
      set.renewFor(testLease, Lease.FOREVER);
      set.remove(testLease);
      // success, keep on trucking ...
  } catch (IllegalArgumentException ex) {
      String message = "An attempt to add a client lease\n";
      message += "with a Lease.FOREVER membership duration\n";
      message += "has failed with an IllegalArgumentException.";
      throw new TestException(message, ex);
  }     

  /* assert that using a membership duration of Long.MAX_VALUE
     does NOT generate an IllegalArgumentException */
  try {
      set.renewFor(testLease, Long.MAX_VALUE);
      set.remove(testLease);
      // success, keep on trucking ...
  } catch (IllegalArgumentException ex) {
      String message = "An attempt to add a client lease\n";
      message += "with a Long.MAX_VALUE membership duration\n";
      message += "has failed with an IllegalArgumentException.";
      throw new TestException(message, ex);
  }     

  /* assert that using a membership duration of 1 (edge case)
     does NOT generate an IllegalArgumentException */
  try {
      set.renewFor(testLease, 1);
      set.remove(testLease);
      // success, keep on trucking ...
  } catch (IllegalArgumentException ex) {
      String message = "An attempt to add a client lease\n";
      message += "with a 1 millisecond membership duration\n";
      message += "has failed with an IllegalArgumentException.";
      throw new TestException(message, ex);
  }     

  /* assert that using a membership duration of 30000 (normal case)
     does NOT generate an IllegalArgumentException */
  try {
      set.renewFor(testLease, 30000L);
      set.remove(testLease);
      // success, keep on trucking ...
  } catch (IllegalArgumentException ex) {
      String message = "An attempt to add a client lease\n";
      message += "with a 30000 millisecond membership duration\n";
      message += "has failed with an IllegalArgumentException.";
      throw new TestException(message, ex);
  }     
    }
View Full Code Here

    public void run() throws Exception {
  ServiceRegistration[] oldSrvcRegs = super.registerAll();
  /* "pretend" the registration process failed ==> must re-register */
  ServiceRegistration[] newSrvcRegs = super.registerAll();
  if ( oldSrvcRegs.length != newSrvcRegs.length ) {
      throw new TestException
                ("Original number of services registered ("
                 +oldSrvcRegs.length+
                 ") != number of services RE-registered ("
                 +newSrvcRegs.length+")");
  } else {
      for (int i = 0; i < oldSrvcRegs.length; i++ ) {
          if ( !(oldSrvcRegs[i].getServiceID().equals
                                       (newSrvcRegs[i].getServiceID())) )
          {
              throw new TestException
                        ("Index " + i + "Service IDs not equal ("
                         +oldSrvcRegs[i].getServiceID()+" & "
                         +newSrvcRegs[i].getServiceID()+")");
    }
      }
View Full Code Here

        for (int i = 0; i < testCases.length; i++) {
            logger.log(Level.FINE, "\n\t+++++ Test Case #" + (i + (int) 1));

            if (!checker(testCases[i])) {
                throw new TestException(
                        "" + " test failed");
            }
        }
        return;
    }
View Full Code Here

        for (int i = 0; i < constraints.length; i++) {
            logger.log(Level.FINE, "\n\t+++++ Test Case #" + (i + (int) 1));

            if (!checker(constraints[i])) {
                throw new TestException(
                        "" + " test failed");
            }
        }
        return;
    }
View Full Code Here

                classes.add(NotPrincipal.class);
                callConstructor(testCase, (Collection) classes,
                        IllegalArgumentException.class);
            } else {
                logger.log(Level.FINE, "Bad Test Case: " + testCase.toString());
                throw new TestException(""
                        + " test failed");
            }
        } catch (TestException e) {
            logger.log(Level.FINE, "Test Case failed: " + e);
            throw new TestException(""
                    + " test failed");
        }
        return;
    }
View Full Code Here

                    || tc == CL_MIN_PR_TYPE__ARRAY__EMPTY
                    || tc == CL_MIN_PR_TYPE__ARRAY__PRIM_TYPE
                    || tc == CL_MIN_PR_TYPE__ARRAY__ARRAY_TYPE
                    || tc == CL_MIN_PR_TYPE__ARRAY__NOT_PRINCIPAL) {
                logger.log(Level.FINE, "Expected Exception type:: " + ex);
                throw new TestException("Instead of " + ex + " no Exception"
                        + " has been thrown while invoking constructor");
            }
        } catch (Exception e) {
            logger.log(Level.FINE, "Exception while invoking constructor " + e);
            // If no Exception is expected
            if (       tc == CL_MAX_PR_TYPE__CLASS
                    || tc == CL_MIN_PR_TYPE__CLASS
                    || tc == CL_MAX_PR_TYPE__ARRAY
                    || tc == CL_MIN_PR_TYPE__ARRAY) {
                throw new TestException("Exception while invoking constructor ",
                        e);
            }

            // If some Exception is expected
            if (!ex.equals(e.getClass())) {
                logger.log(Level.FINE, "Expected Exception:: " + ex);
                logger.log(Level.FINE, "Thrown   Exception:: " + e.getClass());
                throw new TestException("Instead of " + ex + " "
                        + e.getClass() + " has been thrown while"
                        + " invoking constructor");
            } else {
                return;
            }
        }

        // logger.log(Level.INFO, "Returned object: " + ic.toString());

        /*
         * Verify that the corresponding constraint object is created.
         */
        if (ic == null) {
            logger.log(Level.FINE, "Constraint object hasn't been created");
            throw new TestException("Constraint object hasn't been created");
        }

        if (       (tc == CL_MAX_PR_TYPE__CLASS
                 || tc == CL_MAX_PR_TYPE__ARRAY)
                && !(ic instanceof ClientMaxPrincipalType)) {
            logger.log(Level.FINE,
                    "Instead of ClientMaxPrincipalType " + ic.getClass()
                    + " object is returned");
            throw new TestException("Instead of ClientMaxPrincipalType "
                    + ic.getClass() + " object is returned");
        } else if ((tc == CL_MIN_PR_TYPE__CLASS
                 || tc == CL_MIN_PR_TYPE__ARRAY)
                && !(ic instanceof ClientMinPrincipalType)) {
            logger.log(Level.FINE,
                    "Instead of ClientMinPrincipalType " + ic.getClass()
                    + " object is returned");
            throw new TestException("Instead of ClientMinPrincipalType "
                    + ic.getClass() + " object is returned");
        }

        /*
         * Verify that the argument passed to the constructor isn't modified.
         * Compare argument for the constructor before and after invoking the
         * constructor.
         */

        // logger.log(Level.INFO, "Argument before invoking the constructor:");
        // for (int i = 0; i < cl_copy.length; i++) {
        // logger.log(Level.INFO, "cl_copy[" + i + "]:: " + cl_copy[i]);
        // }
        // logger.log(Level.INFO, "Argument after invoking the constructor :");
        // for (int i = 0; i < cl.length; i++) {
        // logger.log(Level.INFO, "cl[" + i + "]:: " + cl[i]);
        // }
        if (!Arrays.equals(cl, cl_copy)) {
            logger.log(Level.FINE,
                    "The argument passed to the constructor is modified");
            throw new TestException("The argument passed to the constructor"
                    + " is modified");
        }
        logger.log(Level.FINE,
                "The argument passed to the constructor isn't modified");

        /*
         * Verify that the argument passed to the constructor isn't retained;
         * subsequent changes to that argument have no effect on the instance
         * created. Compare set of all of the classes from the created
         * object before and after changing the argument.
         */
        Set icSet_before = null;

        try {
            Class icClass = ic.getClass();
            Method elementsMethod = icClass.getMethod("elements", null);
            // Get set of classes from the created constraint
            icSet_before = (Set) elementsMethod.invoke(ic, null);

            /*
             * Change argument passed to the constructor while creating
             * the constraint
             */
            for (int i = 0; i < cl.length; i++) {
                cl[i] = Exception.class;
            }

            // Get set of classes from the created constraint
            Set icSet_after = (Set) elementsMethod.invoke(ic, null);
            // logger.log(Level.INFO, "Set of all of the classes of created object"
            // + " before modification of arg passed to the constructor: "
            // + icSet_before);
            // logger.log(Level.INFO, "Set of all of the classes of created object"
            // + " after modification of arg passed to the constructor : "
            // + icSet_after);
            if (!icSet_after.equals(icSet_before)) {
                logger.log(Level.FINE,
                        "The argument passed to the constructor is retained");
                throw new TestException("The argument passed to the"
                        + " constructor is retained");
            }
        } catch (Exception e) {
            logger.log(Level.FINE,
                    "Exception is thrown while invoking elements() method using"
                    + " reflection: " + e);
            throw new TestException("Exception is thrown while invoking"
                    + " elements() method using reflection.", e);
        }
        logger.log(Level.FINE,
                "The argument passed to the constructor isn't retained");

View Full Code Here

                    || tc == CL_MIN_PR_TYPE__COLL__ILL_EL
                    || tc == CL_MIN_PR_TYPE__COLL__PRIM_TYPE
                    || tc == CL_MIN_PR_TYPE__COLL__ARRAY_TYPE
                    || tc == CL_MIN_PR_TYPE__COLL__NOT_PRINCIPAL) {
                logger.log(Level.FINE, "Expected Exception type:: " + ex);
                throw new TestException("Instead of " + ex + " no Exception"
                        + " has been thrown while invoking constructor");
            }
        } catch (Exception e) {
            logger.log(Level.FINE, "Exception while invoking constructor: " + e);
            // If no Exception is expected
            if (       tc == CL_MAX_PR_TYPE__COLL
                    || tc == CL_MIN_PR_TYPE__COLL) {
                throw new TestException(
                        "Exception while invoking constructor", e);
            }

            // If some Exception is expected
            if (!ex.equals(e.getClass())) {
                logger.log(Level.FINE, "Expected Exception:: " + ex);
                logger.log(Level.FINE, "Thrown   Exception:: " + e.getClass());
                throw new TestException("Instead of " + ex + " "
                        + e.getClass() + " has been thrown while"
                        + " invoking constructor");
            } else {
                return;
            }
        }

        // logger.log(Level.INFO, "Returned object: " + ic.toString());

        /*
         * Verify that the corresponding constraint object is created.
         */
        if (ic == null) {
            logger.log(Level.FINE, "Constraint object hasn't been created");
            throw new TestException("Constraint object hasn't been created");
        }

        if (       tc == CL_MAX_PR_TYPE__COLL
                && !(ic instanceof ClientMaxPrincipalType)) {
            logger.log(Level.FINE,
                    "Instead of ClientMaxPrincipalType " + ic.getClass()
                    + " object is returned");
            throw new TestException("Instead of ClientMaxPrincipalType "
                    + ic.getClass() + " object is returned");
        } else if (tc == CL_MIN_PR_TYPE__COLL
                && !(ic instanceof ClientMinPrincipalType)) {
            logger.log(Level.FINE,
                    "Instead of ClientMinPrincipalType " + ic.getClass()
                    + " object is returned");
            throw new TestException("Instead of ClientMinPrincipalType "
                    + ic.getClass() + " object is returned");
        }

        /*
         * Verify that the argument passed to the constructor isn't modified.
         * Compare argument for the constructor before and after invoking the
         * constructor.
         */

        // logger.log(Level.INFO, "Argument before invoking the constructor: "
        // + cl_copy);
        // logger.log(Level.INFO, "Argument after invoking the constructor : "
        // + cl);
        if (!cl.equals(cl_copy)) {
            logger.log(Level.FINE,
                    "The argument passed to the constructor is modified");
            throw new TestException("The argument passed to the constructor"
                    + " is modified");
        }
        logger.log(Level.FINE,
                "The argument passed to the constructor isn't modified");

        /*
         * Verify that the argument passed to the constructor isn't retained;
         * subsequent changes to that argument have no effect on the instance
         * created. Compare set of all of the classes from the created
         * object before and after changing the argument.
         */
        Set icSet_before = null;

        try {
            Class icClass = ic.getClass();
            Method elementsMethod = icClass.getMethod("elements", null);
            // Get set of classes from the created constraint
            icSet_before = (Set) elementsMethod.invoke(ic, null);

            /*
             * Change argument passed to the constructor while creating
             * the constraint
             */
            cl.clear();
            // Get set of classes from the created constraint
            Set icSet_after = (Set) elementsMethod.invoke(ic, null);
            // logger.log(Level.INFO, "Set of all of the classes of created object"
            // + " before modification of arg passed to the constructor: "
            // + icSet_before);
            // logger.log(Level.INFO, "Set of all of the classes of created object"
            // + " after modification of arg passed to the constructor : "
            // + icSet_after);
            if (!icSet_after.equals(icSet_before)) {
                logger.log(Level.FINE,
                        "The argument passed to the constructor is retained");
                throw new TestException("The argument passed to the"
                        + " constructor is retained");
            }
        } catch (Exception e) {
            logger.log(Level.FINE,
                    "Exception is thrown while invoking elements() method using"
                    + " reflection: " + e);
            throw new TestException("Exception is thrown while invoking"
                    + " elements() method using reflection.", e);
        }
        logger.log(Level.FINE,
                "The argument passed to the constructor isn't retained");

View Full Code Here

            for (int i = j + 1; i < arr.length; i++) {
                if (arr[i].equals(arr[j])) {
                    logger.log(Level.FINE, "Duplicates aren't removed");
                    logger.log(Level.FINE, "arr[" + j + "]:: " + arr[j]);
                    logger.log(Level.FINE, "arr[" + i + "]:: " + arr[i]);
                    throw new TestException("Duplicates aren't removed");
                }
            }
        }
    }
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.